Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

FFT-based Spectrum Meter

Post any examples or modules that you want to share here

FFT-based Spectrum Meter

Postby steph_tsf » Mon Jun 24, 2013 1:35 am

Here is FFT-based Spectrum Meter. It takes one audio stream as input, and plots the frequency content.

Actually there are three different implementations basing on different graphing engines :
- Lines being plotted by the Green component "Graph Lines"
- Dots being plotted by the Green component "GraphDots"
- Bargraph being plotted by the Ruby Graph component, using a Pen.

The most accurate one, sticking to the FFT definition is the one looking like a bargraph, implemented using the Ruby Graph component, using a Pen.
Ruby allows representing first spectral band and the last spectral band like it must, both having half the bandwidth compared to the others.
Observe how many spectral band there are, in function N (the FFT length). There are (N/2)+1 spectral bands. This is compliant with the FFT definition.

Observe the energy displayed by the first spectral band, in presence of DC. It seems to over-estimate DC by 6 dB. Actually, most commercially available FFT graphers are unclear about the first spectral band.
- Some keep the FFT output as is, warning you that the measurement will get corrupt if your signal contains DC. By warning you, they hope that you won't call their field engineer support, complaining about a 10mV DC offset getting over-estimated by 6dB.
- Some apply a radical fix, removing DC from the measured signal, using a high pass filter before the A/D conversion, or using a digital high-pass filter within the A/D conversion, or more simply, hiding the first spectral band.
- Some others apply the -6dB fix, but doing so they need to warn you that albeit any DC offset won't get over-estimated, on random signals the FFT low-end (the first spectral band) will tend to exhibit a kind of -6dB bump.
When there is DC in the signal, the only "honest" window is the Rectangular one. Only the Rectangular window will ensure that the next spectral band, won't be contaminated by the DC, and show AC energy that's actually not there. This reinforces the widespread idea, rule of thumb, that putting a signal containing DC, into a spectrum analyzer, can lead to wrong results. In reality, it depends the windowing function you are using.
On this spectrum meter, there are controls for applying any of the DC fixes described above : keep the FFT results as it (thus overestimate DC by 6dB), remove the DC in digital domain, or apply a -6dB fix on the DC.

Observe the energy displayed by the last spectral band, in presence of a frequency that's very close to Fs/2. Say 22,049 Hz when Fs = 44,100 Hz. The last spectral band will oscillate at a beat frequency, rendering the measurement unstable, quite unreadable.
Actually, most commercially available FFT graphers are unclear about the last spectral band.
Continue observing the way a 22,049 Hz signal gets measured. The surprise is when the cycle is high. The instantaneous reading is 6dB above the level that you would expect. Okay, when considering the pulsating nature of the measurement, one cannot say that there is a steady 6dB overestimation. However, the uncertainty is clear.
On this Spectrum Meter, there is a control for eventually applying a -6dB fix on the last spectral band. If you activate it, you'll face the same paradox we described above (see the discussion about DC), because on random signals the FFT high-end (the last spectral band) will tend to exhibit a kind of -6dB bump.

I'm not saying here that Flowstone delivers wrong result. All I'm saying here, is that Flowstone enables you to realize the inherent pitfalls of any FFT-based analyzer, that most vendors don't want you to know about, and possibly, that some vendor don't know about.

While undertaking the Ruby Bargraph, I feared that the Ruby speed penalty would not enable a decent screen refresh rate. Using this implementation, a 1024 FFT triggered every 200ms tends to saturate my PC. This remains okay for me.

I'll try improving the Spectrum Meter, like the rendering of the X axis labels and the rendering of the vertical lines of the grid, especially when using a log frequency scale.

Any hints welcome,
Steph
Attachments
FFT-based Spectrum Meter (GreenDots LinF).fsm
(18.34 KiB) Downloaded 1341 times
FFT-based Spectrum Meter (GreenLines LinLogF).fsm
(100.32 KiB) Downloaded 1347 times
FFT-based Spectrum Meter (RubyPen LinF).fsm
(18.3 KiB) Downloaded 1346 times
steph_tsf
 
Posts: 249
Joined: Sun Aug 15, 2010 10:26 pm

Re: FFT-based Spectrum Meter

Postby steph_tsf » Sun Jun 30, 2013 7:26 pm

Updated version.
See attached .fsm
Attachments
FFT-based Spectrum Meter_GreenLines LinLogF_ IIR BiQuad Q 0.707 (600).jpg
FFT-based Spectrum Meter_GreenLines LinLogF_ IIR BiQuad Q 0.707 (600).jpg (41.26 KiB) Viewed 17960 times
FFT-based Spectrum Meter_GreenLines LinLogF_ IIR BiQuad Q 0.707.fsm
(751.88 KiB) Downloaded 1464 times
steph_tsf
 
Posts: 249
Joined: Sun Aug 15, 2010 10:26 pm

Re: FFT-based Spectrum Meter

Postby steph_tsf » Mon Jul 08, 2013 6:13 am

Just added more Graphing features, using Ruby.

Thanks MyCo for helping me in some critical areas. MyCo determinant contributions in this particular project are :
- Efficient IIR filtering on an array, using Green code. I found this truly amazing. It opened my eyes, about Synthmaker/Flowstone capabilities. This is in the LPF Fb Hz section. I took MyCo 1st-order LPF and reworked it for implementing a 2nd-order LPF Butterworth, with a variable -3dB frequency.
- Elegant distributed control using a ring Bus. This is in the Frequency control surfaces : F Control, Lin Pad, Log Pad.
- Efficient Ruby error avoidance fix, bypassing any routine that is supposed to manipulate an array, if that array is still "nil" at execution time. This way Flowstone can still generate random triggers during initialization, without Ruby complaining about "nil" issues. This is in the Ruby Draw section, where we draw the gain, the phase, and the estimated impulse response.

Without MyCo, the user manual, the trogluddite "Trigger Tutorial" and the STEM Example Projects from Admin, I would be still nowhere.

Feel free to use and abuse this FFT-based Spectrum Meter. I'm interested in users feedback.
Check also the FFT-based Audio Analyzer here http://www.dsprobotics.com/support/viewtopic.php?f=3&t=1524&start=20

Many thanks, again
Steph
Attachments
FFT-based Spectrum Meter.fsm
(388.1 KiB) Downloaded 1355 times
FFT-based Spectrum Meter.png
FFT-based Spectrum Meter.png (105.33 KiB) Viewed 17908 times
steph_tsf
 
Posts: 249
Joined: Sun Aug 15, 2010 10:26 pm

Re: FFT-based Spectrum Meter

Postby steph_tsf » Wed Jul 17, 2013 2:34 am

The FFT-based Spectrum Meter is now part of the FFT-based Audio Analyzer
http://www.dsprobotics.com/support/viewtopic.php?f=3&t=1524&p=6857#p6857
Four signals can have their spectrum displayed, simultaneously.
Attachments
FFT-based Spectrum Meter and Audio Analyzer.fsm
(1.76 MiB) Downloaded 1456 times
FFT-based Spectrum Meter and Audio Analyzer.png
FFT-based Spectrum Meter and Audio Analyzer.png (87.65 KiB) Viewed 17861 times
steph_tsf
 
Posts: 249
Joined: Sun Aug 15, 2010 10:26 pm


Return to User Examples

Who is online

Users browsing this forum: Google [Bot] and 19 guests