17

If the spectrogram was computed as the magnitude of short time fourrier transforms from overlapping windows, then the spectrogram contains implicitly some phase information. The following iterations do the job : $$x_{n+1} = \text{istft}(S\cdot\exp(i\cdot\text{angle}(\text{stft}(x_n))))$$ $S$ is the spectrogram, $\text{stft}$ is the forward-short time ...


9

Definitely you will have to calibrate your system. You need to know what is the relationship between dBFS (Decibel Full-Scale) and dB scale you want to measure. In case of digital microphones, you will find sensitivity given in dBFS. This corresponds to dBFS level, given 94 dB SPL (Sound Pressure Level). For example this microphone for input $94 \;\mathrm{...


8

Since this is a constant spectrogram, you could just as well have just averaged the |FFT|² and plotted that! (The most colorful way of visualizing things isn't always the optimal one; your signal doesn't change over time, so you don't need the time axis of the spectrogram at all.) Quite possibly, in that "easier" representation, you would have ...


7

You don't have a loss in time precision when using FFTs because the FFT is fast. The FFT is just a fast algorithm for implementing the discrete Fourier transform (DFT), nothing more. Instead, there is an inherent tradeoff in time and frequency resolution due to the Heisenberg uncertainty principle. While its statement is explicitly focused at quantum ...


7

The problem is not the spectrogram parameters, these are correct since they only depend on what resolution you want in time and frequency domain. Also, the spectrogram interpretation is correct, there are multiple frequency peaks. The problem may be: I expected to see one high power frequency after pressure rise, instead of multiple frequencies Why? If ...


6

For the first few experiments I would recommend using a scripting language like Matlab or Python. They're much easier to understand and much quicker to write than "lower level programming languages" like C++. Matlab has a signal processing toolbox and can read and write audio files, do windowing, FFTs etc. as well as a very simple playback mechanism. Basic ...


6

Why are my peaks capped? Your amplification gain is set to too high, or you are too close to the microphone. The amplifier is driven to its limits and it clips the output. Keep this recording and make another one where you are a little bit further away from the microphone to later compare the differences in the spectrogram. It will be interesting to see how ...


5

Please check this answer, which describes a few approaches to the same problem. Given that bird song is a monophonic signal (only one fundamental frequency at any point in time - as opposed to polyphonic) - and given that the timbre is irrelevant, the most interesting feature to extract for this classification task is a pitch contour.


5

Both taking a magnitude spectrogram and a Mel filter bank are lossy processes. Important information needed to reconstruct the original will have been lost. Thus you need to go back and use the original audio samples to do the reconstruction by determining a time or frequency domain filter equivalent to your dimensionality reduction. You can make ...


5

In discrete signal processing the frequency domain axis topology is surprisingly not a straight line, but a closed circle. Therefore the upper and lower edge of your image are really "identified", meaning they are connected and direct neighbors. The modulation you're seeing is the beating of the two interfering components coming closer. The window size has ...


5

This happens because your window is too short. I don't have access to a plotting tool right now, but imagine for a second a slowly varying sinusoid that you chop up into pieces, and these pieces are shorter than the period of your sinusoid. If you take the Fourier transform of each of these pieces, some of your chunks will capture more energy of this ...


5

Another thing the OP can do is use the "complex" chirp. What you really have to do is (at two different times and both times sweeping all frequencies from -Nyquist through DC to +Nyquist) pass the real part, $x_r(t)=\cos(\pi \beta t^2)$ and then pass the imaginary part $x_i(t)=\sin(\pi \beta t^2)$ of the complex chirp through the material under test and ...


5

Since the input signal is real, half of the FFT data is "useless" because it is simply the complex conjugate of the other half. More precisely, a 256-long FFT of a real signal will give you: the DC amplitude, 127 amplitudes, the amplitude at Nyquist, and 127 conjugate amplitudes. Among the 700 chunks, 256 / 32 - 1 = 7 extend outside the boundaries of the ...


5

The "dimensions" of the spectrogram are not chosen based on where will the spectrogram be fed to but rather depend on your application. Therefore, it is key to understand the spectrogram itself first, as a means of generating features for one or more signals and to an extent, understand the Discrete Fourier Transform (DFT) as well, which is the key operation ...


5

I understand the concept of the STFT. In order to avoid spectral leakage, you use a hann window that overlaps by 50%. I'm sorry but you have a misunderstanding of spectral leakage in addition to how a spectogram should be computed. To be exact you cannot avoid spectral leakage completely; all you can do is to make a compromise between the spectral ...


5

I recommend a Synchrosqueezed Continuous Wavelet Transform representation, available in ssqueezepy. Synchrosqueezing arose in context of audio processing (namely speaker identification), and there's much literature on applying CWT for audio tasks. Advantage over STFT is the inherently logarithmic nature of the feature extractor, matching audio structuring. ...


4

After subtracting Fs/2 from F to get a frequency axis from -Fs/2 -> Fs/2 rather than from 0->Fs You can't center the frequency by changing the labels on the x-axis. Use 'fftshift' instead.


4

To illustrate what both @Jazzmaniac and @Phonon are telling you, let's look at the same plot, but for different window lengths. Another change is to look at the plots using the fftshift view --- so that it's clearer that the low positive frequency peaks are close to the low negative frequency peaks. The picture below plots the contour plot of the data you ...


4

None of these spectrograms show music. I would validate your algorithms by substituting a known signal, e.g. a 440 Hz pure tone. That should be a single line in your spectrogram. Audacity can generate that as a .wav file, but you can also numerically generate the signal in Python. Next, mix two known tones and check if your spectrogram is lineair (i.e. ...


4

I had a bit of a hard time to understand the answer of @edouard, which is doing the right thing. Compare to https://dsp.stackexchange.com/a/3410/9031 , which I used to implement my reconstruction. Note that $i$ is the imaginary number, and $x_n$ is the reconstructed signal at the $n^{\text{th}}$ iteration. Start with $x_0$ being a random vector of length ...


4

Wavelets are ideal for localized events. The Fourier Transform represents a function as a sum of sines and cosines, neither of which are localized. The spectrogram does keep some time information, at the expense of frequency resolution In your case, the signal is not localized at all. The spectrogram smears your 15 Hz band over several Hz, as it captures ...


4

Yes, the easiest way to do this is using reshape and FFT, since reshape will give you a matrix and the FFT will operate along a dimension of the matrix. I've applied a 1024 rectangular window on a data set of 65536 points, sampling frequency Fs (1024), and signal frequency (100). x = randn(1, 65536) + cos(2*pi*100/1024*(0:65536-1)); z = reshape(x, 1024, []);...


4

The answer from @orgeGT is quite detailed. It really looks like, to me, a pressure signal from a knocking gazoline engine, where you observe a wide band effect (the impulse part of the knock) and resonant frequencies and their harmonics (the wiggling part of the knock), and a (slight) decay in their amplitude, related to the variations of the volume of the ...


4

Looking at the spectrogram, the prominent artifacts go up or down in frequency synchronously to the 138 MHz signal but have larger bandwidths. That is an indication that they are its harmonics, due to a nonlinearity somewhere in the system. With the sampling frequency of 500 MHz some of the positive and negative harmonics alias to the following (bold) ...


4

Real/imaginary or modulus/phase are two representations of a complex number that carry the same level of information. Then, a STFT is a redundant mapping from a space of functions over a 1D variable (time) onto a space of functions over a 2D variable (time and frequency). Under mild conditions on the window, there are an infinity of inverses, due to the ...


3

Firstly $$abs(z)^{2}=Re \left \{ z \right \}^{2}+Im \left \{z \right \}^{2}=z*z^{^{'}}$$ These are all mathematically identical, so either one will work. That leaves the question of whether the square should be applied or not. In nearly all cases the original signal will represent a "linear" quantity such as voltage, current, force, pressure, particle ...


3

Windowing is nothing more than element-wise multiplication of your signal by window function. Let's assume that you want to apply Hanning window. In your case signal is stored inside myRecording(start_sample:end). Create the window values vector of your signal length: win = hann(length(myRecording(start_sample:end))) Multiply by your signal and store it ...


3

Don't have enough reputation to comment but you need to use the conjugate transpose in your formula for the result to be correct. So try stftb=U*S*V'; in the last line of code. Note that I removed the . which makes a difference since the matrices you are working with are complex.


3

In Understanding FFT Overlap Processing, p. 10, it is suggested that uniform of constant windows, for certain hop patterns, with repeated pulses, could generate such artifacts.


3

Let's define the N-point IDFT $y[n]$ of a signal $Y[f]$ as $$\begin{align*} y[n] &= \sum\limits_{f=0}^{N-1} Y[f] e^{j2\pi n\,\frac{f}{N}},& n\in \{0,\dots,N-1 \}\tag{1} \end{align*}$$ The DCT-II (which is most probably what we're looking at; the others are mathematically useful, but less nice to implement) $\mathbf{Y}[f]$: $$\begin{align*} \mathbf{...


Only top voted, non community-wiki answers of a minimum length are eligible