I need to compute an evarage of an analog input sampled by a ADC The evarage is defined for several positive peaks sum, devided in the number of peaks so it changes all the time.
I need this for an audio effect design. The main problem is how to exactly "catch" the peak sample that is closest to the real positive peak in the input volatage sampled .
How do I do that what is the algorythm in simple words ?
Thanks BarNash
Didn't find your answer? Ask the community — no account required.
P
Paul Keinanen
The brute force method is to use a sufficiently high sampling rate and pick the highest sample value :-)
With say 384 kHz sampling rate and 20 kHz audio tone, the sample point will be less than 21 degrees from the true peak (i.e. less than 7 % from the true peak value for 20 kHz and much less for lower frequencies).
When working with existing samples e.g. at 48 kHz, just upsample to e.g. 384 kHz (by using the real sample as every 1/8th new sample and the intermediate new samples set to 0 and then FIR low pass filtering at 20 kHz) to get a smooth waveform and pick the maximum from there.
If the original signal is noise free an other method would be to look at the rate of change between samples. The rate of change between adjacent real samples is positive before the positive peak and negative after the peak, so clearly, the peak must be close to the point when the rate of change had a sign change from positive and negative.
By extrapolating both slopes across the sign change area and look where the lines intersect, it should be possible to predict _when_ exactly between two real samples the peak occurred and from there calculate the peak amplitude.
A waveform containing strong harmonics may have several false peaks and noisy samples will make it hard to determine the rate of change. Paul
Naw. Trapezoid interpolation is far better and easier to implement, and Simpson's rule will do better still and is easier to implement than the FIR filter.
=46or simple waveforms maybe.
And ratty zero crossing times for resetting the peak detectors.
Did this all in a handful of TTL some 25 years ago.
Join the Discussion
Have something to add? Share your thoughts — no account required.
Didn't find your answer?
Ask the community — no account required
Report Content
You are reporting this content to the moderators. They will look at it
ASAP.