LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to correctly plot the X-Axis for displaying Time instead of # of Samples?

i have acquired (i think) the cepstrum and i want to plot the correct time for the x-axis instead of showing number of samples...how can i do that?i have a zip file with the code and a sample wav file.the cepstrum is the last graph.
 
can someone please help me with this?
0 Kudos
Message 1 of 12
(4,985 Views)
Madgreek,

I am not familiar with the concept of Cepstrum, but I will give this my best shot.  Currently, on your Cepstrum graph you are not plotting the Y values versus sample number directly.  You are plotting one point every 15.625 units of the X axis (Quefrency).  If you want to change that X interval, you only need to change the delta-t value you are passing into the cluster.  On what order do you expect the X range to map to? (seconds, milliseconds, ondsecs, ztreh ;)?)

If the issue is more complex than this and you need to use a non-repetitive-multiple for the X axis, you may need to use an XY Graph, rather than a Waveform Chart.  With an XY graph, you can specify both an X array and Y array for the locus of points. 

Hope this helps!

Cheers,
Spex
National Instruments

To the pessimist, the glass is half empty; to the optimist, the glass is half full; to the engineer, the glass is twice as big as it needs to be has a 2x safety factor...
0 Kudos
Message 2 of 12
(4,956 Views)
hello Spex
 
first of all....just to clear out some aspects 🙂
how did you obtain the 15.625 units...what is that?
i know my Y values for all the graphs are wrongly scaled (displayed)....but i thought that doesnt matter that much so i didnt pay attention to them (since i think its just a matter of scaling)
as far as the X-axis of cepstrum it should (ideally) be in msecs...and Y-axis it should be in volts i think since it just displays the pitch period of a segment of the original signal.
 
basically what the cepstrum is ....its the cepstrum of a cepstrum displayed in time (x-axis)
 
what did you mean by i am not plotting the Y values versus sample number?
 
sorry if i confused you even more
 
kind regards
alex
0 Kudos
Message 3 of 12
(4,953 Views)
correction about my last message.....i meant the cepstrum is just the spectrum of the magnitude spectrum of a signal
0 Kudos
Message 4 of 12
(4,949 Views)
Hi madgreek,

I acquired the 15.625 number by probing the value you have passed into the bundle function just before you pass the data to the cepstrum waveform graph.  Mathematically, that value is calculated in your program as (Sampling Frequency)/(FFT Length) or Fs/N.  It appears to be the frequency resolution (delta-F) for the FFT.  This same value is being passed as the delta-t of the cepstrum graph.  If the cepstrum graph is actually supposed to have a smaller delta-t, on the msec order for example, we just need to pass a different value into the bundle function for the cepstrum graph.  The last thing we need to change is the formatting on the X-Axis so that it will display several significant digits in SI notation so the values on the X-Axis will look like "15.00m" rather than "0.02".

"what did you mean by i am not plotting the Y values versus sample number?"
What I meant by that post is that the units for the X axis are not samples, directly. The X axis was being scaled by the 15.625 value being passed to the bundle function.  Therefore, if the Y array being plotted was theoretically "2, 6, 4, 3, 7, ...", the points would be plotted at "(0, 2), (15.625, 6), (15.625*2=31.250, 4), (15.625*3=46.875, 3), (62.5, 7) ..."  Thus the values on the X axis are not the sample number, but the sample number scaled by 15.625.  If we want this value to be in msec, we just need to find the correct scaling value, or delta-t to pass into the bundle. 

By routing the delta-t value from the "Input Signal" graph to the delta-t of the cepstrum graph, I was able to get the graph to plot the data on an X-Axis that spanned 0 msec to 31.88 msec.

Cheers,


Spex
National Instruments

To the pessimist, the glass is half empty; to the optimist, the glass is half full; to the engineer, the glass is twice as big as it needs to be has a 2x safety factor...
0 Kudos
Message 5 of 12
(4,938 Views)

hello spex and thank you for all the help.i really appreciate it

i see now how you got the 15.625 ( 8000/512 right?). i guess you used the wrong Fs for it.as you can see in  the front diagram the original sampling frequency is 44100 (from the sound format).that frequency you have to choose from the choices i have (8000-11025-22050-44100) below the signal size display just to match the original one so you can get the correct duration of the original waveform. (check to see that for different choices of Fs i.e 8000 as you probably chose the duration changes). but despite that i understood how you obtain the dF for fft.

now, about the original dt you route to the bundle for cepstrum graph. i did the changes you are talking about and i saw the results on the cepstrum graph. it seems much closer to what i should be getting although i didnt quite undertstand the reason for it...im sorry

a question i have though is about the iFFT. i read that, despite using real or complex ifft, the input to the ifft has to be complex always?is this true?if yes,if you can see from the block diagram, the input to my ifft is the logarithmic absolute value of the output of the real fft.do you think that might be another one of my mistakes?

regards

alex

p.s. very stupid question but i have to ask it. is dF=1/dt?

0 Kudos
Message 6 of 12
(4,932 Views)

"If the issue is more complex than this and you need to use a non-repetitive-multiple for the X axis, you may need to use an XY Graph, rather than a Waveform Chart. "

A chart will plot non-periodic data if you uses a Waveform data type. The X-values will be determined by the T0 of the Waveform and the dt if there is more htan one element in the Y-array.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 12
(4,921 Views)
Ben,

Good call, thanks for keeping me honest 😉

Alex,

I adjusted the sampling rate enum on my instance of your VI.  I looked at some other algorithms for computing cepstrum, and it looks like the dt of the original single (1/Fs) is what is used for the delta X on the cepstrum graph.  My explaination for why my not be the exact scientific truth, but here is how I would explain it.  We are performing an FFT, so we are in the frequency domain, so the unit is frequency and the df is Fs/N.  Then we are performing some non-linear scaling on the data that I will "say" is not changing the unit of the FFT data.  Then we perform an inverse FFT bringing the data back into the time domain.  This final data is then seconds and the dt is once again 1/Fs. 

On the question about the input to the IFFT, the VI does require an complex data type.  If you run a real datatype to this VI, LabVIEW will automatically coerce the data to a complex type.  This is indicated by the coercion dot that appears at the input to the VI.  You can also use the "To Double Precision Complex" primitive to manually turn your array to a complex type. 

The final pointer I have at this time is that looking at your algorithm, I have seen cepstrum implemented with a natural log function, rather than the log base 10.  I don't know which way is correct, but it could be the final thing to give you the correct answers. 

r.p.s (response to post script ;))  Not a stupid question.  I believe that df is actually equal to (Sampling Frequency)/(Width of the FFT) ie. (Fs/N) and dt is 1/(Fs), but it has been a little while since I was in the class room implementing single processing algorithms.  I don't get to do this stuff everyday with my role here at NI.

Cheers,


Spex
National Instruments

To the pessimist, the glass is half empty; to the optimist, the glass is half full; to the engineer, the glass is twice as big as it needs to be has a 2x safety factor...
0 Kudos
Message 8 of 12
(4,895 Views)
spex
 
i dont know how to thank you for all your help, suggestions and guidance. i really appreciate it
 
you are right about the dt and the natural log. i just read about it .
 
again i want to thank you for all your help
 
kind regards
alex
 
p.s one last favor if its possible from your part, if not its still fine. in the advanced signal toolkit (version 7.5 and up i think, i have version 7 of it) there is the Real Cepstrum vi. is there a chance, if you can, to run it with the sample waveform i have posted earlier just for me to make sure i get similar results?if you can post here a few screenshots or something to have as reference? is this possible?if not, i still appreciate all your help. i know i ask too much : )
 
 
 
 
 
 
 
0 Kudos
Message 9 of 12
(4,889 Views)
Hi Alex,

Glad to hear that my suggestions are helping.  I did take a comparison screen shot of the results your algorithm with the changes I suggested vs. the Real Cepstrum.vi output.  Looks like we were on the right track!

Cheers,
Spex
National Instruments

To the pessimist, the glass is half empty; to the optimist, the glass is half full; to the engineer, the glass is twice as big as it needs to be has a 2x safety factor...
0 Kudos
Message 10 of 12
(4,849 Views)