## WAV file recorded with wrong header

7

3

I have some WAV files that whose actual sound contents are at 44100Hz, but the headers incorrectly state that the sample rate is 48000Hz (I think this is due to the DAW setting its own sample rate OK but failing to set the interface's sample rate properly).

What can be done to change the headers of the WAV files to make programs interpret their contents as 44100Hz? Specifically, which tools are available for either Linux or Windows that can achieve this?

Thanks!

(In case I am not making sense, I really don't think I need to resample the WAV files at a different rate.)

8

The most direct, if somewhat "hands-dirty", way of doing this is to manipulate the header with a hex editor. There are two entries in the RIFF header that need to be modified: the sample rate itself, which is 80 BB 00 00 in 32-bit little-endian,

and the adjacent byte rate, 192k or 00 EE 02 00 for a 48k 16-bit stereo file. (96k for mono-16bit, 288k for 24bit-stereo, etc.)

These need to be changed to 44.1k / 44 AC 00 00

and 176.4k / 10 B1 02 00

respectively.

In summary: change 80 BB 00 00 00 EE 02 00 to 44 AC 00 00 10 B1 02 00!

No guarantees that this will work with less standard wav files, e.g. including a BEXT-chunk etc.... – leftaroundabout – 2014-12-15T21:53:43.293

1THIS IS AWESOME – MiiinimalLogic – 2014-12-15T22:02:36.693

This is epic. I will have to try it. I hope my wav files are standard since they were created by Reaper – mjr – 2014-12-15T23:57:30.773

Actually, the presence of a BEXT chunk (or JUNK, etc) won't matter. You just have to find the "fmt " chunk, which you can easily do either by searching, or by following the 'chain of chunks'. – Jim Mack – 2014-12-16T01:29:47.743

Works perfectly on my wav files. I had different byte rates but it was easy to calculate the required numbers – mjr – 2014-12-30T18:09:36.917

5

Very easy. Just use SoX:

sox -r 44.1k infile.wav outfile.wav


The -r 44.1k overrides the header information in infile.wav and will not perform any effects on the samples themselves.

1Note this is great for small files, but not so much for large files because it will re-write all the sound data as well. – cmc – 2016-04-09T14:52:21.200

@cmc , this information is very helpful to know. Now, I understand some performance issues I've been having. You should post a separate answer discussing the limitation of sox and discussing options without re-write. I thought of using ffmpeg, but I think that ffmpeg uses sox under the hood. I think the hex-editor answer is great and helped me learn more about fundamental issues, but I'd like something that's more batch-friendly. If this needs to be a separate question, I'll research it and, (if I don't find it), I'll ask it.

– bballdave025 – 2020-09-04T18:36:55.087

4

After some more searching, I have found that ffmpeg is able to do this by converting the WAV to raw PCM format, and then converting back to WAV with the correct sample rate in the header.

For example:

ffmpeg -i input.wav -f s16le -acodec pcm_s16le output.pcm


to convert input.wav to raw PCM data. Then

ffmpeg -f s16le -ar 44.1k -ac 1 -i output.pcm file_FIXED.wav


to convert back to a WAV with sample rate 44.1K.

2

One way i do this, using Adobe Audition, is to "Open as" raw PCM data (one has to type an * in the name bar of the opening window to show all files), and then define the sample rate and mono/stereo information in the pop up box that comes up.

This has proved useful for opening files that were stopped while recording in programs like Ableton Live.