0
0

Hi! First of all, thank you for providing us, hoobie programmers, with this high-quality software that fmod is!

Now for my problem.

I’m using C# and Fmod to create an application that needs to send its output through the speakers AND to save it to an mp3 file.
I’ve looked at the examples provided, both output_mp3 and dsp_gain, and managed to make a dsp plugin that outputs the sound and uses BladeEnc to encode it to the mp3 file.
However, the mp3 file is only noise.

I think it’s because of inbuffer being floats (BladeEnc asks for Shorts). Is this correct? If it is, how can I convert the buffer?

Thanks in advance,
H4evr

  • You must to post comments
0
0

just copy to another buffer (the dspblocksize from System::getDSPBufferSize multiplied by the number of output channels and multiplied by 2 for 16bit), and convert the dsp callback buffer from float to short with

shortbuff[i] = (signed short)(floatbuff[i] * 32767.0f);

the shortbuff would be what you pass to bladeenc.

  • You must to post comments
0
0

Thanks, it works!

I can now save the output as mp3, but now I have a new problem. The sound recorded plays at half the frequency of the original sound.

I do have 2 pitch-shifters before the mp3-dsp, is this influencing or may the problem be other?

This dsp, I forgot to tell, is coded (in C++) as an external dsp plugin.

Anyways, here is my buffer copying code:

[code:u7l85a5s]
for(; n < state->dwSamples; n++)
{
state->pWAVBuffer[n] = (SHORT)(inbuffer[n] * 32767.0f);
}
[/code:u7l85a5s]

  • You must to post comments
0
0

you’re probably encoding the data as mono and then passing in stereo data, or something like that.

  • You must to post comments
0
0

BladeEnc is configured the following way:

[code:11y64byz]
beConfig.format.LHV1.dwStructVersion = 1;
beConfig.format.LHV1.dwStructSize = sizeof(beConfig);
beConfig.format.LHV1.dwSampleRate = 44100; // INPUT FREQUENCY
beConfig.format.LHV1.dwReSampleRate = 0; // DON"T RESAMPLE
beConfig.format.LHV1.nMode = BE_MP3_MODE_JSTEREO; // OUTPUT IN STREO
beConfig.format.LHV1.dwBitrate = 128; // MINIMUM BIT RATE
beConfig.format.LHV1.nPreset = LQP_R3MIX; // QUALITY PRESET SETTING
beConfig.format.LHV1.dwMpegVersion = MPEG1; // MPEG VERSION (I or II)
beConfig.format.LHV1.dwPsyModel = 0; // USE DEFAULT PSYCHOACOUSTIC MODEL
beConfig.format.LHV1.dwEmphasis = 0; // NO EMPHASIS TURNED ON
beConfig.format.LHV1.bOriginal = TRUE; // SET ORIGINAL FLAG
beConfig.format.LHV1.bWriteVBRHeader = TRUE; // Write INFO tag
[/code:11y64byz]

Note that is uses Joint Stereo.

The output also has 2 channels (stereo) so I don’t think that is the problem.

I’ve tried disabling the pitch-shifter units but the problem still remains.

  • You must to post comments
0
0

It will be a mono/stereo mixup, there is nothing else it will be. Maybe it is even a 5.1 to stereo mixup, have you accidently set the speakermode to 5.1?. You’ll have to look into it more for things like this.

  • You must to post comments
0
0

[quote="brett":3ovxexfg]just copy to another buffer (the dspblocksize from System::getDSPBufferSize multiplied by the number of output channels and multiplied by 2 for 16bit), and convert the dsp callback buffer from float to short with

shortbuff[i] = (signed short)(floatbuff[i] * 32767.0f);

the shortbuff would be what you pass to bladeenc.[/quote:3ovxexfg]

Brett can you write some line of code to do it? The part where you mention System::getDSPBufferSize
I need to do the same, my codec also want short

  • You must to post comments
Showing 6 results
Your Answer

Please first to submit.