People who code: we want your input. Take the Survey
18

All three transforms are inner product transforms, meaning the output is the inner product of a family of basis functions with a signal. The parametrization and form of the basis functions determine the properties of the transforms.The number of basis functions for a complete picture (i.e. a result that contains enough information to reconstruct the original ...


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


7

Please refer to this paper on the optimum overlap percentage for the Blackman-Harris window, which is derived to be 66.1%. It has a lot of useful information on spectral analysis and windows.


7

We always want to apply some kind of a window function in order to minimize the effect of leakage. This makes rectangular window (lack of any windowing) case never used, this is why: Any tapering function used is almost always decreasing to zero at boundaries. This is why we are losing some data. In order to retrieve that somehow you will usually do 50% of ...


6

The first-order difference operation is a technique for numerical differentiation. It is the simplest method that I know of, and consists of just treating a discrete-time signal as piecewise linear between each pair of points and calculating the slope between them. The idea is that this time series of slopes should approximate the time derivative of the ...


5

This is a rather general answer : I would say that, although each window function has specific characteristics that make it more or less suitable for specific situations, in this context you're not going to see a huge difference in the STFT of a windowed speech signal. In particular, the two windows that you're comparing are quite similar, so I'd expect ...


5

I am going to break down this answer into two main parts, one for a step-by-step computation of the STFT, and the other in regards to how to compute the MFCC's, once you have the STFT. STFT: Let us say you wanted to compute the STFT of your signal $x[n]$, of total length $N=100$, and block size $M = 10$, with $50$% overlap, and using a hamming window. I ...


5

You don't HAVE to zero pad, ever, unless there are constraints on the length of data required by the FFT algorithm - often it's a case of speed. Many FFT's (like the Numerical Recipes code) require a power-of-two length series, some (like Kiss-FFT) only require it to be an even number, but being a multiple of 2,3 and 5 makes it run much faster. In Matlab'...


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

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'm wondering why the STFT pops out. To me, wouldn't a simple threshold on the signal itself or on its envelope do better / just as well, after removal of the g offset? Once you decide what "measure" is best to detect your event, you can apply the work of Basseville and Nikiforov, that I answered here. The classic reference for that problem is ...


5

If this graphics represents the most typical application scenario, then I would go for some simple short window variance estimation and perform thresholding afterwards; $$ \sigma_x^2 = \frac{1}{N} \sum_{n=0}^{N-1} x_{ac}[n]^2$$ Where $x_{ac}[n]$ is the DC removed input signal; i.e., $x_{ac}[n] = x[n] - \bar{x}[n]$ where $\bar{x}[n]$ is the DC (mean) value ...


5

I did answer a similar question a few years back, but can't find it. Basically, you are losing the energy because of the windowing. It's true to say that you should multiply the spectra by 2 in order to retrieve the energy from negative frequencies and divide it by the window size. However, this is only true for the rectangular window. The correct ...


4

The short-time Fourier transform is generally a redundant transformation, usually implemented with the same subsampling over every frequency. If the window is well chosen, it is complete: you can invert it and recover any initial signal. Since it is redundant and complete, it has many perfect inverses. It can be implemented and understood using more ...


4

Edit: I have recently created two Jupyter Notebooks that illustrate this behaviour and let you play around with some actual matrices and actual signals. I find understanding MDCT easiest if we define our transforms as matrix operations. DFT In case of a DFT such a matrix would look like $$ F_M = \left( \sqrt{\frac{1}{M}} e^{-2 \pi i k n / M} \right)_{k,n=...


4

A vocoder is a type of synthesizer originally developed for speech (or the human voice, thus the "vo" prefix), even before the use of digital processors. The Bell Labs Voder was demonstrated in 1939, and VoCoders were reportedly used for encrypted voice communication during WW2 (according to Wikipedia). DFTs can be used to analyze which audio spectrum ...


4

The short-time Fourier transform (STFT) refers to the time-frequency representation of a signal, which is given by: $$X(\tau,\omega) = \int_{-\infty}^{\infty}x(t)w(t-\tau)e^{-j\omega t} \, dt$$ which is equivalent to: $$ x(t)w(t-\tau) = \tfrac{1}{2\pi}\int_{-\infty}^{\infty} X(\tau,\omega) e^{+j\omega t} \, d \omega $$ If the window is scaled so that: $$...


4

The default parameters of signal.spectrogram are: nperseg = 256 noverlap = nperseg/8 = 32 This means that: The length of analysis window is $256$ samples ($256/250 = 1.024$ second) The overlap between consecutive windows is $32$ samples ($32/250 = 0.128$ second) The timestamps returned by signal.spectrogram correspond to the centres of a window. So in ...


4

A widnow $w[n]$ truncates and weights (tapers) an input signal $x[n]$, to produce $v[n] = x[n]. w[n]$., for subsequent spectral analysis of $x[n]$. A windows's effect on the input signal's true spectrum $X(e^{j\omega})$ is described by a convolution of $X(e^{j\omega})$ with $W(e^{j\omega})$ (window's Fourier transform); $$V(e^{j\omega}) = \frac{1}{2\pi} \...


4

In Chapter 2.4 Previous Work of The Short Time Fourier Transform and Local Signals, S. Okamura, 2011, one reads: The STFT is also known under many names such as the windowed Fourier Transform, the Gabor transform, and the local Fourier transform. Later, one discovers that the definition may slightly vary with different authors, but, at first glance, ...


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

With all due caution, no in both cases (title and body question). I'll start with the second one. Continuous wavelets use all dilations of the mother wavelet, which are not accessed with the STFT The STFT is complex in general, and the windowed sine is not. For the first one: I never tried it, and do not remember having seen it in use, and one should ...


3

True, the complexity would be $O(N \log N)$. But this $\log N$ captures a different reality from the $\log N$ in the FFT algorithm. In your case it comes from the fact that you're only interested in a smaller set of logarithmic spaced frequencies. In the FFT case, it comes from the "divide and conquer", recursive structure of the Cooley–Tukey algorithm. ...


3

What you describe might be similar to applying a Constant-Q transform using Morlet or Gabor wavelets. These transforms may have a higher computational cost than using windowed FFTs, but may, when scaled suitably, represent something closer to human perceptual resolutions for both frequency and time.


3

I tried my best but I couldn't find a resource that would list the "good" overlap factors for common and less common windows. Here's a list of window functions and overlap factors that have constant overlap-add (COLA). (Code here) Heinzel - Spectrum and spectral density estimation... shows several windows and lists their "optimum overlap" and their "...


3

The reason you need overlap add / overlap save for filtering with the short time Fourier transform is basically, that the basis functions associated with the coefficients that you get are are defined over a certain time range (as opposed to a single point in time). The Fourier transform you use to calculate the expansion coefficients also implements ...


3

First of all, what do you mean when you say "Taken the first half of the resulting matrix (n/2+1)"? The FFT will result in a vector, but maybe you mean taking only the first half of the FFT samples because the others are the negative frequencies and hence redundant? Anyway, the process you describe is actually correct, and there is no need to do anything ...


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

The continuous Fourier transform possesses symmetries when computed on real signals (Hermitian symmetry). The discrete version, an FFT (of even length) possesses a slighty twisted symmetry. The DC coefficient ($F(0)$) is real, as well as the Nyquist one ($F(N/2)$). In between, you get $\frac{2048-2}{2}=1023$ "complex" coefficients, "duplicated" in ...


3

This is more like an extended comment to chart the possible answers. Hilbert transform is a frequency domain 90-degree phase shift of the signal. It has an antisymmetrical impulse response around time = 0. You specify that the approximation shall be causal (EDIT: this requirement has since been removed), so I think you need to reference the phase shift to ...


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