10

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

4 Answers 4

11

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,

48k sample rate in RIFF head

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

192k byte rate in RIFF head

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

44.1k sample rate in RIFF head

and 176.4k / 10 B1 02 00

176.4k byte rate in RIFF head

respectively.

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

5
  • 1
    No guarantees that this will work with less standard wav files, e.g. including a BEXT-chunk etc.... Commented Dec 15, 2014 at 21:53
  • 1
    THIS IS AWESOME Commented Dec 15, 2014 at 22:02
  • This is epic. I will have to try it. I hope my wav files are standard since they were created by Reaper
    – mjr
    Commented Dec 15, 2014 at 23:57
  • 1
    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
    Commented Dec 16, 2014 at 1:29
  • Works perfectly on my wav files. I had different byte rates but it was easy to calculate the required numbers
    – mjr
    Commented Dec 30, 2014 at 18:09
7

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.

More info: sox.sf.net

2
  • 1
    Note 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
    Commented Apr 9, 2016 at 14:52
  • @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. Commented Sep 4, 2020 at 18:36
5

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.

3

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.