36

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


13

What would be the ideal way to find the mean and standard deviation of a signal for a real time application. I'd like to be able to trigger a controller when a signal was more than 3 standard deviation off of the mean for a certain amount of time. The right approach in situations like this is typically to compute an exponentially weighted running ...


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.


9

if you need to keep jitter (assuming that's what you mean by "wiggle" :) down to <1ms I'd say forget Windows. Does the absolute latency from input to output matter, or is it just the jitter? You might manage it some of the time, but guaranteeing it is unlikely. What's the penalty for failing to meet the deadline? Will it blow up speakers? Drive a ...


7

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


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

A method I've used before in an embedded processing application is to maintain accumulators of the sum and sum-of-squares of the signal of interest: $$ A_{x,i} = \sum_{k=0}^{i}x[k] = A_{x,i-1} + x[i], A_{x,-1} = 0 $$ $$ A_{x^2,i} = \sum_{k=0}^{i}x^2[k] = A_{x^2,i-1} + x^2[i], A_{x^2,-1} = 0 $$ Also, keep track of the current time instant $i$ in the ...


5

Whether this is possible or not depends on your latency requirements, i.e. the total delay between input and output. A good starting point could be setting up a digital audio workstation using recording software such as ProTools, Sonar, Ableton, Cubase etc. These work with inexpensive (sort of) I/O hardware and come with low latency optimized drivers. Some ...


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

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

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

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

Windows is not real time OS, so well, you don't have true realtime processing capabilities in Windows. With Windows Vista, Microsoft offered a new API that among other thing targeted strict performance, where Exclusive-Mode Streams promised performance close to real-time. This is achieved with a few powerful things working together, including short and ...


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

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

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

papers? why not books Golub, Gene H., and Charles F. Van Loan. Matrix computations. Vol. 3. JHU Press, 2012. and if you need something more basic like understanding the difference between the Holder p-norm of a matrix and the Frobenious norm. Stewart, Gilbert W. Introduction to matrix computations. Elsevier, 1973. Although there are probably some ...


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

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


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


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