[sdiy] Digital accumulator VCO core?
Richie Burnett
rburnett at richieburnett.co.uk
Mon Feb 15 13:06:52 CET 2021
> If you do a polyblep you correct the sample just before and just after the
> transition to "blend" the fractional-sample-position step into whole
> samples, but I don't get what the curve is supposed to be or how you
> design it.
Ok, here goes... (See attached JPG image.)
1. Start with a raw impulse (A).
2. Pass this through a boxcar FIR filter to get a band-limited impulse (B).
3. Pass this through the same boxcar filter again to get an even more
band-limited impulse (C).
4. Now integrate this band-limited impulse to get a band-limited step (D).
5. Finally subtract a naive step from the band-limited step to get (E).
(E) is the correction that you apply around each step in the waveform you're
generating. You pick your points from the two regions between the green
lines depending on the fractional-sample offset of the reset instant in the
saw waveform. These are the modifications to apply to the naive sawtooth
waveform samples just before and just after the discontinuity. (Both curve
sections are fundamentally x^2 in shape. But one segment is inverted and
reversed. You can see that they come from integrating the triangle waveform
C).
So why did we do this?
The naive sawtooth waveform has an instantaneous reset, that happens
somewhere between samples. It is a pure step shape and is what we would
have got if we had just integrated the raw impulse (A). This aliases
horrendously because the impulse (A) has an infinite spectrum, and so does
it's integral, the pure step. So a naive sawtooth waveform aliases because
it's step discontinuity isn't band-limited at all. All of it's harmonics
above the Nyquist frequency folder over and over into the audio band.
Now if we band-limit the impulse a bit before we integrate it to form a
step, it will alias less. A boxcar filter is a pretty crude low-pass filter
(it has pass-band droop, a sloppy transition band, and ripples in the
stop-band), but it has one thing going for it... It is mathematically dead
simple! We could have stopped after low-pass filtering the impulse once to
get (B), then integrated that to get a band-limited step. What you'd get
would have been a linear ramp instead of an instantaneous step. This is
better than doing nothing, and equates to modifying one sample at each
discontinuity. However, one pass through a boxcar IIR filter isn't a great
lowpass filter, and we can easily do better than that.
So instead, we low-pass filter the impulse by shoving it through the boxcar
low-pass filter a couple of times, then integrate it to get a nice smooth
band-limited step (D.)
It's possible to use any filter you want, and pass the impulse through it
more times. The math just gets harder! And the polynomials for the
corrections to apply to each sample become longer. But you can see that the
example I gave results in simple quadratic functions to modify one sample
either side of the step discontinuity.
It's interesting to note that if we had used just one boxcar filtering step,
then integrated to get a ramp transition rather than a step, this isn't too
far away from how a real analogue sawtooth oscillator resets by discharging
it's integrator capacitor over a finite time period. However, this doesn't
give much band-limiting to guard against aliasing. Although there is now no
step discontinuity (it ramps linearly) at the reset instant, there is still
a discontinuity in the gradient! Two passes through the boxcar filter
results in a nice smooth S-shaped reset curve with both y and dy/dx being
continuous. There's still a discontinuity in the second derivative but
that's not nearly as bad.
I hope this helps explain polyBLEP a bit.
If you're dealing with triangle waveforms, you need to deal with
band-limited RAMPs as well as band-limited STEPs. You can see how that is
generated by stopping at the boxcar filtered impulse (B) and then
integrating it TWICE to get a band-limited ramp. Finally you subtract the
naive ramp from it to get the correction you need to apply around the
gradient changes in the naive triangle waveform. (It's possible to get away
with just one pass through the boxcar filter for triangle waveforms because
their spectrum rolls off much faster than saw and square, and aliasing isn't
such a big problem.) Is anyone actually still following this!?!?
-Richie,
--
This email has been checked for viruses by AVG.
https://www.avg.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: polyBLEP.jpg
Type: image/jpeg
Size: 38254 bytes
Desc: not available
URL: <http://synth-diy.org/pipermail/synth-diy/attachments/20210215/bc2aa090/attachment.jpg>
More information about the Synth-diy
mailing list