0
0

Hi!

I’d like to add fmod to my program that used to play wav resources by calling the mmsystem’s sndPlaySound function:

[code:db0x8p9l]HANDLE LoadResourceSound (HINSTANCE hInstance, LPCTSTR lpString)
{
HRSRC hRsrc;
HANDLE hGlobal;
CString wave;

hRsrc = FindResource(hInstance, lpString, "WAVE");
if (hRsrc != 0)
    hGlobal = LoadResource(hInstance, hRsrc);
else 
    hGlobal = 0;

return hGlobal;

}
void PlaySounds(HANDLE soundHandle, BOOL play)
{
if ((soundHandle != 0) && play)
{
sndPlaySound((LPCSTR) LockResource(soundHandle), SND_ASYNC
| SND_MEMORY);
UnlockResource(soundHandle);
}
}[/code:db0x8p9l]

I initialize the fmod engine by calling:

[code:db0x8p9l]FSOUND_Init(44100, 32, 0);[/code:db0x8p9l]

Then I can load and play Ogg Vorbis files:

[code:db0x8p9l]FSOUND_SAMPLE *LoadResourceSound2 (HINSTANCE hInstance, LPCTSTR lpString)
{
HRSRC hRsrc;
HANDLE hGlobal;
CString wave;
DWORD length;
FSOUND_SAMPLE *sample = NULL;

hRsrc = FindResource(hInstance, lpString, "OGG");
if (hRsrc != 0)
{
    hGlobal = LoadResource(hInstance, hRsrc);
    length = SizeofResource(hInstance, hRsrc);
}
else 
    hGlobal = 0;

if (hGlobal != 0)
{
    sample = FSOUND_Sample_Load(
        FSOUND_FREE, (const char *) hGlobal, FSOUND_LOADMEMORY, length);
    FSOUND_Sample_SetMode(sample, FSOUND_LOOP_OFF);
}

return sample;

}
void PlaySounds2(FSOUND_SAMPLE *sound2, BOOL play)
{
if ((sound2 != NULL) && play)
{
FSOUND_PlaySound(FSOUND_FREE, sound2);
}
}[/code:db0x8p9l]

But when I call PlaySounds to play a WAV file loaded from resource through LoadResourceSound, i’s mute!

I know it would be easy to load and play the WAV’s like the Ogg’s, through fmod, but it’s not quite possible or hard to achieve.

Why fmod mutes sndPlaySound? How can I use sndPlaySound and fmod at the same time?

Thanks for your help!

Kurta

  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.