07-08-2012 05:31 AM
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. 🙂
07-08-2012 10:09 AM
When I use the sample.wav file in the examples>sound2 folder, I have no problems.
07-09-2012 09:04 AM
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.
07-10-2012 02:00 AM
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??
07-10-2012 08:13 AM
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.
07-10-2012 08:32 AM
i was told to do the for loop since the output from the read file would be a 1D array and I had to connect it to the get waveform component which only accepts single data.
07-10-2012 08:44 AM
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.
07-10-2012 10:26 PM
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?
07-10-2012 10:35 PM
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
07-11-2012 07:32 AM
@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?