LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Display Problem with Time-Frequency Spectra

Solved!
Go to solution

I was just handed a .WAV file containing some utterances, and asked to determine the frequency spectrum so we could order appropriate speakers to play the sounds.  Because they are short utterances (a 4-5 second example is below), I decided to use the Short-Time Fourier Transform (STFT) code to create a Time-Frequency Spectrograph.  I'd not done this previously, so I installed the Advanced Signal Processing Toolkit, ran some of the Time Frequency Analysis examples, read the Help files, and went to work.  My (partly-successful) code snippet is below (the problem isn't the analysis, It's the Display, Dummy):

Spectrogram QuerySpectrogram Query

I read a Sound File, extract the (only) left channel, and run it through the STFT routine.  I scale it using the Configure Spectrogram Indicator, specifying to Use dB and Ignore Timestamp (and providing a Reference to the Time-Frequency Spectrogram Indicator, an Intensity Graph, that it produces.

 

When I first did this, I started with a copy of one of NI's Examples, and got a nice Spectrogram.  I started editing NI's code, replacing it with my own and simplifying somewhat (see above), but wiring it to the Indicator that came with the Example (why not?).  As you can see, below, I got a nice picture.

Time-Frequency SpectrogramsTime-Frequency Spectrograms

So far, so good.  So I added a second spectrogram (for comparison), but this time I right-clicked the output from the Configure Spectrogram Indicator VI and chose "Create Indicator".  This gave me the second plot above (I used the same data here, of course).  So what's the problem?

 

Notice the Amplitude Indicator, the little Rainbow Bar shown to the right of Spectrogram #1, but missing in Spectrogram #2.  I've been looking all over for this, and can't figure out where it is.  I've compared (by hand) many of the Properties of the two Intensity Graphs (using LabVIEW to examine all of the Z-Scale properties), and haven't found where they differ, but clearly they do.

 

One other thing is annoying me -- in the Block Diagram, the Label for Spectrogram #1 (the one I "borrowed" from the LabVIEW Example) has a box around it.  I may have known at one time how to "box" such a label, but I've forgotten, and can't get rid of the box!  [This seems almost too trivial to worry about, but it bugs me ...].

 

Just so I don't have Bob_Schor yelling at me about not posing Pictures (I'm sure he'd be OK with Snippets), I'll also attach the code, with "Make Current Values Default" (which I hope preserves the Pretty Pictures).

 

Bob Schor

 

Message 1 of 8
(4,248 Views)
Solution
Accepted by Bob_Schor

Re: "boxing" a Label- shift-right click on the background of the label, select color picker, choose Transparent, bang no more box 🙂 The box comes from a white background AFAIK.

Message 2 of 8
(4,227 Views)
Solution
Accepted by Bob_Schor

@Bob_Schor wrote:

 

 

Notice the Amplitude Indicator, the little Rainbow Bar shown to the right of Spectrogram #1, but missing in Spectrogram #2.  I've been looking all over for this, and can't figure out where it is.  I've compared (by hand) many of the Properties of the two Intensity Graphs (using LabVIEW to examine all of the Z-Scale properties), and haven't found where they differ, but clearly they do.

 


The Rainbow Bar is there in #2. Customize the control and move the plot you will see it hiding. Seems like a bug.

 

mcduff

 

Snap65.png

Message 3 of 8
(4,226 Views)

It's more of a "glitch" than a bug 🙂 You can do it without having to customize the control:

 

sneaky.png

 

Run that 2-3 times and it'll come out of hiding. It's unfortunate you can't select something "behind" something else if they're part of the same "parent". You'd have a similar issue if you hid the label behind the graph.

Message 4 of 8
(4,221 Views)

Well, I should have been able to figure out the "Boxed Text" as I started with LabVIEW back when Tools were visible (and have heard from my colleagues wails of anguish from Rumors that NXG will only have AutoTools).  I'm also grateful for learning that the ZScale "bar" was really there all along -- I just couldn't see it!  I'll bring this to NI's attention -- to the best of my knowledge, I didn't do anything to "cause" the Graph to hide part of its legend, it just "did it all by itself".  Bad Spectogram!

 

Bob Schor

0 Kudos
Message 5 of 8
(4,206 Views)

I don't have that toolkit installed, but I've noticed that frequently when right-clicking and picking "Create indicator" you can have some weirdness where it'll use the format of the indicator on the VI that you clicked on- not always the base type of the VI.

 

Could the Z axis be hidden in that VI's front panel for some reason? Maybe it's just that specific VI that has an accidentally hidden Z axis. Does the same thing happen with other "Create indicator" VI's that generate spectograms?

0 Kudos
Message 6 of 8
(4,201 Views)

@BertMcMahan wrote:

Could the Z axis be hidden in that VI's front panel for some reason? Maybe it's just that specific VI that has an accidentally hidden Z axis. Does the same thing happen with other "Create indicator" VI's that generate spectograms?


Don't know, but when I get some "free time" at work (I only have that toolkit installed on my Work PC), I'll check.

 

Bob Schor

0 Kudos
Message 7 of 8
(4,194 Views)
Solution
Accepted by Bob_Schor

This Is Not A Bug!!  This is an Example of Bob Schor not following Bob_Schor's oft-repeated advice to "Read the Help File carefully".  In the Help for TFA STFT Spectrogram VI, it says:

 

spectrogram returns the quadratic time-frequency representation of the signal. Each row corresponds to the instantaneous power spectrum at a certain time. Use the TFA Spectrogram Indicator to display the spectrogram on an intensity graph. You can save the time-dependent 2D array to a text file for use in another software environment. The resulting text file contains only Z values and does not retain the time axis information or the frequency axis information. You can use the TFA Get Time and Freq Scale Info VI to compute the time scale information and the frequency scale information of the time-frequency representation.

 

I used TFA Get Time and Freq Scale Info alright, but I used the "default" Spectrogram Indicator you get by right-clicking the Spectrogram output and choosing "Create Indicator".  If, instead, I find the TFA Spectrum Indicator on the Front Panel Controls and drop it, not only does it have the Intensity Axis "bar" visible, the Graph name has a box around it, the other "complaint" in my original Post.

 

This is clearly the right way to solve the Indicator problem, so I'm also going to mark this Post as a Solution.  I will, however, confess that I "stumbled" upon it while writing up a Bug Report to NI (which, thank goodness, I didn't send, but may suggest that they look into considering a fix for this obscure "feature").

 

Bob "Red-Faced" Schor

0 Kudos
Message 8 of 8
(4,161 Views)