Spectrogram C++ library

江枫思渺然 提交于 2019-11-27 00:37:12

问题


For my current project in C++ / Qt I need a library (LGPL is preferred) which can calculate a spectrogram from a signal ( basically an array of doubles ). I already use Qwt for the GUI part.

Any suggestions? Thanks.


回答1:


It would be fairly easy to put together your own spectrogram. The steps are:

  1. window function (fairly trivial, e.g. Hanning)
  2. FFT (FFTW would be a good choice but if licensing is an issue then go for Kiss FFT or similar)
  3. calculate log magnitude of frequency domain components (trivial: log(sqrt(re * re + im * im))



回答2:


"How do I create a frequency vs time plot?" lists several libraries, each of which can calculate a spectrogram from a signal.

Copied and pasted from my own answer:

Some source code to generate spectrograms / waterfall plots from audio data:

  • SoX - Sound eXchange includes spectrogram source code
  • Audacity includes spectrogram source code
  • glfer includes waterfall spectrum display spectrum source code
  • source code that uses fftw to compute the spectrogram of an audio stream
  • more source code that uses OpenAL and fftw to compute the spectrogram for an audio stream
  • "Sound Activated Recorder with Spectrogram in C#" by Jeff Morton
  • Topographica seems to include spectrogram source code
  • SpectroGraph for iTunes

Image to Spectrogram goes in the reverse direction from the above utilities.




回答3:


you could use fftw (fftw.org) to calculate the spectrogram, you would still need to plot the data, but that should not be a problem




回答4:


You can use FFT code from here. It uses C++ template metaprogramming for efficiency. The full source is provided by the author here.

It was suggested to include this code into Eigen for its use of templated (type friendly) code.



来源:https://stackoverflow.com/questions/2133651/spectrogram-c-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!