LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Realtime Hz display from a .wav file

Hey there,

 

Next to playing the sound file I also want to have a chart displaying the current [Hz]. So far I've been able to play the sound and instantly display the Hz input over the whole song. Instead of instantly displaying the whole song on the chart I want it to go with playing of the song. I feel like it has to do with the data type of the wire connecting to the chart (data (waveform((DBL))) since I've already tried to change some settings chart itself (Chart History Length etc). Can someone help me read out a .wav file and display this in real time on a Waveform Chart? (or any other chart) 

0 Kudos
Message 1 of 4
(258 Views)

Reading a wave file and displaying the data is not "real time".

 

Are you looking for e.g..a Joint Time-Frequency Analysis (JTFA) or are you only interested in the main frequency component?

Do you have the advanced signal processing toolkit?

 

A single time point has no "frequency", so you need to balance time and frequency resolution while accounting for spectral leakage, alias frequencies and other artifacts. How familiar are you with signal processing? If you only listen for a millisecond, you cannot tell the difference between Beethoven's fifth and a rap song.

 

As poor mans solution, maybe you could rattle the array data component through some ptbypt filter and fft while scaling the output based on dt?

 

 

Message 2 of 4
(219 Views)

Hi,

 

To display the frequency (Hz) in real-time on a Waveform Chart as the .wav file plays, use a buffer to read chunks of the file and update the chart incrementally. Ensure your chart’s data type matches the audio data and adjust the update rate to sync with the audio playback. This approach will allow the chart to reflect the Hz changes as the song progresses.

0 Kudos
Message 3 of 4
(186 Views)

@Student129041 wrote:

Hey there,

 

Next to playing the sound file I also want to have a chart displaying the current [Hz]. So far I've been able to play the sound and instantly display the Hz input over the whole song. Instead of instantly displaying the whole song on the chart I want it to go with playing of the song. I feel like it has to do with the data type of the wire connecting to the chart (data (waveform((DBL))) since I've already tried to change some settings chart itself (Chart History Length etc). Can someone help me read out a .wav file and display this in real time on a Waveform Chart? (or any other chart) 


I may be wrong, but I think you don't understand the data, are using the wrong terminology (which "confused" @Altenbach, who probably was deliberately answering the "wrong" question you asked -- it is very hard to really confuse him otherwise).

 

I believe a .wav file basically encodes a waveform, showing the amplitude of a signal sampled at some sampling interval (often around 44 kHz, if a CD), which LabVIEW saves in a special data construct called a "Waveform".  When you plot a Waveform on a Chart (by wiring the Waveform to the Chart), it "does what you asked it to do", and plots the entire Waveform, outputting the points as fast as it can.  

 

Assume you have a microphone, an amplifier, a speaker, and an oscilloscope, and are going to sing into the microphone and want to hear it and "see it" on the scope.  Is that what you are trying to do?  That's what I think you are trying to do, but maybe @Altenbach is right (at least a 90% probability that's correct!), and you don't want to look at the Waveform (which will just be a jiggling trace moving across the scope).

 

Of course, you provided no code to show us what you did, used [Hz] without defining clearly what you are trying to plot, and seem ignorant of the concept of a Waveform (which represents a time-varying signal) and what it is you want to extract and plot.

 

So to get back to what I thought you (maybe) wanted, if you want a plot that jiggles around and varies as you play the sound in "real time", you need to take the Waveform data and "plot the points in real time", not "all at once", but "one at a time" at some frequency.

 

Bob Schor

 

 

0 Kudos
Message 4 of 4
(178 Views)