LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Wav file component Vi

Hello,

 

I made this VI that gets the Y component of any wav file it reads. It's displaying no errors but it's not displaying any data other than a 0.000023 dt for ALL wav files i put into it. What's wrong with it? Any help would be much appreciated. 🙂

0 Kudos
Message 1 of 10
(3,498 Views)

When I use the sample.wav file in the examples>sound2 folder, I have no problems.

0 Kudos
Message 2 of 10
(3,493 Views)

Have you tried using any other .wav files?

 

I was unable to recreate you problem. It seems to work fine with a couple of different .wav files that I have on my computer.

Brandon L.
Automation Engineer
0 Kudos
Message 3 of 10
(3,476 Views)

Brandon-L,

 

All my wav files are just 4 to 5 seconds long. Does the length of the wav file affect how this vi. shows the data??

0 Kudos
Message 4 of 10
(3,469 Views)

0.000023 refers to a 44.1kHz sample rate, which is pretty common for a sound file. How do you know it's wrong? 

 

As for your code: Having the code read the file at each iteration is not a good approach - you're constantly hammering the hard disk. If you want to test various files then put a button on the front panel in which you initiate the read, and execute the code only when you press the button. You can use an event structure.

0 Kudos
Message 5 of 10
(3,458 Views)

 

0 Kudos
Message 6 of 10
(3,454 Views)

I think you misunderstood what was being explained to you. The output of Sound File Read is an array of waveforms because each waveform in the array corresponds to a channel in the sound file. Thus, for a stereo sound, you'd have two waveforms. In your code you have a for-loop, but you are not doing any indexing on the output, thus, you will always get the data for the last channel in the sound file for your array indicator.

 

I don't exactly know what your final objective is, but your question was related to believing that the Sound File Read was not working correctly because you saw a value of 0.000023for dt for all wav files that you tried. Well, that value is perfectly reasonably, and probably perfectly correct, since it's the sample rate for the sound file, and all of your sound files may have been sampled at the same rate. The length of the sound file has no bearing on that value. 

 

Plus, I was referring to the while loop, not the for-loop.

0 Kudos
Message 7 of 10
(3,452 Views)

smercurio_fc

 

Thank you for the clarification. What I'm trying to achieve here is to get a single component that would differentiate a wav file from others and I thought I would use the Y component. By the way, how many iterations would I need in order to get the component I want?

0 Kudos
Message 8 of 10
(3,445 Views)

I revised the VI a bit and used an event structure, but again I'm still getting the 0.000023 dt. Here is the revised VI

0 Kudos
Message 9 of 10
(3,444 Views)

@MarkBai wrote:

smercurio_fc

 

Thank you for the clarification. What I'm trying to achieve here is to get a single component that would differentiate a wav file from others and I thought I would use the Y component.


Define "differentiate a wav file from others". What do you define as "different"?

 


By the way, how many iterations would I need in order to get the component I want?

This question is meaningless since I don't know what you mean by "component". As I said, there are as many waveforms in the array as there are channels in the recorded file. How am I supposed to know how many that is? They're your recordings.

 

 


I revised the VI a bit and used an event structure, but again I'm still getting the 0.000023 dt.

You're not listening. I told you. That's the inverse of the sampling rate. Why are you expecting this to be different? How do you know that the wav files weren't all sampled at the same rate?

 

0 Kudos
Message 10 of 10
(3,435 Views)