Range of integer audio

When reading/writing integer audio data,is the full range allowed? This implies that an offset correction of +/- 0.5 have to be made when converting to/from floats which varies in the range [-1, 1]. See http://en.wikipedia.org/wiki/Talk:Linear_pulse-code_modulation.

The first section in that talk page is bit pedantic, and is pointing out that the middle of the range of signed 16-bit integers is -1/2 bit out of the range of -32768 to +32767. In PCM 16-bit signed integer, 0x0000 is zero.

– Bill

The full data range is allowed for signed integer audio.
The most positive value for a 16 bit sample is 32767 (7FFF Hex)
The most negative value for signed 16-bit is -32769 (−8000 Hex)
The smallest value is 0 (silence).
This means that samples can be slightly more negative than positive, so 0 is not strictly the centre point (though close enough for all practical purposes)

This can be illustrated practically in Audacity (this example is using Audacity 1.3.12, but should work with other versions)
To save confusion, switch off “dither” in Preferences.
Set the default Quality to a signed integer format (16 or 24 bit).

  1. Generate some silence and make 2 splits (Edit menu > Split) so that you have 3 sections.
  2. Duplicate the track (Ctrl+D)
  3. Select the first section of the first track.
  4. “Effect menu > Nyquist Prompt” enter the code (sum s 1)
  5. Select the third section of the first track and apply the code (sum s -1)
  6. Select the first section of the second track and apply the code (sum s -1)
  7. Select the third section of the second track and apply the code (sum s 1)

You should now have something similar to this:
trackpanel000.png
8) (optional) select all (Ctrl+L) and apply “Amplify” with a positive value (allow clipping). This will ensure that the first and third sections are at the absolute maximum values possible (optional, because they should be already).
9) Select all (Ctrl+A) and Mix and Render (Ctrl+SHIFT+M to render to a new track).
10) Amplify the rendered track repeatedly.
It will be observed that the first and last sections are 1 bit negative.

Optionally you can export either of the tracks as signed PCM and examine the data in a Hex editor to confirm the values of 7FFF, 8000 and 0000, though this may be a bit confusing depending on the exact format chosen.

Thanks :smiley: