Page 1 of 1

import .wav file as raw

Posted: Wed May 30, 2018 8:46 pm
by Dan_Cox
I use ubuntu 16.04 and Audacity 2.1.2 I try to import a .wav file from a professional audio recorder because it is damaged. However, I cannot import even an undamaged file. There is only noise. Mediainfo says it has 2.304kbps, 48kHz, 24bits, 2channels, PCM(little/signed). So I set 24bit signed, little endian, Stereo and so on. I only hear noise. What is wrong?

Re: import .wav file as raw

Posted: Wed May 30, 2018 9:09 pm
by kozikowski
What was the recording and how was it damaged?

Koz

Re: import .wav file as raw

Posted: Wed May 30, 2018 10:20 pm
by steve
Dan_Cox wrote:What is wrong?
Import RAW does not work for 24-bit files (it's a bug).
I'll log it on the bug tracker.

Re: import .wav file as raw

Posted: Wed May 30, 2018 11:34 pm
by steve
steve wrote:Import RAW does not work for 24-bit files (it's a bug).
Cancel that. Looking closer, it's not a bug.

The problem is that the file you are working with is not a true RAW file.

A standard Microsoft PCM WAV files has 44 bytes "header" before the start of the data.
Each sample of a 24-bit PCM file is 3 bytes.
If you don't discard the header, then it is read as 14 samples + 2 bytes, and those 2 bytes push the rest of the data out of order. Where Audacity is expecting to get a 3 byte number for each sample, it is getting 2 bytes that belong to one sample, and one byte that belongs to the next sample.

To read 24-bit PCM correctly, it is essential that a correct offset is given (or at least, an offset that puts the first byte of each sample as the first in each group of 3 bytes).

Try importing with an offset of 44 bytes.

Re: import .wav file as raw

Posted: Wed May 30, 2018 11:41 pm
by steve
steve wrote:A standard Microsoft PCM WAV files has 44 bytes "header" before the start of the data.
Note that not all WAV files have standard Microsoft PCM WAV headers. It's not uncommon for valid WAV files to have headers larger than 44 bytes, so you may need to experiment, (or use a Hex Editor to examine how big the header actually is).

Re: import .wav file as raw

Posted: Wed May 30, 2018 11:44 pm
by steve
steve wrote:(or use a Hex Editor to examine how big the header actually is).
Some information about that: https://stackoverflow.com/questions/199 ... yte-header

Re: import .wav file as raw

Posted: Wed May 30, 2018 11:47 pm
by steve
and the Microsoft RIFF format specification here: http://soundfile.sapp.org/doc/WaveFormat/

Re: import .wav file as raw

Posted: Thu May 31, 2018 7:25 pm
by Dan_Cox
Thank you all. It works with an offset of 4 or 10 or 16 and so on. The other row with 1 or 7 or 13 and so on channels are changed.