0
0

Hi, i was just wondering how i could get to play two differnt sounds at the same time!

Basically the first one is the music which is loaded up at the begining than say like a couple of seconds later when something happenes in the game i play a voice sound! How can i set it to play on a different channel?

Currently i am doing:

[code:hpmg2l40]FSOUND_Init(44100, 32, 0);
FSOUND_STREAM* level;
//load and play song
level = FSOUND_Stream_Open("Sounds/Main Theme.wav",0, 0, 0);
FSOUND_Stream_Play (0,level);[/code:hpmg2l40]

thats for the music!

i than want to use a voice to play over this music without stopping it:

[code:hpmg2l40]FSOUND_Init(44100, 32, 0);
FSOUND_STREAM* voice;
//load and play voice
voice= FSOUND_Stream_Open("Sounds/angry.mp3",0, 0, 0);
FSOUND_Stream_Play (0,voice);[/code:hpmg2l40]

i think that the second 0 in this line

voice= FSOUND_Stream_Open(“Sounds/angry.mp3”,0, 0, 0);

is the channel number i want to play it on? I tried changing that to 2 and it crashed my computer!! So now i dont want to muck around with it!

All Help would be realy appreciated!
thnkx!!

  • You must to post comments
0
0

The 0 in your Play command is the channel argument. try using the Free constant so that fmod will automatically select an available channel for you.

  • You must to post comments
0
0

[quote="Janus":4tnlbkw4]The 0 in your Play command is the channel argument. try using the Free constant so that fmod will automatically select an available channel for you.[/quote:4tnlbkw4]

thnx for the quick responce!!

Could u plz help me with that, wat is the free constant?
sorry its just that ihavnt used fmod that much before so im pretty new to it and i need to complete my game for thursday and dont have any time left at all!
Any help would be really useful!

thnx

  • You must to post comments
0
0

[quote="Nads":3mqzrtub][quote="Janus":3mqzrtub]The 0 in your Play command is the channel argument. try using the Free constant so that fmod will automatically select an available channel for you.[/quote:3mqzrtub]

thnx for the quick responce!!

Could u plz help me with that, wat is the free constant?
sorry its just that ihavnt used fmod that much before so im pretty new to it and i need to complete my game for thursday and dont have any time left at all!
Any help would be really useful!

thnx[/quote:3mqzrtub]You’ll need to check your particular header, but I believe the constant is named FMOD_CHANNEL_FREE.

  • You must to post comments
0
0

also look in the documentation, the meaning of all the function parameters is explanied there

  • You must to post comments
0
0

I found this in the header file:

[code:85v0fpsu]#define FSOUND_FREE -1 [/code:85v0fpsu]

so does that mean for my bit of code i just set the all the channels for all my sounds to -1 ? and they should all automatically play on different channels??

like this? :

[code:85v0fpsu]FSOUND_Init(44100, 32, 0);
FSOUND_STREAM* Menu;
//load and play song
Menu = FSOUND_Stream_Open("Sounds/Menu Theme.mp3",0,[b]-1[/b], 0);
FSOUND_Stream_Play ([b]-1[/b],Menu);[/code:85v0fpsu]

and than the same for the next peice of sound aswell!!?

  • You must to post comments
0
0

right ive used this:

[code:3n5gz8t1]FSOUND_Init(44100, 32, 0);
FSOUND_STREAM* level;
//load and play song
level = FSOUND_Stream_Open("Sounds/Main Theme.wav",0, FSOUND_FREE, 0);
FSOUND_Stream_Play (FSOUND_FREE,level);[/code:3n5gz8t1]

and this:

[code:3n5gz8t1]FSOUND_Init(44100, 32, 0);
FSOUND_STREAM* fire;
//load and play song
fire = FSOUND_Stream_Open("Sounds/Gun_357mag.wav",0, FSOUND_FREE, 0);
FSOUND_Stream_Play (FSOUND_FREE,fire);[/code:3n5gz8t1]

the first one is a music file and starts playing right at the begining, than when the player presses fire the second one should also be played on top without stopping the first one. But it stops the first one and u can than only hear the gunshot and no music????

why is it doing that, it should be set to the next free channel!!
wats the solution?

plz anyone i need urgent help!
im running out of time!!! :(

  • You must to post comments
0
0

LOL yeh i just relised that back about 1hour ago!!

thnx for ur help.

I have another question how can i stop FSOUND_Stream_Play when i want it to so that i can play the next say music file?

it doesnt let me just overwrite it, that freezes the game so i want to stop it first and than play second one!!

  • You must to post comments
0
0

u see i know i can use

FSOUND_Stream_Close(level);

but the problem is that the level handler is in a different .cpp file and i want to stop it playing in the other file so it would say undeclared identifier if i did that bit above!

how can i use a handler which is in a differnt .cpp file?

  • You must to post comments
Showing 8 results
Your Answer

Please first to submit.