LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabView Program that can play a .wav file on an external speaker

I am trying to make a labview program that can play a .wav file stored in labview on an external speaker by using an arduino UNO as DAQ device.

I found several solutions to play a .wav file on the loudspeaker of the computer itself, but I am stuck at sending the analog signal to an external speaker.

 

Someone who has found a solution to this problem?

0 Kudos
Message 1 of 6
(1,166 Views)

Hi Senne,

 


@SenneDG wrote:

I am trying to make a labview program that can play a .wav file stored in labview on an external speaker by using an arduino UNO as DAQ device.

I found several solutions to play a .wav file on the loudspeaker of the computer itself, but I am stuck at sending the analog signal to an external speaker.


Read the WAV file into an array of waveforms.

Then output the sample data of the waveform(s) to your Arduino…

 

what have you tried and where are you stuck?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(1,157 Views)

Hello

 

I can read a WAV file with the 'sound file read simple' block and store the data in a waveform. 

I am using the hobbyist toolkit and I think the problem I am having is that I can't use the 'Analog Write' because the Arduino UNO only has analog read ports or digital read and write ports. 

 

So I tried using the  'Digital Write' block but in this way, I only can play the first frequency of the file.

0 Kudos
Message 3 of 6
(1,135 Views)

Hi Senne,

 


@SenneDG wrote:

I can't use the 'Analog Write' because the Arduino UNO only has analog read ports or digital read and write ports. 


So you want to output an analog signal without using an analog output???

How should this happen?

 


@SenneDG wrote:

So I tried using the  'Digital Write' block but in this way, I only can play the first frequency of the file.


How do you write an analog waveform to a DO?

What is the "first frequency"?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 6
(1,107 Views)

@SenneDG wrote:

Hello

 

I can read a WAV file with the 'sound file read simple' block and store the data in a waveform. 

I am using the hobbyist toolkit and I think the problem I am having is that I can't use the 'Analog Write' because the Arduino UNO only has analog read ports or digital read and write ports. 

 

So I tried using the  'Digital Write' block but in this way, I only can play the first frequency of the file.


Um... yeah without an analog out (internal DAC [not DAQ]) you are kinda hooped

 

I guess you could use all of the Uno's digital outputs and an R-2R Ladder for 14bit resolution.

 

BTW: DAQ = Data AcQuisition DAC = Digital to Analog Converter 

 

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 5 of 6
(1,089 Views)

There's a few ways of doing analog out with an Arduino, such as the R-2R circuit, or PWM + filter cap. Unfortunately I don't think LabVIEW's LINX toolkit will be a viable option here. Using the LINX API to write serial data, and set digital / pwm outputs will likely be too slow for audio data.

 

It might be doable using an 8-bit R-2R circuit. custom Arduino sketch and custom LabVIEW code. The LV code would load a wav file, convert it to single channel 8-bit (0-255), then stream the data to the Arduino via its serial port. On the Arduino every byte received from the serial port would be read and written to the R-2R circuit using a port write. It would sound pretty lo-fi, but be enough for basic audio.

 

Once you have the analog signal output, you'll want to run it through an amplifier circuit of some sort to drive the speaker.

0 Kudos
Message 6 of 6
(1,049 Views)