Support for 24bit samples in 32bit word RAW data

Feedback and Reviews for Audacity 2.x

This board is ONLY for general feedback and discussion about Audacity 2.X.

If you require help, or think you have found a "bug", please post on the forum board relevant to your operating system.
Windows
Mac OS X
GNU/Linux and Unix-like

Support for 24bit samples in 32bit word RAW data

Permanent link to this post Posted by Menion » Wed Sep 27, 2017 12:36 pm

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
Menion
 
Posts: 3
Joined: Wed Sep 27, 2017 12:32 pm
Operating System: Windows 10

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

Permanent link to this post Posted by steve » Wed Sep 27, 2017 3:50 pm

Please post a short example file.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 45306
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

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

Permanent link to this post Posted by Menion » Thu Sep 28, 2017 10:07 am

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
Attachments
test.zip
13 channel, 32 bit data with 24bit audio sample LSB aligned
(449.55 KiB) Downloaded 7 times
Menion
 
Posts: 3
Joined: Wed Sep 27, 2017 12:32 pm
Operating System: Windows 10

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

Permanent link to this post Posted by steve » Thu Sep 28, 2017 12:26 pm

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)))))

9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 45306
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

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

Permanent link to this post Posted by steve » Thu Sep 28, 2017 1:41 pm

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.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 45306
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

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

Permanent link to this post Posted by Menion » Thu Sep 28, 2017 3:10 pm

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
Menion
 
Posts: 3
Joined: Wed Sep 27, 2017 12:32 pm
Operating System: Windows 10


Return to Audacity 2.x Feedback and Reviews



Who is online

Users browsing this forum: No registered users and 1 guest