How to save 3D sound effects to wav files?

#1

I designed a 3D sound effect, but the audio I saved is different from the one I previewed. How should I save the 3D sound effect?Here is the code I initialized to save:

void FMODCore::saveInit3D(char *inputPath, char *outPath) {
FMOD_RESULT result;
result = system->setOutput(FMOD_OUTPUTTYPE_WAVWRITER_NRT);
ERRCHECK(result);
result = system->setSoftwareFormat(24000, FMOD_SPEAKERMODE_DEFAULT, 10);
ERRCHECK(result);
result = system->init(32, FMOD_INIT_NORMAL, (void *) outPath);
ERRCHECK(result);
result = system->set3DSettings(1.0, DISTANCEFACTOR, 1.0f);
ERRCHECK(result);
result = system->createSound(inputPath, FMOD_3D, 0, &sound);
ERRCHECK(result);
result = sound->set3DMinMaxDistance(0.5f * DISTANCEFACTOR, 5000.0f * DISTANCEFACTOR);
ERRCHECK(result);
}

#2

How is the sound different?

#3

The listener’s speed, position, and direction of movement are different from what I set.
I solved this problem by using real-time save, but it was time-consuming.
Can 3D effects be saved using NRT?

#4

Nothing in the system knows what the output is or behaves differently because of it.

How are you measuring the difference?

This post may help with understanding FMOD_OUTPUTTYPE_WAVEWRITER_NRT a bit more:

The way FMOD_OUTPUTTYPE_WAVEWRITER_NRT works is it generates audio every time System::update is called. The amount of data generated per ‘update’ is governed by the bufferlength parameter of System::setDSPBufferSize.

So the faster you call System::update the faster the data is generated. Now the important part for your job is to convert ‘x’ number of calls to System::update into something you can match to your timeline.

By default FMOD operates at a sample rate of 48000 samples per second (configurable via System::setSoftwareFormat). So if you set ‘bufferlength’ to 1024, each time you call System::update 1024 samples will be generated (written to the wav file). So… 1024 / 48000 = 0.021333 seconds ~ 21.3 milliseconds of data is generated per call.