0
0

I am writing a wav file editor, which incorporates 3D sound-positioning, using the latest release of FmodEx. I can play wav files with correct positioning (using system->set3DListenerAttributes() and updating the listener) fine, but once the sounds have been adjusted as desired, I haven’t been able to write them to disk properly.

Here is my code to initialize FMOD to write to disk:

ERRCHECK (FMOD::System_Create(&my_system));
ERRCHECK (my_system->setOutput (FMOD_OUTPUTTYPE_WAVWRITER_NRT));

my_system->setSoftwareFormat(44100, FMOD_SOUND_FORMAT_PCM16, 0, 2, FMOD_DSP_RESAMPLER_LINEAR);

ERRCHECK (my_system->init(32, FMOD_INIT_STREAM_FROM_UPDATE, _T(szHighlightFile)));

I create the sound to be played as follows:

result = my_system->createSound(szGlobalOpenFileName, FMOD_3D, 0, &sound1);
ERRCHECK(result);
result = sound1->set3DMinMaxDistance(0.5f * DISTANCEFACTOR, 5000.0f * DISTANCEFACTOR);
ERRCHECK(result);

And play it as follows:

result = my_system->playSound(FMOD_CHANNEL_FREE, sound1, true, &channel1);
ERRCHECK(result);
result = channel1->set3DAttributes(&pos, &vel);
ERRCHECK(result);

This results in an output wav file of the correct length, and (presumably) of the correct format, but the file cannot be played by a standard wav-file player (e.g., MediaPlayer, which chokes with an unhelpful error message).

I have tried setting up a DSP to trap the processed inbuffers and write them to disk myself with the correct format, but have not succeeded in fathoming how the floating point values in the inbuffers relate to the 16-bit values in each channel of a 16-bit stereo wav file, and it is not clear whether the DSP inbuffers actually contain the processed 3D sounds.

Doubtless, I am mis-construing how to use

setOutput (FMOD_OUTPUTTYPE_WAVWRITER_NRT)

if in fact it can be used at all with 3D sounds.

Your help in how to write processed 3D sounds to disk would be most gratefully appreciated.

Thanks very much.

  • You must to post comments
0
0

Just a random question, do your generated .WAV files have the proper RIFF headers on them?

  • You must to post comments
0
0

You’re creating your sound as a hardware sound (which is the default unless you specify FMOD_SOFTWARE). FMOD probably can’t write out hardware sounds, because they don’t go through its mixing engine. Try adding FMOD_SOFTWARE to your createSound() call.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.