0
0

Hi,

I am testing on how to integrate FMod in our software. I want to have 2 types of output: realtime and to an audio encoder.

Realtime: everything is fine. When I output to a DSP (which will encode the audio in a file later), the sound library seems to be immune for:

[code:ajht61av]FMOD::System::set3DListenerAttributes[/code:ajht61av]

and

[code:ajht61av]FMOD::Channel::set3DAttributes[/code:ajht61av]

There is no 3D sound! The soundchannels are created with the FMOD_3D flag. Is this possible at all and, if yes, what could be the cause of my problem?

I create a soundsystem and DSP which saves into a FIFO buffer which I use in the encoder:

[code:ajht61av]
//Initialization
int channels = 2;
float DISTANCEFACTOR = 1.0f;

LogIfError(func, pSystem_->setOutput(FMOD_OUTPUTTYPE_NOSOUND_NRT));
LogIfError(func, pSystem_->setSoftwareFormat(48000, FMOD_SOUND_FORMAT_PCM16, channels, channels, FMOD_DSP_RESAMPLER_MAX));
LogIfError(func, pSystem_->setDSPBufferSize(1600,4)); //30FPS!
LogIfError(func, pSystem_->init(200, FMOD_INIT_NORMAL, 0));
LogIfError(func, pSystem_->set3DSettings(1.0f, DISTANCEFACTOR, 1.0f));
[/code:ajht61av]

The DSP Initialization is done the same (except bypass settings) as in the dsp_custom example:

[code:ajht61av]
/*
Create the DSP effects.
*/
{
FMOD_DSP_DESCRIPTION dspdesc;

    memset(&dspdesc, 0, sizeof(FMOD_DSP_DESCRIPTION)); 

    strcpy(dspdesc.name, "My first DSP unit"); 
    dspdesc.channels     = 0;                   // 0 = whatever comes in, else specify. 
    dspdesc.read         = myDSPCallback; 
    dspdesc.userdata     = (void *)0x12345678; 

    result = system->createDSP(&dspdesc, &mydsp); 
    ERRCHECK(result); 
} 

 mydsp->setBypass(false);

/*
    Main loop.
*/
result = system->addDSP(mydsp, 0); 

[/code:ajht61av]

The DSP code, which works fine:

[code:ajht61av]
const size_t shortBufferSize = length * outchannels * sizeof(short);
short * fBuffer = new short[length * outchannels];

for (int count = 0; count < length; count++) 
{ 
    for (int count2 = 0; count2 < outchannels; count2++)
    {
        outbuffer[(count * outchannels) + count2] = inbuffer[(count * inchannels) + count2];
        short v = (inbuffer[(count * inchannels) + count2] * 32767.0f) / 2; //TODO: see why it cracks when I don't lower the volume
        fBuffer[(count * outchannels) + count2] = v;
    }
}

// Further output to my FIFO buffer.
[/code:ajht61av]

Hopefully anyone can help!

Best regards,

Arthur

  • You must to post comments
0
0

All the 3D code is driven by System::update are you calling that at appropriate intervals?

  • You must to post comments
0
0

Hi,

I load two mp3 files and set the position relatively at X=-6 and X=6. In realtime one sample is panned left, the other right.
The listener is set to position 0,0,0, velocity 0,0,0

FMOD_VECTOR forward = { 0.0f, 0.0f, 1.0f };
FMOD_VECTOR up = { 0.0f, 1.0f, 0.0f };

This is the DSP Buffer size: pSystem_->setDSPBufferSize(1600,4)
On each update call I get the data, which is encoded succesfully into an audio file.

However, the encoded audio is still normal stereo (the exact original samples mixed).

So I assume update is OK, but something in the settings is not.

Arthur

  • You must to post comments
0
0

By the way, I also built an output plugin, just to be sure.

Fmod is initialized with FMOD_OUTPUTTYPE_NOSOUND_NRT and FMOD_INIT_NORMAL | FMOD_INIT_STREAM_FROM_UPDATE

To output to my encoder I call System::update until everything is encoded. The sound and listener positions are ignored, though and I hear a mix of my two samples in stereo.

  • You must to post comments
0
0

This line is probably the culprit:
[quote:14ev63d4]LogIfError(func, pSystem_->setSoftwareFormat(48000, FMOD_SOUND_FORMAT_PCM16, channels, channels, FMOD_DSP_RESAMPLER_MAX));[/quote:14ev63d4]

Firstly with FMOD_DSP_RESAMPLER_MAX, the ‘max’ means ‘size of the enum’ it isn’t a valid resampler type. This isn’t a problem because FMOD will fall back to linear, but it’s worth mentioning.

The actual issue will be setting numoutputchannels to ‘channels’ which in this case is 2. By doing this you are putting FMOD into RAW speaker mode, I’m guessing this isn’t your intention? Likewise setting numinputchannels to 2 will restrict FMOD to only loading mono or stereo files (is that your intent?). My recommendation would be to set both of those values to 0, which will use the existing values.

  • You must to post comments
0
0

Thanks for your help, it works fine now.

  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.