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
if (FSOUND_Init(44100,32,0) == FALSE)
rec = FindResource(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_SOUND1), _T("Sound")); handle = LoadResource(NULL, rec); data = LockResource(handle); length = SizeofResource(NULL, rec);
play1=FSOUND_Sample_Load(FSOUND_FREE, (const char *)data, FSOUND_LOADMEMORY,length);
m_debugBgnMusic.output << FSOUND_GetError() << endl;
I have checked that FSOUND_Init is success, and all rec, handle, data, and length have valid pointers like
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.
- hcn asked 14 years ago
- You must login to post comments