Interesting Histograms.
Reply #49 – 2011-05-31 10:13:14
0.5lsb is an issue for spectrum analysis, and in principle, might also exacerbate potential stability issues in lowpass filters. But more importantly, ITS JUST WRONG. Indeed, hence the discussion—it's a small but annoying issue if it's not handled consistently.PCM cannot represent exactly +1.0, it's as simple as that. The valid range is -1.0 <= y < +1.0 where 1.0 maps to 2^(nbits-1). Anything above that range is simply clipped to the highest possible value, so inverting -32768 results in +32767. Not quite -- inverting (multiplying by -1) -32768 results in -32768. Invert all the bits, and add 1. But that's also highly undesirable for DSP. At the ADC, if there is no bias, inverting an analogue signal that converts to -32768 would produce an analogue signal that converts to 32767; digital inversion should give the same result (at the DAC output that is).That is correct, and proper. That is, after all, the definition. Yes. Really. Can you provide a source for the definition? The wikipedia entry for two's complement arithmetic ? It doesn't mention ADC/DAC biasing. A better place to look might be IEC 60908 or somesuch. If there is no ADC bias (and 16-bit ADC values are stored unmodified or with just the top bit flipped), then a valid DSP solution is:float dsp_sample = (adc_sample + 0.5) / 32767.5; If there is ½ LSB ADC bias then a valid DSP solution is:float dsp_sample = adc_sample / 32767.0; and -32768 is an unused value. The code:float dsp_sample = adc_sample / 32768.0; doesn't seem to map to any real world ADC scenario. In practice, as has been mentioned, recordings are made with headroom and probably have any DC-offset (w.r.t. digital 0) removed with post-processing; this however has the same result as biasing the ADC, which again means that -32768 should be an unused value.