Archive of the former Yahoo!Groups mailing list: Korg Poly800/EX800 Users

previous by date index next by date
previous in topic topic list  

Subject: Re: [korgpolyex] digital osc vs DCO

From: Gordonjcp <gordon@...>
Date: 2016-09-21

On Tue, Sep 20, 2016 at 08:58:49PM -0700, domgoold@... [korgpolyex] wrote:
> is 'blep' a term for bandlimiting?

It's a contraction of "BandLimited stEP".

If you have a discontinuity - a step - in your waveform, you have harmonics. Now if you just go from -1 to +1 you'll have an infinite amount of harmonics and at some point they will exceed the Nyquist frequency for your sample rate. Those harmonics will "fold over" and be present in the audio passband, and you'll get odd gurgling and clanging noises.

One way to avoid that would be to take the sum of sines for your harmonics, and stop when you're comfortably below Nyquist. That would work but be computationally expensive. What you'd find if you plotted a square wave generated with 1f(1) + .333f(3) + .2f(5) + .143f(7) + .111f(9) is that you'd have something that sure sounded square, looked roughly square but had little wobbly "overshoots" at the edges of the steps.

Fire up scipy/matplotlib/mathcad/whatever, don't just take my word for it.

Another way is to add a "minblep" which can be thought of as a "sample" of that wobbly overshoot (it's called the Gibbs Phenomenon) that you paste over a step in a naive waveform, which rounds off the corners and makes it seem like those high harmonics were never there.

One more way is a polyblep where you calculate something similar to a bicubic interpolation of the sample in between the sides of the discontinuity. Another way to think about the aliasing is that at certain frequencies with a fixed sample rate the discontinuity is going to fall "between" samples (I'll come to this in a second) so the polyblep calculates an in-between value. It's pretty much exactly like antialiasing graphics by drawing a slightly "blurred" pixel in a sharp corner.

> i've tried generating saws and squares as 'naive' waveforms,
> and it was ok but you do get aliasing on high notes in some
> situations. (is not too much of a problem?)
> supposedly you'd have progressive bandlimiting as pitch rises,
> is that it?

Basically this, yes. You're only knocking off the highest partials so they don't exceed half the sample rate.

For a squarewave at (say) a 32kHz sample rate, then at 110Hz (open A on a guitar) there would be almost no effect since there would be almost no harmonics above 16kHz. At high A, 7040Hz, your output waveform would be mostly just a sinewave since there would be ∗no∗ harmonics below 16kHz, and indeed the highest note with a harmonic would be up around E8, 5274Hz...

> i was suprised and a bit disappointed that DSP oscillators are
> often wavetables with (?look-up tables? i'm not a programmer)

What you have to do there is calculate a set of wavetables where as you go up the octaves the upper harmonics are removed. You can either do this with sampled waves, or you can do a whole bunch of FFT magic to create your tables just how you want them.

It's the table lookup that kind of becomes the problem, because that's why you get uneven sized "steps". Imagine you have a 256-byte sample that loops perfectly of a bandlimited waveform. You play it back at 32kHz and you get a 125Hz signal. How do you get 250Hz? Well, you could play it at 64kHz, or you could just play every second sample. Let's assume we're fixed at 32kHz so skipping samples it is.

How do you get 187.5Hz, half-way between? You can't play half a sample. You have to play two samples then skip one, then play two, then skip one, over and over. The way we do this is called a "phase accumulator".

If you had a 16-bit counter, you'd take the top 8 bits as the address into your sample, and if you added 256 to the counter every time you'd count up in ones, if you added 512 you'd count up in twos, and if you added 384 you'd count up one sample with 128 in the lower byte, then the next time you'd add 384 again and get 768 (that would be a 3 in the upper byte), then 384 again leaving 4 in the upper byte and 128 representing "half a sample" in the lower byte.

Practically you'd make the counter much longer - say, 32 bits - to give you finer-grained control over the frequency.

--
Gordonjcp MM0YEQ