0
0

hi,

if i do

FSOUND_PlaySound(1, sample);

is there a way of later checking if channel 1 is free?

  • You must to post comments
0
0

cheers

  • You must to post comments
0
0

i’m just wondering how i can see what channel i’m playing on?
if i try:
FSOUND_PlaySound(FSOUND_FREE, sample);
it doesn’t always choose channel 1 or 2….
i’d like to be able to see what channels are in use without hardcoding what channel…

basically i’m making a game for my end of year uni project and already have music working, but cant play more than one track and cant play sound effects over the music… any help will be fantastic

cheers
Niik

  • You must to post comments
0
0

if i understand correctly the PlaySound function will return an integer value representing the channel number that FMOD used for that particular call.

so if you do

int channel = FSOUND_PlaySound(FSOUND_FREE, sample);

you will have the channel value stored in the variable channel.

i think.

  • You must to post comments
0
0

Im still getting an error, that i can’t play more than one stream, without restartign the app.

i can play one sound effect, or music track, but not two at the same time or one after another…

some of my code (maybe i’m missing something/doing something wrong):

[code:1zmzv5r8]

// loads the sound into a channel and pre-pares the song for playing

// a selection of 10 sounds/music tracks can be selected by pressing
// numbers 0-9,

// press the space bar if you want to stop the sound in mid play

FSOUND_STREAM* Music::LoadSong(Ogre::String songName)
{
static FSOUND_STREAM* songToPlay = NULL;
songToPlay = FSOUND_Stream_Open(songName.c_str(), FSOUND_2D, 0,0);
if (songToPlay != NULL)
{
FSOUND_Stream_Play(FSOUND_FREE, songToPlay);
}
}

//To stop the sounds, the current sounds being played is passed in

void Music::stopPlay(FSOUND_STREAM* songToPlay)
{
FSOUND_Stream_Stop(songToPlay);
}

[/code:1zmzv5r8]

** do i have to re-init after stopping the sounds?

** whether i press the spacebar to stop the sound, or it play out, i cannot start another track?

[/code]

  • You must to post comments
0
0

cheers brett,
yes it was a logic error… fixed now, but i get multiple echoes if i press the key for the same sound many times….

ie:
if i press “KC_4” (4/$)
it plays an explosion sound…
if i then press the same key either in or out of sequence with any other keys, i could press: 4,4,7,1,4,8,5,4
it will echo sound effect 4, four times in this case
or: 4, 4, 5, 7, 2, 3
it will echo it twice in this case…
if i press the space bar this is my code:
[code:1emawnxu]
// this stops all the channels

FSOUND_StopSound(FSOUND_ALL);
[/code:1emawnxu]

[code:1emawnxu]
Ogre::String Music::chooseSong(int songNumber)
{
Ogre::String songName;

switch (songNumber)
{
case 0:
    {
        songName = "../projects/Music_test/sfx/0.wav";
        break;
    }
case 1:
    {
        songName = "../projects/Music_test/sfx/1.wav";
        break;
    }
case 2:
    {
        songName = "../projects/Music_test/sfx/2.wav";
        break;
    }
case 3:
    {
        songName = "../projects/Music_test/sfx/3.wav";
        break;
    }
case 4:
    {
        songName = "../projects/Music_test/sfx/4.wav";
        break;
    }
case 5:
    {
        songName = "../projects/Music_test/sfx/5.wav";
        break;
    }
case 6:
    {
        songName = "../projects/Music_test/sfx/6.wav";
        break;
    }
case 7:
    {
        songName = "../projects/Music_test/sfx/7.mp3";
        break;
    }
case 8:
    {
        songName = "../projects/Music_test/sfx/8.mp3";
        break;
    }
case 9:
    {
        songName = "../projects/Music_test/sfx/9.mp3";
        break;
    }

default:
    {
        break;
    }
}
return songName;

}
[/code:1emawnxu]

// EDIT:

it actually builds up all the channels, so if i play 4, 2, 6, 7
by the time i press 7 it is playing 4 times, with a micro second delay….

and i have added
FSOUND_Stream_Close(songToPlay);

for when i try to stop the sounds

i may be able to find this myself…. will post again when i do

  • You must to post comments
0
0

I found why it is playing multiple times… the sound is being opened on multiple channels,

…. now to find how to stop that!

// Edit

fixed… !!

the keypress listener was registering a number of keypresses for each sound, so multiple channels were being opened.

  • You must to post comments
Showing 6 results
Your Answer

Please first to submit.