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

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


6

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


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

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

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

See the MATLAB documentation: s = spectrogram(x) returns the short-time Fourier transform of the input signal, x. Each column of s contains an estimate of the short-term, time-localized frequency content of x. Namely each column of the matrix s is the result of an fft() on some samples of the input. So the plot you see is the magnitude of the columns of s. ...


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

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

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

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


4

I have derived the DFT for data whihc is sampled in a non uniform manner: The DFT Matrix for Non Uniform Time Samples Series Problem Statement We have a signal $ x \left( t \right) $ defined on the interval $ \left[ {T}_{1}, {T}_{2} \right] $. Assume we have $ N $ samples of it given by $ \left\{ x \left( {t}_{i} \right) \right\}_{i = 0}^{N - 1} $. The ...


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

Nowadays the easiest thing would be to use librosa for this task. It has the mel_to_stft function which does exactly what you want. As others have mentioned, this reconstruction is lossy and only approximate solution can be found. In librosa it is done using the Non-negative Lease Squares algorithm. A thing to keep in your mind: if you have extracted the ...


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{...


3

The sharp rectangular shape of the spectrum, with the immensely flat top definitely says "OFDM, with suitable whitening/PAPR reduction"; what constellation is used on the individual carriers is a bit hard to tell. Can you, with a no-samples-left-out spectrogram (e.g. gr-fosphor sink, or by playing back your recorded file slower and using a suitably high ...


3

Some details to Jojek's post. Shared here for future reference. The key is to take the window in consideration and taking a reference ref which corresponds to 0dBFS. import numpy as np import matplotlib.pyplot as plt import scipy.io.wavfile as wf fs, signal = wf.read('Sine_440hz_0dB_10seconds_44.1khz_16bit_mono.wav') # Load the file ref = 32768 # 0 dBFS ...


3

So, first of all, CSV seems to me the least suitable format imaginable for this amount of data. It needs to be parsed, is memory hungry, and wastes precision, and isn't linearly addressable (ie. to get to the 99999. element, you need to parse the preceeding 99998 elements). So I'd recommend keeping the structure from these files, but converting them to ...


3

Concerning the comment from Juancho, we can assume that the time is normalized to e.g. 1s, meaning that $t=1$ corresponds to $1s$. Then, we dont have a problem with the units (this a very common operation and not specific to your problem). Now, regarding the "instantaneous frequency" (also check Wikipedia and another question on math.se), it is not ...


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