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

up vote 7 down vote accepted

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!

  • No guarantees that this will work with less standard wav files, e.g. including a BEXT-chunk etc.... – leftaroundabout Dec 15 '14 at 21:53
  • THIS IS AWESOME – MiiinimalLogic Dec 15 '14 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 Dec 15 '14 at 23:57
  • 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 Dec 16 '14 at 1:29
  • Works perfectly on my wav files. I had different byte rates but it was easy to calculate the required numbers – mjr Dec 30 '14 at 18:09

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

  • 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 Apr 9 '16 at 14:52

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.

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 acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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