From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

π (Pi) Day!

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview
This example makes use of the Sound Files VIs to read a .wav sound file and selectively play only one of the channels (by default, it is set up for a 2 channel source).

 

Description
Essentially, this is based on the 'Sound File to Sound Output' shipping example, but with the functionality to select either the Left or Right channel to be played at a time.  This may be useful in applications where it is desired to test a multichannel speaker setup, or also as a starting point to send different sound output to each speaker.


Requirements

  • LabVIEW 2012 (or compatible)
  • Sound output device capable of playing at least 2 channels of audio


Steps to Implement or Execute Code

  1. Select a .wav sound file to test in the file dialog box (a sample has been included).
  2. Select a channel to mute, Left or Right.
  3. Run the VI and listen with a pair of stereo speakers or headphones to confirm that the correct channel has been removed.

 

Additional Information or References
VI Block Diagram

5-82.png

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

Regards,
Chris (CLED, CLA, CTA)
Applications Engineering Specialist

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
TwoCentsHappy
Member
Member
on

(22^2+222+2^2)/(222+2^2)    it takes two to almost make pi

altenbach
Knight of NI Knight of NI
Knight of NI
on

A few minutes of simple changes can dramatically increase the performance of your code, e.g. you can easily gain almost an order of magnitude in speed for "calculate N digits of pi". Significant further improvements are probably possible by digging a little bit deeper.

mtedaldi
Member
Member
on

cool... let's make a competition:"who can create the fastest code (without using external libraries of course and with reliable results)?"

--
Marco Tedaldi, University of Zurich, CLAD