0
0

I’m having trouble with instances of the same struct overwriting the other one’s sounds. Even though different WAV:s are loaded by the structs, the same sound (The last one loaded) is played from both.
The problem persist if the structs are made into an array or a vertex.

There might be a simple awnser to this, but i’m just a beginner with c++.

[code:3cf3mgoo]

include <iostream>

include <fmod.h>

struct shorse
{
FSOUND_SAMPLE* sound;
};

shorse horse1;
shorse horse2;

int main ()
{
FSOUND_Init (44100, 32, 0);

//Load DIFFERENT Sounds
horse1.sound = FSOUND_Sample_Load (0,"test.wav",0, 0, 0);
horse2.sound = FSOUND_Sample_Load (0,"test2.wav",0, 0, 0);

//Plays the same sound:
FSOUND_PlaySound (0,horse1.sound);
system("PAUSE");

FSOUND_PlaySound (0,horse2.sound);
system("PAUSE");

FSOUND_Sample_Free (horse1.sound);
FSOUND_Sample_Free (horse2.sound);
FSOUND_Close();
}
[/code:3cf3mgoo]

Thx in advance for your help!

  • You must to post comments
0
0

The problem is that you’re initialising your sounds on the same sample pool index here :

[code:bu40s0gb]horse1.sound = FSOUND_Sample_Load (0,"test.wav",0, 0, 0);
horse2.sound = FSOUND_Sample_Load (0,"test2.wav",0, 0, 0); [/code:bu40s0gb]
(the first parameter)

Let’s change to this :
[code:bu40s0gb]horse1.sound = FSOUND_Sample_Load (FSOUND_FREE,"test.wav",0, 0, 0);
horse2.sound = FSOUND_Sample_Load (FSOUND_FREE,"test2.wav",0, 0, 0); [/code:bu40s0gb]

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.