Page 1 of 1

Support for 24bit samples in 32bit word RAW data

Permanent link to this postPosted: Wed Sep 27, 2017 12:36 pm
Posted by Menion
Hi all
Some automotive audio format, especially when transported over TDM links, use 24bit audio samples (signed integer) but in 32bit word
So, a samples 0xAABBCC, will be packed in 0x00AABBCC (it is quite uncommon that is packed as 0xAABBCC00 but it is worth to consider it)
Unfortunately Audacity cannot manage this format, the 24bit expect that the samples are packed 24bit in 24bit, so the result that this format cannot be opened
Is it possible to add it?
Bye

Re: Support for 24bit samples in 32bit word RAW data

Permanent link to this postPosted: Wed Sep 27, 2017 3:50 pm
Posted by steve
Please post a short example file.

Re: Support for 24bit samples in 32bit word RAW data

Permanent link to this postPosted: Thu Sep 28, 2017 10:07 am
Posted by Menion
Hi
Please find attached the sample (13 channels). You can discard the WAV header and import as RAW, offset 44 bytes

These are the first two 13 channel frame:

00 a9 97 00 - 00 a9 97 00 - 00 ff ff 00 - 00 00 00 00 - 00 00 00 00 - 00 00 00 00 - 00 00 00 00 - 00 00 00 00 - 00 00 00 00 - 00 00 00 00 - 00 00 00 00 - 00 e5 7b 00 - 00 23 5b 00

00 3b a2 00 - 00 3b a2 00 - 00 ff ff 00 - 00 00 00 00 - 00 00 00 00 - 00 00 00 00 - 00 00 00 00 - 00 00 00 00 - 00 00 00 00 - 00 00 00 00 - 00 00 00 00 - 00 00 00 00 - 00 00 00 00

There is a [email protected] sinewave in channel 0 and 1, you can see that the data are 24 bit valid but LSB aligned. I cannot import as 24bit because the extra byte will disalign everything, neither 32bit, because of the missing MSB byte
Bye

Re: Support for 24bit samples in 32bit word RAW data

Permanent link to this postPosted: Thu Sep 28, 2017 12:26 pm
Posted by steve
This code, when applied with the Nyquist Prompt effect, will read the audio data from a selected track and convert it to normal 32-bit float:

Code: Select all
(setf ln  ;; length of sample buffer
  (if (<= len 1000000)
      (truncate len)
      10000))

(setf range (power 2.0 -8.0))     ; range of positive samples
(setf offset (power 2.0 -7.0))    ; offset to roll negative signed bits round to negative values
(setf makupgain (power 2.0 8.0))  ; make-up data range to full-scale
(setf dur (/ ln *sound-srate*))   ; length of buffer in seconds

(defun process (buffer chunk-start)
"Convert buffer samples to 32-bit float audio."
  (dotimes (i ln)
    (if (> (aref buffer i) range)
        (setf (aref buffer i) (- (aref buffer i) offset))))
  (mult makupgain (snd-from-array chunk-start *sound-srate* buffer)))

(let ((out (s-rest 0)))
  (do ((buff (snd-fetch-array *track* ln ln) (snd-fetch-array *track* ln ln))
       (t0 0 (+ t0 dur)))
      ((not buff) out)
    (setf out (sim out (process buff t0)))))


Re: Support for 24bit samples in 32bit word RAW data

Permanent link to this postPosted: Thu Sep 28, 2017 1:41 pm
Posted by steve
Forgot to mention in previous post - you can just import the file as a "normal" audio import. Audacity reads the file as 13 channel 32-bit signed integer, 48 kHz, and copies the data into 13 tracks, mono, 32-bit float, 48000 Hz. This gives a different track order than Import RAW, but is otherwise the same, and it saves having to select settings manually.

I also notice that there is something else going on it that 13 channel track - most of the tracks are mostly silence, but with occasional samples that line up with samples in other tracks and with glitches in the sine wave tracks. Looks like there's more to this encoding than just padding 24 to 32 bits.

Re: Support for 24bit samples in 32bit word RAW data

Permanent link to this postPosted: Thu Sep 28, 2017 3:10 pm
Posted by Menion
hi
Discard channel 12-13, you see that every two sample there are these spurious just repeated. And there are some glitches we are trying to fix
This is a real automotive audio TDM bus we are debugging :)
I will try the code you suggested