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

# Tag Info

7

Yes, Butterworth are IIR. The decay from an impulse technically lasts forever. Yes, all [implementable] IIR are causal. Yes, because of #1 and #2. Don't use signal.filtfilt. Use signal.lfilter. filtfilt does the same thing as lfilter, except twice, in opposite directions, which changes a causal filter into a zero-phase filter. However, as the ...

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

A simple approach would be to implement a filter using scipy.signal.lfilter, where plenty of documentation exists in python on how to use that function. To do this effectively you need to first define the signal bandwidth of interest relative to the sampling rate. As long as the sampling rate is sufficiently more than twice the bandwidth, there will be an ...

4

In order to resample without aliasing, the resampling process needs to apply an anti aliasing filter at the new Nyquist Frequency (or thereabouts). So chances are, your resampling process applied a low pass filter at 256 Hz or so and that removed A LOT of the energy.

4

You don't want np.ones_like(num) in the denominator. That's making a denominator of all ones, with lots of possibly unstable poles. Your denominator in Python needs to be [1,0,0,0,0,0,...]. Or just [1] if possible.

4

As mentioned in the comments you can just take the integral of the squared magnitude. Notice that the magnitude of $|e^{a+bj}| = |e^a||e^{bj}| = e^a$ for $a,b \in \mathbb{R}$, comparing with your function we see that $|x_i(t)|=1$. We conclude that $x_i(t)$ is a power signal, not an energy signal, i.e. you must define a time interval to integrate. Then the ...

3

The book is not wrong, but it does present the concepts on LFM in a clunky manner and can be misleading. The book presents the analytical expression for the LFM spectrum, which is an approximation. It also plays with the plot views and most likely unwraps the phase angles, which is usually required to see the phases you expect. Usually when you're ...

3

Parseval's identity and Plancherel's theorem finally boil down to orthogonality. When one decomposes a data (with samples), via a scalar product, onto an orthogonal sequence (yielding coefficients), there exists a certain preservation (equality, up to a proportionality factor) of energy between samples and coefficients. There are some technical conditions, ...

3

Let's follow the math from incubation to delivery. It begins with psi, a rescaled morlet2 (as shown previously) at a scale $a=64$, and $\sigma=5$: $$\psi = \psi_{\sigma}(t/a) = e^{j\sigma (t/a)} e^{-(t/a)^2/2} \tag{2}$$ gets integrated and L1-normalized: -- (see caveat2 below) $$\psi = \psi_{\text{int}}(t) = \frac{1}{a} \int \psi_{\sigma}(t/a)\ dt \tag{3} ... 3 Median filtering is non-linear, and pretty awesome about removing outliers. You just need to adjust the length of the filter based on the estimate of the frequency of the errored samples. 3 As you can see, the second measurement of 358 is an erroneous measurement. Why would that be erroneous? Phase is periodic with 2\pi or 360 degrees. That means 358 degrees is the same angle as -2 degrees. Your data looks perfectly fine if you look at it as 2, -2, 3, 5, 10, 18 , ... What you probably need is phase "unwrapping". If you see a ... 3 From the information you've given, I'd use spectrogram A as the frequency data is spaced logarithmically. This is advantageous for pitch detection applications as it gives you a greater amount of resolution around the fundamental frequencies. 3 There are a few things going on: The complex representation of frequency is such that the real part corresponds to a cosine component and the imaginary part to a sine component. So a complex phase of 0 corresponds to a cosine wave, not a sine wave. This is why the computed phases are off by about 90 degrees from what you expect, according to the trig ... 3 Couple of things: You really can't print to the console in a high-speed context, especially not in audio callback functions. That printing has side effects, and it's slower than you think, I promise. This alone breaks "real-timedness": You can never guarantee how fast your printing is (or isn't). Ahhhh! You're re-designing the filter for every ... 3 Your Python code has two weak spots, rather typos, but these are not the source of your failure to "show a plateau" in PSD graph. First we review these "typos". The line f, check = welch(Const_wave,samplerate,nperseg=len(Wave)) must read f, check = welch(Const_wave,samplerate,nperseg=len(Const_wave)) or else, the variable Const_wave ... 2 I will use Wikipedia notations - Kalman Filter. In most models the state transition model matrix  F  depends on the interval parameter  T . The same goes for the Process Noise Covarinace Matrix  Q . For instance, for the constant velocity model:$$ F = \begin{bmatrix} 1 & T \\ 0 & 1 \end{bmatrix}, \; Q = \begin{bmatrix} \frac{ {T}^4 }{4} & ...

2

I believe you're correct, it's an issue with the overlap-add process. The code doesn't correctly calculate the triangular windows for lower pitches. In short, the windows are too big. It produces incorrect results for any pitch ratio below 1, such as 0.5 (one octave down). The diagram below explains the issue as I understand it: The big windows introduce so ...

2

FIR filter with impulse response $h[n] = {-\frac{1}{2}, \frac{1}{2}}$ means that : $$y[n] = \frac{1}{2}x[n-1] - \frac{1}{2}x[n]$$ This is in some sense a mirror operation of Moving Average of two samples. This is Moving Difference (samples reversed). A High Pass Filter. So, each output sample is the difference of current input sample with previous input ...

2

THe DWT does not really know about the actual sampling. It do cares about the relative frequency span. And it has not knowledge about pre-processing, like linear filtering. So in your case, the detail coefficients of the first level of wavelet coefficients correspond, more or less, to the [128/2-128]/2 frequency range. Because of the initial [0-30] low-pass ...

2

Based on the blog post - The Paint Bucket in Paint.Net 4.0 (Video) I can tell it uses some edge detection to handle similar colors within a piece wise smooth area. More information is given in the Paint Bucket Tool documentation. Usually the way it can be implemented is by defining color metric. How far a color is form another color. If it within the ...

2

If you think of the spectrograms as filter banks it might be easier to conceptualize. With a STFT, each bin in the bank has the same time/frequency resolution. With the Wavelet transform, the bins at lower frequencies have higher frequency resolution, which means they must also have lower time resolution. There is an inherent trade off between time and ...

2

All real-time filtering (as opposed to post processing) wirh FIR and IIR filters will have start up transitions based on the state of the filter at start up. For optimum rejection of AC noise , Instead of a Butterworth Filter consider using an 2nd order IIR notch filter with the notch set at your AC frequency (such as 50 Hz). A design for this is further ...

2

%matplotlib inline is a magic command for IPython that allows you to add plots to the browser interface. It's not for the the terminal. Sounds like you are using the Python interpreter at the command line, which isn't going to be useful for you as a beginner. Install jupyter notebook and use it instead of the command line interpreter to follow along with ...

2

If a first-order IIR will do, modify that slightly, and you're done. So the usual first-order low-pass filter can be defined as $y_n = h(\theta_n)$ such that $y_n = y_{n-1} + a(\theta_n - y_{n-1})$. This works great for $\theta_n \in \mathbb{R}$. You want a low-pass filter that's defined on an interval that spans $360^\circ$. For reasons that will become ...

2

A good way to deal with circular (directional) averages is to turn it into a vector average. To find the average angle $\bar{\theta}$ of several angles $\theta_n$ (in radians) then: $$\bar{\theta} = \arg \left ( \sum_{n=0}^{N-1} e^{i \theta_n} \right )$$ where $\arg$ is the argument (angle) of the resulting complex sum. There's some more stuff about this ...

2

As Marcus Müller said, there is an error, when converting abs and angle values back to complex numbers. It should be like this: \begin{align} x = |x|(\cos \phi + j \sin\phi) \end{align} Note, that the result convstft of this conversion will be close, but not equal to the original values in stftspectro, most probably, due to inaccuracy of floating point ...

2

This is probably the single most asked question on this forum. A similar one was asked and answered just a few hours ago: Spectral leakage from mathematical point of view Your expectations are wrong: you only get a spectral dirac impulse if the frequency of the complex exponential on he FFT grid, i.e. an integer multiple of the sample rate divided by the ...

2

A few suggestions: I would do all filter design with poles and zeros, NOT with filter coefficient Implement everything as second order sections, with one complex pole pair per section. The zeros of a Butterworth filter are constant: they are at $z = 1, z= -1$. You don't need to explicitly calculate the $b$ coefficients of your filter. It's always \$b = [1, 2 ...

2

Why do I have ringing and such an aggressive response? Because you designed a really aggressive filter, which is borderline unstable. All the poles are less than 1/1000 away from the unit circle. How does the low cut off frequency and high sample rate affect the filter response? The lower the cutoff, the higher the order, and the higher the sample rate, ...

2

If you add two cosines you simply get the product of the sum and difference frequencies. $$cos(x) + cos(y) = 2\cdot cos \left( \frac{x+y}{2} \right) \cdot cos \left( \frac{x-y}{2} \right)$$ If the frequencies are very close together, than the difference frequency is close to zero and that's what creates the "beat". The exact definition of what ...

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