37

There's a flaw in Jason R's answer, which is discussed in Knuth's "Art of Computer Programming" vol. 2. The problem comes if you have a standard deviation which is a small fraction of the mean: the calculation of E(x^2) - (E(x)^2) suffers from severe sensitivity to floating point rounding errors. You can even try this yourself in a Python script: ofs = 1e9 ...


9

The classic reference for this problem is Detection of Abrupt Changes - Theory and Application by Basseville and Nikiforov. The whole book is available as a PDF download. My recommendation is that you read Chapter 2.2 on the CUSUM (cumulative sum) algorithm.


8

Real-time low-latency partitioned convolution reverb with a long impulse response works by dividing the impulse response into unequally sized partitions. The shortest partitions (blocks) are at the beginning of the impulse response, and the partition length grows towards the end of the impulse response: Each partition length can be processed separately, ...


6

Nvidia seems to have published some white papers comparing DNN inference performance between high-powered CPUs and (of course) Nvidia GPUs. (one example) Ballpark seems to be that some systems can meet or exceed typical video frame rate thru-put for some class of DNN classification tasks. Whether those image sizes and/or DNN architectures and ...


6

Your original differentiator, which should be $x(n)-x(n-1)$, is called a "first difference" differentiator. That differentiator amplifies high-frequency noise. As a next step I suggest you try what's called the "central difference" differentiator defined by: $$ \mathit{Diff} = \frac{x(n)-x(n-2)}{2} $$ which does not amplify high-frequency noise.


5

It comes down to latency vs. complexity. If your filter is 10 seconds long, you need to store the audio data of the last ten seconds and then you are able to calculate the current output audio sample with a latency of basically zero (ignoring the time required for calculations here) simply by doing: $$y[0] = \sum_{k=0}^{l} x[-k] \dot h[k]$$ where $l$ is ...


5

Try something like this: $\begin{eqnarray} \mu(n) &=& (1 - \alpha_1) \mu(n) + \alpha_1 x(n) \\ \bar{x}(n) &=& x(n) - \mu(n) \\ s(n) &=& (1 - \alpha_2) s(n) + \alpha_2 \bar{x}(n)^2 \\ \sigma(n) &=& \sqrt{s(n)} \\ \end{eqnarray}$ This is equivalent to sending your input signal to a 1-pole DC blocking high-pass filter with a ...


5

A more principled way of solving this problem is to apply signal detection theory (a.k.a hypothesis testing). I will outline here an easier case where we are trying to decide if the data has a positive slope trend vs. no trend. Setting up the hypotheses, $$ H_0: y(n) = w(n) $$ $$ H_1: y(n) = A n + w(n), \; \; A>0. $$ Here $\{y(n)\}_{n=0}^{24}$ is the ...


5

Depending on the level of noise you expect to encounter on your signal, you might actually be able to use the finite differencing you suggest, originally. If you want to know the general trend of your data upward or downward, sum together the, in your case, 24, differences. So, lets say that you have some metric, $D$, for your signal. Lets say that for a ...


5

As I commented on a previous post, the time-frequency analysis method known as "short term Fourier transform" $X$ is equivalent to a filter bank, analysing your signal $x$. For a given analysis window $w_n$, of size $N$, the filter at frequency $k/N$ is : $$ h_n=w_{−n}e^{j2\pi\frac{nk}{N}}$$ For usual analysis windows (Hann, Hamming, or even rectangle), ...


5

First, with the classic short-term Fourier transform approach, there are alternative to interpolation - in particular techniques making use of phase information to recover the instantaneous frequency (See this question) which can give you very accurately the position of a spectral peak without an increase of FFT size. The drawback, as you correctly said, is ...


5

You are confusing "processing time" with "latency". Real-time filters are able to generate output samples at the same rate as they receive inputs. They would however induce latency, meaning that the bulk of the energy generated for an input appears later in time with respect to that input. Consider for example the following input/output: time : 0 1 2 3 4 ...


5

Do I have to filter the whole (or at least a huge bit) of the signal every time a few new samples came in or is there a way (like the sliding DFT) where it is possible to efficiently determine the new part of the filtered signal? Digital filters don't work like that -- basically, classical FIR or IIR can work on every single new sample. You should really ...


4

For an EEG signal, I suppose you need to keep the shape of the signal. Therefore the filter should have linear phase, so the reasonable way to go is a FIR filter. If shape (transients) don't matter much for your application, then an IIR filter would be preferable since it will give less end-to-end delay in general. Note that suprressing 0 - 1 Hz, ...


4

Frequency or pitch? There are already tons of research papers and books on human pitch perception. But, IIRC, humans tend to be bad at accurately "extracting" frequencies unless they happen to be a pitch fundamental. And multiple frequency peaks within a "critical band" tend to be perceived as noise. So any method with "near human accuracy" may also have ...


4

Jason and Nibot's answer differ in one important aspect: Jason's method calculates the std dev and mean for the the whole signal (since y = 0), while Nibot's is a "running" calculation, i.e. it weighs more recent samples stronger than samples from the distant past. Since the application seems to require std dev and mean as a function of time, Nibot's ...


4

I usually frame this problem as one of slope detection. If you compute a linear regression over a moving window, the illustrated drop will be visible as a significant change in slope sign and/or magnitude. This approach offers are a number of factors that will require "tuning": for example, the sampling frequency, the window size, etc, will affect the ...


4

To add to jan's answer: Most commercial reverb effects (plug ins or hardware) are NOT based on convolution with an impulse response but are based parametric algorithms in some network configuration. This has a bunch of advantages: Less memory Less MIPS It's parametric, so different parameters like "room size", "reverb time" , "color", etc. can be adjusted ...


4

I think that, especially in the context of real-time DSP the terms are really talking about the same topic. Perhaps the most general Wikipedia reference about buffers would include both first-in-first-out (FIFO) and last-in-first-out (LIFO) but a LIFO buffer is usually called a "stack". If it's a FIFO buffer, we usually call it a "queue" and, particularly ...


4

In a 2003 paper in French, "Estimation par maximum de vraisemblance de la dérivée d’un signal bruité. Application à la caractérisation de vérins pneumatiques" (Maximum likelihood estimation of the derivative of a noisy signal. Application to the characterization of pneumatic cylinders) [from the early GRETSI french-speaking conference on signal and image ...


3

Questions: First, am I right in my assumption that by keeping 12 bits for as long as I can, I'll get better results? Yes, you are correct. Second, is there a smarter way of turning those 12 bits into 8 bits than just shifting everything to the right four times? Sometimes. Signed shifting to the right four times is the safest way to go, because you are ...


3

The first thing I would enjoin you to do is to measure the actual accuracy of your ADC. The 12-bit performance announced by the manufacturer can often be reached only in ideal conditions, such as: Using an external precision voltage reference rather than the built-in one. Using a distinct power supply for the analog section of the MCU. Using all the ...


3

Once you get the basics covered (Jason has covered this pretty well), you will also want to research Integral Windup and filtering of the error signal and its estimated derivative. The former is very important if your control point changes discontinuously (i.e. you don't have a separate controller 'ramping' the control signal for your PID.) The latter is ...


3

Similar to the preferred answer above (Jason S.), and also derived from the formula taken from Knut (Vol.2, p 232), one can also derive a formula to replace a value, i.e. remove and add a value in one step. According to my tests, replace delivers better precision than the two-step remove/add version. The code below is in Java, mean and s get updated ("...


3

Cross correlation should work. I think the problem is the waveform that you are using. A square wave has bad auto-correlation properties. If it is a periodic square wave it will have multiple peaks. It sounds like you are just using a single pulse which is better, but it will still have a gradual roll-off which is a problem. Instead, use a Barker code, ...


3

'Real time' is a concept from computer engineering. A real time system is one that is guaranteed, by design, to execute a function or routine in a certain time T, or less. For example, a real-time avionics system is proven to react to signals coming from certain instruments in a time below a given threshold. In your case, a more precise description (IMHO) ...


3

I'm sure you can implement a simple fuzz or overdrive effect on that board. Apply asymmetrical clipping to you your data, and filter the result with a biquad IIR filter. You'll need a lowpass filter to smooth out some of the nasty high frequencies after clipping (try a cut-off frequency $f_c\in [4..7]$kHz), and you might want a parametric EQ to boost some ...


3

The fact is that if $x(t)$ is real and then $X(-j\omega) = X^*(j\omega)$ (it's easy to prove) and, because of duality, if $X(j\omega)$ is real, so also then $x(-t) = x^*(t)$. in your case, you have both $x(t)$ and $X(j\omega)$ being real. keep in mind that anything that is purely real is also equal to its complex conjugate. so you can say: "if $x(t)$ is ...


3

If the spectrum of your I/Q samples is centered at zero then you'll have to perform either AM or FM demodulation before routing any real-valued audio samples to a sound card. For AM demodulation you'll need to implement a complex-input "envelope detector" which produces a real-valued audio signal riding on a DC bias. (In a few days check the web page: www....


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