RAW unsigned 8-bit PCM import/export, sample selection and editing

Attached is a RAW, unsigned 8 bit file with 256 values from 0-255.
I’ve noticed the following in Audacity 2.4.1:

  • exporting the file after import does not result in original data. I know there are limitations to a floating point representation but I think this should not be an issue with 8 bit resolution!?

  • also: “export” and “export selected” of the same data differ in output

  • sample selection and editing is not as precise as I would have expected; while double-clicking the track’s samples results in 256 samples selected, if I move the cursor to the last sample, it shows “255 samples”. This heavily depends on the zoom factor, if the selection is extended more than half of a “sample slot width”, it correctly shows “256 samples”. Same goes for editing: it seems it’s possible to cut partial “white space” at the start and end of a track. This also causes an incorrect sample count: Deleting the first sample, selecting the track still results in “256 samples”. Export results in 256 bytes!

I’ve looked into this as the sample data obtained from a few very short waveforms (100 samples) was not as expected.
byte.txt (256 Bytes)

Audacity works internally in 32-bit float format, so when exporting as 8-bit, the data is downsampled from 32-bit float to 8-bit.
As is standard practice when reducing the bits per sample, the output has “dither” applied. This is generally a good thing for audio, but not good for “scientific” measurement / experiments.
Dither may be turned off in Audacity Preferences in the “Quality” tab. (https://manual.audacityteam.org/man/quality_preferences.html)

More information about “dither” here: https://manual.audacityteam.org/man/dither.html

Deleting the first sample, selecting the track still results in “256 samples”. Export results in 256 bytes!

I couldn’t duplicate that. When I deleted the first byte and exported I got a file with 255 bytes (01 - FF hex) when viewed with a hex editor.

(I did turn off dither but that shouldn’t affect file size.)

Thank you, that does the trick.

Thanks for trying. Steps to reproduce:

  1. Import raw file
  2. Maximum zoom, start of track (first sample 0x00 is in bottom left corner, only a quarter of the circle is visible)
  3. position cursor close to sample, so that position toolbar says “0 samples”
  4. drag-select or SHIFT+HOME to select. selection is visible only in timeline.
  5. DEL to remove selection. selection and sample point disappears, track moves left accordingly. a small left-arrow appears at bottom left corner of track (?).
  6. selecting the whole track results in “256 samples”
  7. Export with dither turned off results in file with original data (length 256).