Re: [linux-audio-dev] Reference amplitudes and LADSPA (again)

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] Reference amplitudes and LADSPA (again)
From: Steve Harris (S.W.Harris_AT_ecs.soton.ac.uk)
Date: Tue Feb 05 2002 - 13:27:46 EET


On Mon, Feb 04, 2002 at 07:24:47 -0000, Paul Kellett wrote:
> > input = (float)read_from_soundcard() / 32767.0f;
> > input = run_plugin(input);
> > ...
> > write_to_soundcard((short)(input * 32767.0f));
>
>
> ... but please make that 32768.0f !
>
> I forget the reasons, but there was a long argument about it either
> on music-dsp or vst-plugins. It's a very small difference, but an
> important one if for example you are performing noise shaping on a
> float signal just before it is converted to 16 bits, or if you just
> want an accurate "over" meter.

You're probably right, but I chose 32767.0f for the same reasons:

2's comp 16 bit integers go from 32767 to -32768, so if you scale by 32767
then subtract half a bit dither you should be inside the short range,
at 0dBFS but not clipping.

No-one should use a c cast in order to produce integer output either, it
will cause crossover distortion. You should be using a rounding
conversion. The code was just to make it obvious what was happening,
rather than real source.

- Steve


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Tue Feb 05 2002 - 13:28:22 EET