Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Document Type: Example Program
NI Supported: Yes
Publish Date: Sep 6, 2006


Feedback


Yes No

Related Categories

Related Links - Developer Zone

Related Links - Products and Services

Reading Data From an Audio File in a Specified Format

4 ratings | 3.50 out of 5
Print

Downloads

Filename: read_and_convert_wave_file.zip
Requirements: View

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

Requirements


Filename: read_and_convert_wave_file.zip

Software Requirements


Application Software: LabVIEW Full Development System 7.1
Language(s): LabVIEW

 
4 ratings | 3.50 out of 5
Print

Reader Comments | Submit a comment »

 

Legal
This example program (this "program") was developed by a National Instruments ("NI") Applications Engineer. Although technical support of this program may be made available by National Instruments, this program may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this program with each new revision of related products and drivers. THIS EXAMPLE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).