[sdiy] VU meter algorithms

Richie Burnett rburnett at richieburnett.co.uk
Mon Mar 18 20:15:31 CET 2019

Exactly...  The Nyquist Shannon Sampling Theorem says that twice the 
bandwidth is sufficient to *reconstruct* the original band-limited 
continuous-time signal.  But it says nothing about how much processing is 
required to get back to the continuous-time signal, or determining various 
metrics about that signal like peak amplitude.  So if peaks occur between 
the samples, (which is almost guaranteed to happen because why would the 
peaks in the audio signal decide to line up with regular samples) then you 
will always under-estimate the peak amplitude.  As you said at the Nyquist 
frequency your peak amplitude measurement could under-estimate by up to 100% 
depending on the relative phase of the signal being sampled.  So if you 
don't want to drastically under-estimate the peak amplitude of 
high-frequency signals you are either going to need to sample the analogue 
signal at a much higher sample rate _OR_ up-sample (interpolate) the data 
that you have to find the inter-sample peaks.

The LED display update rate (largely determined by human persistence of 
vision) and the audio sample-rate are un-related in my opinion.  So you can 
freely choose both of them in order to satisfy each ones requirements.

After trying to design a high-speed precision analogue rectifier recently, 
(and even after pinching every neat idea on Rod Elliot's site about 
precision absolute value circuits,) I would have to say that this is one of 
the rare instances where I would disagree with Scott G.  In my opinion it's 
easier to rectify signals in the digital domain where mathematical 
operations are perfect, and not plagued by diode voltage drops, 
non-linearities and op-amp slew rates!

Tom, what do you actually want your "VU meter" LED bargraph to tell you Tom? 
Is it:

1. A visual indication of perceived volume.
2. An indication of the peak level of the continuous-time analogue input 
3. An indication of whether your ADC clipped.

The first option (1) has loads of options for different "ballistics" using 
various attack and release times and is what I believe an original VU meter 
was designed to show.  You can play about with all sorts of options like RMS 
smoothing, A-weighting, etc, and this is the sort of thing that the BBC uses 
to match the perceived volume of various different programme material being 

The second and third options are peak reading meters, but are subtly 
different.  Number 3 doesn't care about inter-sample overs because if they 
didn't occur at a sampling instant then they didn't cause clipping, and 
won't cause clipping unless you do some subsequent interpolation, phase 
shifting or filtering.  Number 2 does care about peaks that occur between 
samples, and needs to use some sort of interpolation to estimate 
inter-sample levels and indicate them accordingly.

One popular digital level meter option seems to be to use a bargraph with 
some attack/decay time-constants chosen to give it a nice feel, along with a 
clipping LED at the top that latches on for a couple of seconds if the peak 
level reaches 0dB relative to full-scale.

Hope this is helpful,


-----Original Message----- 
From: Tom Wiltshire
Sent: Monday, March 18, 2019 5:33 PM
To: rburnett at richieburnett.co.uk Burnett
Subject: Re: [sdiy] VU meter algorithms

Well, quite.

The short answer is “far higher than any reasonable LED update rate”.

If we assume 20KHz as the highest input frequency, then obviously my 40KHz 
sample rate is inadequate because we might sample at the zero crossings each 
time. Updating the LEDs at 100Hz would be more than enough (flicker at that 
speed is already perceived as “variable brightness”) but such a rate is 
hopeless as a sample rate.

But it’s worth pointing out that we’re trying to imitate something that was 
originally done with moving coil meters and which had quite considerable lag 
(300msecs attack and decay from what I can find out). So how hard can it 

> On 18 Mar 2019, at 15:38, rburnett at richieburnett.co.uk wrote:
> Ahhh, but how high a sample rate do you need to use to be sure that you 
> take a sample at the peak of a waveform!?!?!?  ;-)
> -Richie,
> On 2019-03-18 15:25, Tom Wiltshire wrote:
>> Hi all,
>> Does anyone know of any good resources on bargraph VU meter
>> algorithms, and specifically implementing a “Peak hold” feature?
>> I’m trying to write one - well, I *have* written one - but I’m not
>> overly impressed with its performance. The “VU meter” portion of the
>> code is pretty good: I sample the audio at 40KHz, then rectify it,
>> take the highest sample in a block of 16, and then apply an IIR
>> smoothing filter with a time constant of about 200msecs. That part
>> seems pretty good, although it “under reads” significantly.
>> I’m having worse problems with the Peak Hold dot. This has an attack
>> of zero (so it never misses a peak) but uses a longer decay time of
>> 400msecs or so. But a typical input signal tends to make it jump
>> about, so instead of clearly lighting a single LED, it instead lights
>> two or three intermittently. This makes the display rather confusing
>> to look at.
>> I’d thought to just get stuck in and see how it went (and it went ok)
>> but I think now might be a good time for a bit of research. This is a
>> solved problem, so someone must have dealt with these issues before
>> me.
>> Thanks,
>> Tom
>> _______________________________________________
>> Synth-diy mailing list
>> Synth-diy at synth-diy.org
>> http://synth-diy.org/mailman/listinfo/synth-diy

Synth-diy mailing list
Synth-diy at synth-diy.org

This email has been checked for viruses by AVG.

More information about the Synth-diy mailing list