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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

.wav file Reading out vs. Reading in data

Hey guys,

 

I have a .wav file I am reading and outputting to speakers. I am a little confused over the rates of reading vs. outputting. I know they both want to be the same (around 48 kHz), but I don't know how to configure both. I can configure the sample rate (the rate at which the signal goes to the hardware) through the daqmx timing subvi, but I don't know how to set the hardware to output at the same rate.

 

I am assuming these rates are not correct because when I play my .wav file through the computer it sounds better than when I play it through my daq 4461 card (analog out) connected to my speaker.

 

Thanks

4.PNG

0 Kudos
Message 1 of 13
(3,008 Views)

Hi monkeys,

 

"it sounds better than"

Use better speakers on your DAQ card to improve sound quality… 😄

 

- Use the waveform sample rate to set the sample rate of your DAQmx task!

- For DAQmxTiming exist a setting to take sample rate of waveform automatically…

 

Right now you set some arbitrary sample rate and an arbitrary clock source - we can't see both values!

What's the purpose of the inner while loop?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 13
(3,000 Views)
You've hidden the sample clock source and the rate.

p.s. That equal comparison with the local variable is just wrong.
0 Kudos
Message 3 of 13
(2,995 Views)

So I don't have a task because I just have a channel and I am reading a .wav file right? The speakers are good speakers and I am playing pink noise so all I can tell is that it doesn't sound right haha. The point of the 2 while loops is my ability to change the volume and have the signal continue to output. In other words, I don't have to re-run the program every time I want to change the volume. Here is my front panel... I know the scale is wrong for the graph.

 

5.PNG

0 Kudos
Message 4 of 13
(2,992 Views)
You can't do DAQ without a task. It doesn't have to be saved in MAX, though.

You can set the timing source to be the waveform - your .wav file.
0 Kudos
Message 5 of 13
(2,977 Views)

Hi monkeys,

 

- you don't need to set a clock source here

- you want to output an array of waveforms on just one AO channel? Either select more output channels or output just one waveform…

- Use DAQmxTiming with "Use waveform" option…

 

What volume values do you use (other than 1)?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 13
(2,973 Views)

I like to vary the output from 1,2,3,4,...etc. to get different voltages to my speakers. If I don't use a clock source and I just select "use waveform" then the two wires don't connect because my source (.wav file) is 1D array of waveforms. I don't know why a pink noise .wav file is 1D array of waveforms.

0 Kudos
Message 7 of 13
(2,968 Views)

Hi monkeys,

 

ever heard you could use IndexArray function to index a single waveform from an array of waveforms?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 13
(2,955 Views)

Yes, I used index array and put it into the daqmx timing set to waveform and it reports an error when I run it6.PNG

0 Kudos
Message 9 of 13
(2,950 Views)

Hi monkeys,

 

you really should show the full picture - not just part of it. The interesting part is hidden behind that error message (and the window borders)…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 13
(2,945 Views)