0
0

Am wondering, i need to play two files at the same time.

1) I have “music” playing.

when they enter the ScreenName and hit return, i want a sound effect “while” the music is playing.
basicly, i want to be able to play the effect without the background music stopping.

i use;

FSOUND_PlaySound()

to play the files, i have even tryed.

//////////////////////////////////////////////////////////////////////////
FSOUND_SAMPLE *Effects[20]; // effects
FSOUND_SAMPLE *pSound; // my music
int soundChannel = 0; // for music
int effectChannel = 0; // for effects

void PlayCurrent(int location, bool music)
{
if (music)
soundChannel = FSOUND_PlaySound(FSOUND_FREE,pSound);
else
effectChannel = FSOUND_PlaySound(FSOUND_FREE,Effects[location]);
}

//////////////////////////////////////////////////////////

But the main pSound stopps while the effect plays

Thanks
Bah_cpp

  • You must to post comments
0
0

I could just say how would i play two *.wav files simultainously.

  • You must to post comments
0
0

hmmm, well this is the function i wrote to set the base music and or sound effects.

[code:20ve6t9x]
//================
// SndSetup
//
================

int SndSetup(char *filename, bool loop, bool music, int location)
{

if (music == false)
{

    if (!FSOUND_Init(44100, 32, FSOUND_INIT_GLOBALFOCUS))
    {
        MessageBox(NULL,"fmod init failed","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
        return false;
    }  

    Effects[location] = FSOUND_Sample_Load (FSOUND_FREE,filename,0,0);

    if (!Effects[location])
    {
        MessageBox(NULL,"Could not load sound, corrupt/invalid path.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
        return false;
    }

//  if (loop) FMUSIC_SetLooping(peffects[location], TRUE);
}

else if (music)
{ 

    if (!FSOUND_Init(44100, 32, FSOUND_INIT_GLOBALFOCUS))
    {
        MessageBox(NULL,"fmod init failed","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
        return false;
    }  

    pSound = FSOUND_Sample_Load (FSOUND_FREE,filename,0,0);

    if (!pSound)
    {
        MessageBox(NULL,"Could not load sound, corrupt/invalid path.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
        return false;
    }

// if (loop) FMUSIC_SetLooping(pSound, TRUE);
}

return true;

}
[/code:20ve6t9x]

any see anything wrong here?

  • You must to post comments
0
0

erm, yeah but with diffrent thigns….
oh wait…. opps lol…..

first call is this…
[code:1fabs2wu]
void IntroInit(char *TextName, char *SongName, bool SongFlag)
{
FontInit(TextName, 23);

if (SongFlag)
{
    if (!SndSetup(SongName, true, true, NULL))
        SysShutdown();

}

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
INTRO = true;

}
[/code:1fabs2wu]

second….
[code:1fabs2wu]
void NameEnterd(void)
{
CopySName(ScreenName, Name);
SndSetup("data/sounds/start.ogg",false,false,0);
PlayCurrent(0,false);
}
[/code:1fabs2wu]
so… i should not call that function more then once, as it overwrites the current state?

i can re-code that function so its only executed once… then would it be the case off..

[code:1fabs2wu]
Effects[location] = FSOUND_Sample_Load (FSOUND_FREE,filename,0,0);

    if (!Effects[location])
    {
        MessageBox(NULL,"Could not load sound, corrupt/invalid path.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
        return false;

[/code:1fabs2wu]

then just doing this….

effectChannel = FSOUND_PlaySound(FSOUND_FREE,Effects[location]);

would this be correct?

Thanks
bah_cpp

  • You must to post comments
0
0

Thank you very much for spotting that out for me. It has been fixed i have re-coded most functions its all working perfectly as expected now.

Thanks.
bah_cpp

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.