I have a raw buffer of floating point samples read in from a .txt file. If I import raw into Audacity, it plays back just fine.
I want to push it into FMOD however and play it back.
I have tried various things but either the DLL crashes or I try other parameters and get ERR_MEMORY. data here is a pointer to my raw floating point buffer and I’m only passing in half the size in case it was a memory buffer overflow. Very confused why this won’t work.
FMOD_CREATESOUNDEXINFO creationInfo;
creationInfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
creationInfo.length = numSamples/2;
creationInfo.format = FMOD_SOUND_FORMAT_PCMFLOAT;
creationInfo.numchannels = 1;
creationInfo.defaultfrequency = 48000/2;
FMOD_RESULT result = fmodSystem->createSound(data, FMOD_OPENMEMORY_POINT, &creationInfo, &m_fmodSound);
if (result != FMOD_OK)
{
FMOD::System* fmodSystem = SoundManager::GetSingleton()->GetFMODSystem();
fmodSystem->playSound(this->m_fmodSound, NULL, false, &m_fmodChannel);
}
Memset the structure fixed my issues. And then I figured out the parameters needed.
FMOD_CREATESOUNDEXINFO creationInfo;
memset(&creationInfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
creationInfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
creationInfo.length = numSamples*sizeof(float);
creationInfo.format = FMOD_SOUND_FORMAT_PCMFLOAT;
creationInfo.numchannels = 1;
creationInfo.channelorder = FMOD_CHANNELORDER_ALLMONO;
creationInfo.defaultfrequency = 48000;
//creationInfo.suggestedsoundtype = FMOD_SOUND_TYPE_RAW;
FMOD_RESULT result = fmodSystem->createSound(data, FMOD_OPENRAW | FMOD_OPENMEMORY | FMOD_DEFAULT, &creationInfo, &m_fmodSound);
if (result == FMOD_OK)
{
this->m_isLoaded = true;
SoundManager::GetSingleton()->PlayControlledSound( this, true );
}
So I have the same char* buffer that holds float data. Its 38 seconds of data, but the audio plays back in 35 seconds. SampleRate is 48000. I provide 1,851,392 floats.
1851392/48000 = 38.57 seconds.
Anyone know what causes this? FMOD internal timer issue? Calling FMOD::Update too often?
^ Also solved. This was incorrect. My internal timer had some issues and the audio playback when properly timed worked just fine.
1 Like
Thank you for all the info and for sharing the solution.