[sdiy] Digital accumulator VCO core?

Tom Wiltshire tom at electricdruid.net
Mon Feb 15 20:09:56 CET 2021


It’s all absolutely an approximation.

In theory you need a perfect digital filter, which is a sinc curve which goes off to infinity both *before* and *after* the reset edge event that we’re trying to correct. This is the ”harder maths” he mentions - infinity is always a bit of drag, wherever it crops up!

Of course, in practice, nothing half so serious is *actually* required, and you can do well with “windowed sinc” filters of various types or even simpler things like Richie proposes. These can provide very decent performance for very little overhead.

==================
       Electric Druid
Synth & Stompbox DIY
==================



> On 15 Feb 2021, at 18:36, cheater cheater <cheater00social at gmail.com> wrote:
> 
>> 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.
> 
> Am I right to think that this is an approximation? This looks like the
> linear component of some larger formula than that. What are the next
> terms? What is the general formula?
> 
>> 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.
> 
> Am I right to think that if you pass this through a high pass filter
> multiple times, you will recover the aliases? In digital a synthesizer
> with multiple high pass filters, do we need to do "a better job" of
> band limiting this? I understand in an analog synthesizer, after
> you're done outputting this to analog audio, any aliases might be lost
> in the noise, but I'm not convinced that they will be _unrecoverable_.
> 
> On a separate note, has anyone come across something that's like a
> spectral "gate"? like a normal time-domain noise gate, but for each
> frequency separately: i.e. a frequency will pass through only if it's
> above a certain threshold.
> 
> Cheers
> 
> 
> On Mon, Feb 15, 2021 at 1:11 PM Richie Burnett
> <rburnett at richieburnett.co.uk> wrote:
>> 
>>> 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
>> _______________________________________________
>> Synth-diy mailing list
>> Synth-diy at synth-diy.org
>> http://synth-diy.org/mailman/listinfo/synth-diy
>> Selling or trading? Use marketplace at synth-diy.org
> _______________________________________________
> Synth-diy mailing list
> Synth-diy at synth-diy.org
> http://synth-diy.org/mailman/listinfo/synth-diy
> Selling or trading? Use marketplace at synth-diy.org





More information about the Synth-diy mailing list