I’am having trouble creating sounds with FMOD using custom wave bank. The bank holds ADPCM or XMA compressed data with all the information needed to decode the sound. Since the wave bank is preloaded at level start all data is in the memory. What I’am trying to do is to pass particular sound data block to createSound with FMOD_OPENMEMORY_POINT flag so it won’t make unnecessary copy of the data. Before sound creation method I setup the FMOD_CREATESOUNDEXINFO structure. Unfotunatelly createSound gives me a FMOD_ERR_FORMAT message. I have tried many possibilities but no luck, so my question is is it possible to create a sound with FMOD_OPENMEMORY_POINT providing only the raw compressed ADPCM or XMA data block (Assuming proper setup of FMOD_CREATESOUNDEXINFO) ?
Also the wave bank ADPCM data is compressed with encoder delivered with DirectX SDK. Is it possible that it is not compatible with IMAADPCM decoder used in FMOD?
Thanks in advance,
- lromaniuk asked 5 years ago
To get raw ADPCM to work you must add FMOD_CREATECOMPRESSEDSAMPLE to your mode. Also exinfo.length should the compressed size of ADPCM data.
Assuming your platform is windows, do you mean the output window in visual studio? If you right click on the window is "Program Output" ticked?
Regarding the FMOD_OPENMEMORY_POINT the sound finally got created (with ADPCM format), but during playback it is havily distorted (it sounds like a mix of heavy clipping with noise). Is it possible that the distortion is caused by use of MS DX Sdk ADPCM encoder?
Another thing is, according to what you have said, that I will be unable to create sound that way from XMA or other compressed formats such as MP3 or CELT, is it true?
If so, here is another question:
In our application we are forced to use virtual memory to store our wavebank data. When particular sound data is needed we swap this data to physical memory. Is there possibility to achieve such a behavior when using FMODs FSB?
Regarding the FMOD logging version:
Yes the "Program Output" is checked. Call to FMOD::Debug_SetLevel(FMOD_DEBUG_ALL) gives me no error message, so everything seems to be ok, except that no logs are printed in the output window.
Our decoder handles standard IMA ADPCM.
EDIT: It appears the encoder in the directx SDK produces a different variant of ADPCM.
Can you elaborate on how you using virtual memory? What platforms are you on, what specific system API calls are using, are you catching page fault exceptions?
Hey, here’s the code. It’s striped of several unrelated method calls and error checks.
// Try to obtain sound definition
SoundSource* def = m_SoundBank.GetDef(soundID);
// Prepare it – if wave bank is used the data allready resides in memory
// Setup FMOD mode
FMOD_MODE mode = FMOD_SOFTWARE | FMOD_IGNORETAGS | FMOD_OPENMEMORY_POINT | FMOD_OPENRAW;
// Set proper format
FMOD_SOUND_FORMAT format = FMOD_SOUND_FORMAT::FMOD_SOUND_FORMAT_NONE;
if(def->GetFormat()->wFormatTag == WAVE_FORMAT_PCM)
format = FMOD_SOUND_FORMAT::FMOD_SOUND_FORMAT_PCM8;
format = FMOD_SOUND_FORMAT::FMOD_SOUND_FORMAT_PCM16;
format = FMOD_SOUND_FORMAT::FMOD_SOUND_FORMAT_PCM24;
format = FMOD_SOUND_FORMAT::FMOD_SOUND_FORMAT_PCM32;
else if(def->GetFormat()->wFormatTag == WAVE_FORMAT_ADPCM)
format = FMOD_SOUND_FORMAT::FMOD_SOUND_FORMAT_IMAADPCM;
else if( def->GetFormat()->wFormatTag == WAVE_FORMAT_XMA2)
format = FMOD_SOUND_FORMAT::FMOD_SOUND_FORMAT_XMA;
//Setup FMOD sound creation info structure
memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
exinfo.length = def->GetNumBytes(); // decompressed size
exinfo.numchannels = def->GetPlayFormat()->nChannels;
exinfo.defaultfrequency = def->GetPlayFormat()->nSamplesPerSec;
exinfo.suggestedsoundtype = FMOD_SOUND_TYPE::FMOD_SOUND_TYPE_RAW;
exinfo.format = format;
// Let’s try to create FMOD sound with MEMMORY_POINT to def sound data
FMOD::Sound* fmod_sound = 0;
// def->GetWaveData() is RAW sound data, pure samples
fmod_sys->createSound(def->GetWaveData(), mode, &exinfo, &fmod_sound);
// This setup gives FMOD_ERR_FORMAT
Hope it gives a better picture of what i’am trying to do.
One more thing. I’ve set up my project to compile with FMOD Log enabled libraries, but i have any FMOD internal logs in my output window. FMOD debug level is set to FMOD_DEBUG_ALL. What possibly I’m doing wrong?
Please login first to submit.