PDA

View Full Version : mono conversions are overmodulated



kurt
05-20-2002, 03:22 PM
I convert files for use on an AM radio station. When I convert an MP3 or WAV stereo file to mono (Format: PCM; 44.100 kHz, 16 bit, Mono 86 kb/sec), it's way too hot. I have to reduce the gain by about 6 to 8 dB, and it's still distorted and clipped. Is there a way to reduce these levels so the end result isn't distorted?

Kurt

daren
05-21-2002, 02:17 AM
Hi,

It's the way mono is created in these converters (by adding
left and right together).

My Real Audio, MP2, Dalet and AIFF codecs attenuate the
left and right signals before adding.

You could try;

a) attenuating the audio before conversion (6dB is enough)
b) convert first to AIFF mono and then to WAV (AIFF is also a linear format).

Hey Spoon, how about putting in an attenuator in the WAV
and MP3 codecs for mono conversions? I've got a routine for
you if you want...

Cheers,
Daren.

Unregistered
05-21-2002, 02:21 AM
This mono convertor is a good idea, by adding L and R channels some of the music quality that has been lost in the conversion from sound (analog) to memory (digital) will be restored.

Spoon
06-02-2002, 05:14 AM
Sure drop me the routine, I will drop it in the latest beta.

daren
06-02-2002, 07:25 AM
Hi Spoon,

Here is the attenuation routine I use:

//================================================== =========================
//routine to attenuate the pData buffer by 50% for stereo to mono conversions
//================================================== =========================
void CLWAVEOUT::Attenuate(char *pData, DWORD DataLength, int bps)
{
int i;

switch(bps)
{
case 8:
{
unsigned char *pWorkerData = (unsigned char *)pData;
int s;

for (i=0;i<DataLength;i++)
{
s = (int) *pWorkerData;
*pWorkerData = (unsigned char) (s / 2);
pWorkerData++;
}
break;
}

case 16:
{
short int *pWorkerData = (short int *)pData;
short int s;
for (i=0;i<DataLength/2;i++)
{
s = *pWorkerData;
*pWorkerData = (short int)(s / 2);
pWorkerData++;
}
}
}
}


I call this using the following line of code:

//if we're making mono from stereo attenuate audio stream by 50%
if ((MP2Stereo == 1) && (InputChannels==2))
Attenuate(pSampleDataBuffer,DataSize,InputBitsPerS ample);

The MP2Stereo is the same as MP3Stereo in your MP3 example codec.
InputChannels and InputBitsPerSample are globals which get their
values in the existing initialisation function:

CLWAVEOUT::CLWAVEOUT (char *Filename, ENCompressionOpenResult &ReturnError, WAVEFORMATEX *WFXInputFormat)
{

InputBitsPerSample = WFXInputFormat->wBitsPerSample;
InputChannels = WFXInputFormat->nChannels;
}

Not very exciting code, but it does the trick :-)

Daren.

daren
06-02-2002, 07:30 AM
One more thing;

You need to call this *before* sending your data to the Windows
PCM ACM for stereo to mono conversion...

Cheers,
Daren.

Spoon
06-02-2002, 11:08 AM
Thanks