Playing Sound in LabVIEW

Content

1) STEP 1: Create sound file using Audacityhttp://audacity.sourceforge.net/ ) or similar program. Export the edited file in .wav format to your desktop.

2) STEP 2: In the Labview Front Panel, Create a path to the file ( Modern—String and Path— File Path). Use the Operate Value (finger) to locate (provide a path to) your sound file on the desktop.

3) STEP 3: Write or modify a program to play the sound file. We started with the one found under LabView—Help— Find examples—Hardware—Sound . Most of the blocks can be found under Programming—Graphics and Sound— Sound—Output, Files, plus one function from Programming— Numeric Arithmetic:

Code
Content
The Device ID seemed to work if I set it to 1. The number of samples can just be a constant- I set it to the default of 2500.

The above program seemed to have a lot of extra stuff in it, so I reduced it to this version- it plays the sound when I push a button on the EV3.
Code
Content
To neaten it up still further, you can make most of the code into a Sub VI(Custom block), which could be reused to play various sound recordings when needed:
Code
Attachments
AttachmentTypeSize
soundfiletosoundoutput_580a6079cffa3Sound File to Sound Output.vi19.40 KB

Leave a Reply

Your email address will not be published. Required fields are marked *