So I have the following code:
FMOD::Sound* aSound = NULL;
FMOD_CREATESOUNDEXINFO exinfo; memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO)); exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO); exinfo.length = aFile->GetSize(); DWORD a2Dor3D = FMOD_2D; if (mIs3DSounds) a2Dor3D = FMOD_3D; if (mLoadUsingStream) hRes = mFMODSystem->createStream((const char *)aFile->GetData(), FMOD_HARDWARE | FMOD_OPENMEMORY | a2Dor3D | FMOD_CREATECOMPRESSEDSAMPLE | FMOD_LOWMEM , &exinfo, &aSound); else hRes = mFMODSystem->createSound((const char *)aFile->GetData(), FMOD_HARDWARE | FMOD_OPENMEMORY | a2Dor3D | FMOD_CREATECOMPRESSEDSAMPLE | FMOD_LOWMEM , &exinfo, &aSound);[/code:1rifj8d1]
Where (const char *)aFile->GetData() is the name of a compressed file that has been loaded into memory that I want to play. The code works fine on 360 but I always get FMOD_ERR_INVALID_PARAM on Windows.
Removing the exinfo structure eliminates the invalid param error but replaces it with a FMOD_ERR_FORMAT error.
I’m relatively inexperienced with FMOD so if there’s something I’m missing here please let me know. This code was originally written by someone else who I am not able to contact.
- mbarney asked 7 years ago
Sadly that didn’t seem to work, I even removed all the flags except FMOD_OPENMEMORY and I still get invalid param.
aFile->GetSize(); does appear to be returning the correct size.
aFile->GetData() returns a BYTE* that points to the file data, not the file name sorry for the confusion.
I know this code works on 360 but I’m confused as to why it doesn’t work on PC…
I should also note that removing the passed in exinfo changes the error from invalid param to file not found (which makes sense as) so I don’t know if this indicates that there is something wrong with how I’m doing the exinfo or not. It lines up okay with the samples.
The first thing I notice is that you’re combining compressed samples with hardware sounds. Those two are incompatible. If you want compressed samples, they must be software sounds. Try changing FMOD_HARDWARE to FMOD_SOFTWARE.
Also, createStream() is basically the same as createSound() but passing in FMOD_CREATESTREAM, which is also incompatible with FMOD_CREATECOMPRESSEDSAMPLE. Try removing FMOD_CREATECOMPRESSEDSAMPLE from the createStream() call.
To open a file from memory, you’ll definitely need the EXINFO structure. However, I’m confused. You say:
[quote:2rgoyd2k](const char *)aFile->GetData() is the name of a compressed file that has been loaded into memory[/quote:2rgoyd2k]
Is it the name of the file, or is it a pointer to the file data? You should pass in a pointer to the actual file data, not the name of the file.
Assuming that that’s correct, I would check that the GetSize() and GetData() calls are returning the values that you’re expecting them to.
Hope that helps!
Please login first to submit.