LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How read/write matlab style WAV sound file?

The supplied LabVIEW WAV read/write VIs require fixed sampling rates (like 8000, 11025, 22050, 44100), and use integer data (so the waveforms take on large +/- integer values).

I need to read/write WAV files that are like those used in Matlab with its wavread and wavwrite functions. Those can use ANY sample rate, and the waveforms have decimal values between -1 and +1.

Could someone suggest either how to directly write these standard WAV files with an existing VI, or how to write my own VI to do this?

Thanks in advance.
0 Kudos
Message 1 of 3
(3,706 Views)
LabVIEW uses integer PCM data for the sound data instead of a floating-point type between -1 and 1, so you'll have to convert numbers in the range [-1, +1] to [0, 255] for 8-bit or [-32768, 32767] for 16-bit sample size. (For example, the second case you can multiply by 32767 and then convert to I16.)

You can modify the Snd Write Wave File to include the new sampling rate that you want. Just changing the area near "rate" should automatically work, but I haven't tested it.

By the way, many sound cards do not support more than the frequencies mentioned, so even if you can create a WAV file, it doesn't mean your sound card can play it at that exact frequency.

Good Luck.
Message 2 of 3
(3,706 Views)
That's a great help! Thanks. I have made the changes to the supplied NI VIs so that any rate can be used. The new read/write VIs are attached and seem to work ok.

Best,
F
Download All
0 Kudos
Message 3 of 3
(3,706 Views)