"Snd Read Wave File in a Format.vi" opens an audio (.wav) file and converts any valid format of data to a specified audio format. The user can select whether the format is mono or stereo and whether it is 8 or 16 bits per sample.
This example program demonstrates how to open a audio file (.wav) in LabVIEW and get the data in a specified format regardless of the format found in the file.
The VI "Snd Read Wave File in a Format.vi" is much like the "Snd Read Wave File" VI included in the sound palette in LabVIEW, but with the difference that in this VI the user can select the sound quality (mono/stereo) and the number of bits per sample (16 bits/8 bits). This example subVI also has 4 audio outputs but this time you can control which one will be active regardless of the type of data in the .wav file you select.
The VI has an input for a path to a .wav file. If this is unwired or if there is an empty path input, the VI opens a dialog window to select the file. There are also inputs to select the bits per sample and stereo or mono. The sampling rate is always kept for all audio files opened. "Snd Read Wave File in a Format.vi" also includes error inputs. If there is an incoming error, the VI does nothing but pass the error to the error output and return empty arrays of data.
The outputs of this VI are four terminals for audio, however, only the selected one is active (the others return an empty array). There are two outputs with a sound format cluster, one for the original format found in the file, and another one for the selected format (the one that the actual output is in).
This VI is intended to be used where the processing of audio files is needed. It gives the user the ability to program for just one known format of audio data, regardless of the format found in the .wav file being opened.
FILE INFORMATION:
There are two VI's included in this zip file:
1. "Snd Read Wave File in a Format.vi" - This VI can be used as a subVI that does the format conversion .
2. "Test for Snd Read Wave File in a Format.vi" - This VI is a simple example that demonstrates the use of "Snd Read Wave File in a Format.vi".
To view the functionality of the format conversion, run "Test for Snd Read Wave File in a Format.vi".
NOTE: This example VI uses the Sound VIs which are not available in the LabVIEW Base Package.
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.