Re: [ecasound] Trying to normalize two channels independently

New Message Reply Date view Thread view Subject view Author view Other groups

Subject: Re: [ecasound] Trying to normalize two channels independently
From: Kai Vehmanen (
Date: Tue Nov 07 2000 - 22:34:59 EET

On Sun, 5 Nov 2000, Andy Loening wrote:

> -a:1 -f:s16_le,1,48000 -i channel_1.wav \
> -a:2 -f:s16_le,1,48000 -i channel_2.wav -erc:1,2 -eac:0,1 \
> The resultant output file only uses ~50% of the amplitude in the left and
> right channels. When I use either of the following commands:
> I assume this behavior is a feature, so that when you're combining
> multi-track recordings into a single file you don't get clipping. Is
> there anyway to disable this?

Yup, this is a feature. Audio streams are mixed together using the
following algorithm:

for x = 0; x < out_buf.channel_count; x++
        out_buf[x] = 0 // mute channel x
        for y = 0; y < chain_bufs.count; y++
                out_buf[x] = out[x] + chain_bufs[y][x] / out_buf.channel_count

So if you are mixing multiple chains, each containing normalized audio,
but on different channels, the overall channel volume seems to go down to
1/number_of_output_channels. So this is precisely what you describe above.

Currently it is not possible to get around this. It would be quite easy to
add a new mix-algorithm (ie. a new param to -m option), but I'm not sure
whether people would actually find (and use) this feature. They'd
basically had to understand what is happening "under the hood".

> I guess I could also just amplify the two channels by 200%, but I'd want
> to convert the wav files to 24bit first, so that I don't drop any bits
> when going from 100%->50%->100%

Amplifying by 200% actually isn't that bad. The magic thing hear is that
internally ecasound uses floating-point representation for samples. In
practise this means that you will always have the 23bits of precision
offered by 32bit ieee754 float (23bit mantissa, 8bit exponent and 1bit for
the sign). In optimal case, only the exponent needs to be adjusted.

Another possibility is to compile ecasound to use double (64bit float)
as the internal sample format. You can define this in
'libecasound/sample-specs.h'. This brakes LADSPA support (LADSPA is
based around 32bit floats; VST plugins have the same restriction),
but should otherwise work fine.

 . ... [ audio software for linux ] /\ .
 . [ my armchair-tunes mp3/ra/wav ]

To unsubscribe send message 'unsubscribe' in the body of the
message to <>.

New Message Reply Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Tue Nov 07 2000 - 23:01:50 EET