I want to develop a Real-time Audio Spectrum Analyzer, input to which, needs to be given through a microphone. I know that Spectral Analysis can be done in MATLAB, but can this be done for live (real-time) input? How?

 Accepted Answer

Honglei Chen
Honglei Chen on 17 Oct 2018
You can use Spectrum Analyzer to do this.
https://www.mathworks.com/help/dsp/ref/dsp.spectrumanalyzer-system-object.html
Look at the examples in the above page. The signal are fed into the analyzer in batch mode. You can just replace those signals with the one you get from the microphone.
HTH

6 Comments

Parth Tarabadkar
Parth Tarabadkar on 17 Oct 2018
Edited: Parth Tarabadkar on 17 Oct 2018
I am unable to do exactly that (replacing the signal). May I please know the procedure for interfacing a microphone with MATLAB and accepting real-time signals through it? Are there any special functions to do so?
Parth Tarabadkar
Parth Tarabadkar on 14 Nov 2018
Edited: Parth Tarabadkar on 14 Nov 2018
Thank you so much Mr. Chen, I am able to do Spectrum Analysis on a real-time audio signal. But I am stuck on the next step where the dB value of a particular frequncy in the spectrum needs to be extracted in a variable and then compared with another constant number (in real-time).
When you say compare, what do you mean?
If you just want to see the display of spectrum with a constant, I think you should be able to pass in an impulse signal with the threshold value and then the analyzer will display both.
If you really want to get the value itself, then you need to use a different function to do this. Depending on the settings you use in spectrum analyzer, there should be a way to replicate the algorithm with pspectrum. The algorithm of spectrum analyzer is documented in the algorithm section.
The pspectrum reference page is at
HTH
Parth Tarabadkar
Parth Tarabadkar on 15 Nov 2018
Edited: Parth Tarabadkar on 15 Nov 2018
By compare, I mean that if the input audio signal has a frequency component of 500 Hz and the corresponding gain is +2dB, then I want this value (the number 2) in a variable (say x), so that it could be further compared with any other number which we provide explicitly (say 1), i.e calculate the difference between x and 1 in real time.
In that case, I'd suggest you to use pspectrum instead of spectrum analyzer to retrive the number.
HTH

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!