NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
Zed8
Posts: 4
0 Kudos
Accepted Solution

Basic Spectrogram from Acquire Sound VI

Hello,

 

I have just recently begun to delve into LabView, and I have what I imagine to be a pretty basic question here. I am using LabVIEW 8.5.

 

I am using the Acquire Sound VI to get data from an external microphone, and I can convert the dynamic data to a waveform, display that waveform on a basic waveform chart, and also perform and display the FFT frequency spectrum.

 

What I cannot figure out, however, is how to feed this waveform data into the STFT Spectrogram VI (and then into an Intensity Graph) so that I can see the time/frequency amplitude behavior.

 

Ideally, I would like a real-time spectrogram that takes data over at least 5 seconds, but just as well would be a spectrogram that is created after the program is run and then stopped. Please help out a newbie here. I appreciate it.

 

I have attached the basic sound input VI that I'm trying to make the spectrogram from.

Member
VTKim
Posts: 122

Re: Basic Spectrogram from Acquire Sound VI

Hi Zed8,

 

The function that you will have to use is the Get Waveform Components and from there, you will be able to wire the Y component to the STFT Spectrogram VI and then into an intensity chart.  Here is a screen shot with red squares around what I modified in your code and attached the modified code.  I added timing since this is just a good programming practice. I hope this helps!

 

Spectrumimage.png

 

Kim W.

Applications Engineer
National Instruments
Member
Zed8
Posts: 4
0 Kudos

Re: Basic Spectrogram from Acquire Sound VI

Thanks Kim. That is pretty close to what I wanted. I ended up finding a simpler way to get waht I wanted (an accurate spectrogram over a period of as many seconds as the program runs) without using the STFT at all.

 

Spectrogram2.gif

Member
Crawling
Posts: 23
0 Kudos

Re: Basic Spectrogram from Acquire Sound VI

Hi Zed8,

 

I am new to Labview and I am on a project to measure sound.  I tried to practice on your last block diagram but I seems to stumbled on an issue.  The vrms output is a single dimensional array whereas the intensity chart is expecting a double dimension array.  I have attach the vi for clarification.  Will appreciate if you could kindly show me where did I go wrong. 

 

Thanks

 

Abu

Member
DylanC
Posts: 93
0 Kudos

Re: Basic Spectrogram from Acquire Sound VI

Hi Crawling,

 

You need to enable auto-indexing on the output tunnel of your data to the spectrogram.

 

DylanC

Member
Crawling
Posts: 23
0 Kudos

Re: Basic Spectrogram from Acquire Sound VI

Dear DylanC,

 

By having auto-indexing on which is set off at default in a while loop, each iteration will add the time dimension, converting the single dimension array (Vrms) into a two dimensional array (vrms, t).  Now I can continue my crawl to my next stop. 

 

Thanks DylanC.

 

Crawling.

Member Y3G
Member
Y3G
Posts: 144
0 Kudos

Re: Basic Spectrogram from Acquire Sound VI

Guys,

This was very supporting and efficient.

I am doing a range measurement in meters with the STFT. I would like to change the frequency axis of the STFT according to a certain frequency resolution.

For example each 100 Hz equals to 1 meter, so that the Frequency component is shifted accordingly and the values are in the Y-Axis.

How do I do  that?

Is there a way to set markers on the Frequency plot as well as on the STFT plot and read them out as Indicators?

 

Many thanks in advance

Y3G

Member
Tim-C
Posts: 50
0 Kudos

Re: Basic Spectrogram from Acquire Sound VI

What is the specific VI that you're using when you refer to STFT? And how are you plotting it?

TimC
National Instruments
Applications Engineer
Member Y3G
Member
Y3G
Posts: 144
0 Kudos

Re: Basic Spectrogram from Acquire Sound VI

Hello to All,

I have continued and have added some STFT charts and some more questions, attached is my code and a picture.

1) How  do I modify the X-Axis of the POwer spectrum according to my input Frequency. I am doing this with a Function Generator and getting wrong Results.

2) Why  do you put the FFT PropertNode XScale.Multiplier the value 1.33? 

3) The Time Waveform starts with an offset, How can I change it?

4)  ...and as mentioned before I would like to use the STFT but have difficilties to get the correct values even when wanting to show the correct Frequency as in the FFT Power spectrum. Can anyone explain tome what I am doing wrong?

 

 

 

 

Many thanks in advance

Y3G

 

Member
Tim-C
Posts: 50
0 Kudos

Re: Basic Spectrogram from Acquire Sound VI

Hey Y3G,

 

Can't you just use a property node with the Xscale.maximum for the x axis?

 

Also here a link on how to change the offset of a waveform 

http://labview.ni.com/docs/proposals/6.1/HTMLHelpProposal/HTML%20Conference/WebHelp/LvwaveWaveform_S...

 

Hope that helps

TimC
National Instruments
Applications Engineer
By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page