Hi people. I’m using winxp with VC++ 6.0 and working on an MFC modeless dialog. I’m trying to load the music from the resource with FSOUND_Sample_Load. I search the forum and found the solution that brett posted in other thread previously. :) But I still can’t seem to get it right. Here’s the code that I’m having trouble with. ๐Ÿ˜•

IDR_SOUND1 //an midi file
IDR_SOUND2 // an mp3 file


int CBgnMusic::OnBgnMusicInit()
if (FSOUND_Init(44100,32,0) == FALSE)
return (0);
return (1);

void CBgnMusic::LoadToMem()
HRSRC rec;
HGLOBAL handle;
void *data;
DWORD length;

rec = FindResource(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_SOUND1), _T("Sound"));
handle = LoadResource(NULL, rec);
data = LockResource(handle);
length = SizeofResource(NULL, rec);


void CBgnMusic::OnBgnMusic1()
play1=FSOUND_Sample_Load(FSOUND_FREE, (const char *)data, FSOUND_LOADMEMORY,length);
m_debugBgnMusic.output << FSOUND_GetError() << endl;
FSOUND_PlaySound(FSOUND_FREE, play1);

I have checked that FSOUND_Init is success, and all rec, handle, data, and length have valid pointers like

rec 0x004072F8
handle 0x0040DF50
data 0x0040DF50
length 22950

and these will change if I change it to IDR_SOUND2.

The problem is play1 return 0x00000000, and I get error 11 (FMOD_ERR_FILE_FORMAT) when I use FSOUND_GetError() to check immediately after the play1 line.

I have used FSOUND_STREAM to play the midi file before I converted to FSOUND_SAMPLE and it works ok. Anyone know what I did wrong? Thanks.

edited: I place fmod.dll into the release folder and the root folder, and error 11 is changed to error 10 (FMOD_ERR_FILE_NOTFOUND). ๐Ÿ˜• When I was using FSOUND_STREAM before, fmod.dll has always been outside of release folder. But anyway, still return an error to me. :(

  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.