2

Can somebody explain me why I cant play two sounds at the same time ?

here a part of the code :

#include <fmod.h>

FMOD_SYSTEM *system;
FMOD_SOUND *dooropen;
FMOD_SOUND *keydoor;
FMOD_SOUND *slap;
FMOD_SOUND *bomb;
FMOD_SOUND *scratch;
FMOD_SOUND *secret;
FMOD_SOUND *pickey;
FMOD_SOUND *caisse;

FMOD_RESULT resultat1;
FMOD_RESULT resultat2;
FMOD_RESULT resultat3;
FMOD_RESULT resultat4;
FMOD_RESULT resultat5;
FMOD_RESULT resultat6;
FMOD_RESULT resultat7;
FMOD_RESULT resultat8;


FMOD_System_Create(&system);
FMOD_System_Init(system, 1, FMOD_INIT_NORMAL, NULL);


resultat1 = FMOD_System_CreateSound(system, "sound/door-open.mp3", FMOD_CREATESAMPLE, 0, &dooropen);

resultat2 = FMOD_System_CreateSound(system, "sound/key-door.wav", FMOD_CREATESAMPLE, 0, &keydoor);

resultat3 = FMOD_System_CreateSound(system, "sound/slap.wav", FMOD_CREATESAMPLE, 0, &slap);

resultat4 = FMOD_System_CreateSound(system, "sound/bomb.wav", FMOD_CREATESAMPLE, 0, &bomb);

resultat5 = FMOD_System_CreateSound(system, "sound/scratch.wav", FMOD_CREATESAMPLE, 0, &scratch);

resultat6 = FMOD_System_CreateSound(system, "sound/secret.wav", FMOD_CREATESAMPLE, 0, &secret);

resultat7 = FMOD_System_CreateSound(system, "sound/pickey.wav", FMOD_CREATESAMPLE, 0, &pickey);

resultat8 = FMOD_System_CreateSound(system, "sound/caisse.wav", FMOD_CREATESAMPLE, 0, &caisse);

And I call my sounds like this :

FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, scratch, 0, NULL);
FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, bomb, 0, NULL);

I think there's a channel problem because when I played "bomb" I can hear it (this sound is like 3 seconds) but if the "scratch" sounds happens the sound "bomb" is stopping...

caps lock
  • 511
  • 3
  • 7
  • 20

4 Answers4

3

The second parameter in FMOD_System_Init() is maxchannels. Just set it to 2 or higher. In the official tutorial they use 100.

qqx
  • 18,947
  • 4
  • 64
  • 68
kuzmas
  • 33
  • 5
1

try creating new systems for the amount of sounds you want to play simultaneously, or you can try using FSOUND_Play instead of FSOUND_Init.

or you can also check out the Hekkus Sound System. I used it already for multiple sounds and worked, but it doesn't support mp3.

  • Thank you, I created 7 more system and it works fine, but I dont think that was the best solution.. I dont understand why I needed to create a system for each sounds ! – caps lock May 22 '12 at 23:57
1

As said before init the system with more channels
and
update the FMOD_SYSTEM after each FMOD_System_PlaySound.

Just insert

FMOD_System_Update(system);

Then it will be okay.

user2737037
  • 1,119
  • 1
  • 16
  • 29
0

Create one channel per one sound and it will works fine or use FMOD_CHANNEL_FREE

Quest
  • 2,764
  • 1
  • 22
  • 44