1

I have been working to find temporal displacement between audio signals using a spectrogram. I have a short array containing data of a sound wave (pulses at specific frequencies). Now I want to plot spectrogram from that array. I have followed this steps (Spectrogram C++ library):

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))

Now after performing these 3 steps, I am stuck at how to plot the spectrogram from this available data? Being naive in this field, I need some clear steps ahead to plot the spectrogram.

I know that a simple spectrogram has Frequency at Y-Axis, time at X-axis and magnitude as the color intensity.

But how do I get these three things to plot the spectrogram? (I want to observe and analyze data behind spectral peaks(what's the value on Y-axis and X-axis), the main purpose of plotting spectrogram).

Regards, Khubaib

Khubaib Ahmad
  • 141
  • 10
  • 2
    C++ has no built-in graphics. Unless you are fine with drawing a plot made of `*` or similar on the console you need to use some graphics library – 463035818_is_not_an_ai Apr 13 '20 at 15:29
  • @idclev463035818 actually no, you don't need a special library. Rendering to a BMP file is trivial in pure C++. The question is whether it's what the OP wants. – Ruslan Apr 13 '20 at 15:56
  • @Ruslan of course you can write a BMP image, but that isnt what I would call "plot the spectrogram", because you still need an external program to view the BMP. Maybe there are even programs that you can pass the raw data and they will create a plot, but I dont thinks that is what is asked for. On the other hand you can of course write c++ code for graphics for a given platform from scratch, but I think also this is not what OP is asking for – 463035818_is_not_an_ai Apr 13 '20 at 16:13
  • Hi Guys, Thank you for your input. I want to generate a spectrogram more as we can observe in Audacity or Python Scipy spectrogram plotting. Further explaining my question please have a look : https://dsp.stackexchange.com/questions/66447/how-to-get-coordinatesxtime-yfrequency-of-spectral-peaks-from-spectrogram – Khubaib Ahmad Apr 14 '20 at 10:02

0 Answers0