Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write wav file with 32-bit float data?

Tags:

audio

wav

I would like to be able to write PCM wav files with 32-bit floating point samples. This seems to be a valid format since libsndfile claims to support it.

However, if I specify in my header a sample size of 32-bits, any program I open it in assumes that it's 32-bit integer data. What flags, etc need to be set in the wav file header to specify floating point data?

Can anyone point me to some documentation that explains how to do this?

like image 329
Judah Menter Avatar asked Jan 14 '10 06:01

Judah Menter


People also ask

Should I use 24-bit or 32-bit float?

24-bit audio recordings can capture a dynamic range of up to 144.5 dB. Meanwhile, 32-bit float audio can capture the absolutely ludicrous range of up to 1,528 dB. That's not only massively beyond the scope of 24-bit audio, but it's beyond the scale of what even counts as a sound on Earth.

What is a 32-bit float file?

Compared to fixed-point files (16- or 24-bit), 32-bit float files store numbers in a floating-point format. This is fundamentally different than fixed point, because numbers in these WAV files are stored with “scientific notation”, using decimal points and exponents (for example “1.4563 x 106“ instead of “1456300”).


1 Answers

You need to set the wFormat tag in the 'fmt' chunk to WAVE_FORMAT_IEEE_FLOAT (3).

A good source for the WAVE format specification is this page.

like image 162
Han Avatar answered Sep 21 '22 18:09

Han