This content is not available in your preferred language.

The content is shown in another available language. Your browser may include features that can help translate the text.

Bad Behavior Creating .Wav File from Waveform Using Sound File Write VI

Updated May 6, 2023

Reported In


  • LabVIEW

Issue Details

I have waveform data and I'm trying to use the Sound File Write VI to write it to a sound file. I've verified that the waveform itself is correct, but when I listen to the .wav file or read it back in to LabVIEW, it does not sound right and the waveform looks flat.


Depending on the datatype used for the Y value of waveform, there are different ranges that are acceptable. Anything outside the range will be coerced without scaling, i.e. they will be coerced to +1 or -1, whichever is closer. This is documented in the Help file for sound data.

That said, to avoid your waveform being coerced you will need to scale your data to correct range according to the data type selected. In general the data will be floating-point, so you should scale the waveform to the range of -1.0 to 1.0.

Below it is an example of how to scale an array of doubles to the range of -1.0 to 1.0.

Additional Information

As mentioned in the Help file:

The Y array of the waveform contains Pulse Code Modulated (PCM) data. In PCM data, each element in the Y array is proportional to the amplitude of the signal.

If the Y array data type is a 16-bit signed or 32-bit signed integer, the values range from the minimum to the maximum value for the data type and are centered at zero. A buffer of elements each with the value of zero represents silence.

If the Y array data type is a 8-bit unsigned integer, the values range from 0–255 and are centered at 127. A buffer of elements each with the value of 127 represents silence rather than a buffer of elements each with the value of zero. This might cause an initial clicking sound with 8-bit unsigned integers.

For floating-point data, the values range from -1.0 to 1.0, inclusively. The data is coerced into that range. There is no scaling.