MinBLEP questions.

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

I thought I would take the plunge and try doing a MinBLEP oscillator. A few quick questions come to mind:

1) How important are sub-sampled blep tables? Can you just mix in a blep when the phase crosses a discontinuity or will the sub-sample jitter introduce noticeable artifacts.

2) How would you go about FM/PM with MinBLEP oscillator, especially if you are also doing PWM? Can you just adjust the phase increment every sample and hope it all works out or do you need some extra tricks to handle boundary conditions?

Post

GameSmith wrote: 1) How important are sub-sampled blep tables? Can you just mix in a blep when the phase crosses a discontinuity or will the sub-sample jitter introduce noticeable artifacts.
If you remember that a BLEP is actually a sample, then understanding what happens when use one goes something like this...

The noise you'll get from a BLEP can be understood as the noise you'll get from interpolating it. Because that interpolation noise is the difference between the ideal BLEP and what you actualy get.

So the interpolation noise depends on the level of oversampling and the kind of interpolation used on the blep sample.

If you use drop sample interpolation, rounding down to the nearest sample, which basically results in quantizing the positioning of the blep. You'll get 6db increase in SnR for every power of 2 of oversampling. So 8x will give you 18db SnR.

If you use Linear interpolation you'll get 12db for every power of 2 oversampling, so 32x would give you 60db.

However it's complicated by the fact that the amount of artifacts you'll get depends on how many BLEPs are being added. At 100hz you only get ~100 bleps per second, at 10khz, you get ~10,000. So each time you drop away from nyquist by an octave you have half as many bleps, and hence they will contribute half as much (6db less) to the signal, which means 6dbs less noise also.
2) How would you go about FM/PM with MinBLEP oscillator, especially if you are also doing PWM? Can you just adjust the phase increment every sample and hope it all works out or do you need some extra tricks to handle boundary conditions?
If you're doing PM you just do

if (newphase - oldphase) passes zero insertBlep;

where newphase = (phase+phasestep+phasemod)
and oldphase is the same but from the previous iteration.

You have to remember that you flip the sign of the blep depending on which way it passes zero.

It can also happen that the phase modulation might be so extreme that it's passing zero twice, but IME the sound will be so messed up by the time it reaches that point that it's not actually worth worrying about.

If you're doing PWM by subtracting 2 sawtooths then you just count the pulsewidth modulation as part of the phase modulation for the sawtooth you're using to create PWM.

If you're doing PWM by flipping from -1 to +1, then it's more complicated because rather than just working out when the signal passes zero you have to work out where it intersects the changing pulse width. The reset point is changing as well as the phase so it's the intersection of those two changing signals that determines where you need to place the BLEP.

Post

GameSmith wrote: 1) How important are sub-sampled blep tables? Can you just mix in a blep when the phase crosses a discontinuity or will the sub-sample jitter introduce noticeable artifacts.
I try my best to not repeat what nollock said, but:

Do you mean "do I need multiple branches for the BLEP" then yeah, because otherwise it won't help you at all. The number of different BLEP-branches gives you the "theoretical" oversampling you get from the BLEPs. So if you choose the BLEP (without interpolation) from 100 different branches (depending on the sub-sample position of the discontinuity) then the result will be comparable to using 100 time oversampling. Whatever jitter is basically like aliasing at the "oversampled" rate.

Basically, what the BLEPs do is reconstruct directly the wave that you'd ended up with, had you oversampled by the number of BLEP branches, and then used the BLEP filter to downsample the result (this also means, any suitable low-pass filter can be used as the basis for the BLEP; it need not be a windowed sinc or anything). Because the theoretical oversampling can be much larger than what would be practical to actually use, the results can be made very clean.

In practice it's not a big deal to have a couple of thousand branches, at which point you can pretty much get away even without interpolation (say 4092 branches = 2^12 => 12*6dB = 72dB which is already quite clean in practice). Unless you are using really long BLEPs, the limitations of the filter itself probably start to dominate.

Something to note though, is that with a large number of branches, the access pattern will be awful, if you simply store it "as-is" (you'd be reading every 4096th or something sample, basically trashing as much cache as possible), so you might want to reorder the data so that every branch is continuous in memory.

Post

Thanks for the responses, I think I get what you are on about. I was thinking that the distortion you got from using a single blep and ignoring the sub-sample position of the transition would be different from aliasing distortion. I assumed it would sound more harmonic and nice because it is sort of similar to PWM.

Post

GameSmith wrote:Thanks for the responses, I think I get what you are on about. I was thinking that the distortion you got from using a single blep and ignoring the sub-sample position of the transition would be different from aliasing distortion. I assumed it would sound more harmonic and nice because it is sort of similar to PWM.
If you ignore the sub sample position all you will do is lowpass the signal, you wont antialias the step.

Post

If you ignore the sub sample position all you will do is lowpass the signal, you wont anti-alias the step.
I don't quite understand this, if your sample rate was an exact multiple of your oscillator frequency wouldn't the sub-sample position always be zero. Would you get a band-limited wave for this frequency and not others?

If you generate a band limited step with no over-sampling, can't you mix as many of these in as you like and never have any frequencies above the Nyquist?

I don't see how anything would alias using a minBLEP generated at the sample rate and ignoring the sub-sample. I thought you would start getting a PWM like sound as the period of the wave changes slightly because it is not an integer number of samples.

Post

if samplerate is exact multiple of osc frequency then no anti-aliasing is needed. aliasing is the cause of signal period jitter (different period length in samples every period).

BLEP has the same effect as running oversampled signal thru FIR filter and then downsampling. notice when u do this then the step shape is different at every discontinuity. obviously u need to take into account the sub-sample position to get the same effect with BLEP. otherwise u just filter the non-oversampled signal with FIR which doesn't reduce aliasing at all.

Post

I think I understand now, thanks for your responses.

Post

GameSmith wrote: I don't see how anything would alias using a minBLEP generated at the sample rate and ignoring the sub-sample. I thought you would start getting a PWM like sound as the period of the wave changes slightly because it is not an integer number of samples.
Ok, BLEP is derived from BLIT but the sample principles apply. I'll explain with BLITs as I think its a little easier to follow.

So BLIT is basically the derived from the fact that you can do band limited interpolation by placing a sinc impulse at every sample instant, multiplied by that sample instants magnitude. So every output sample is a sum of every surrounding sinc impulse that contributes to that sample instant.

BLIT simplifies this by being a band limited impulse train, most of the sample instants are zero most of the time. So it's simply a matter of placing a sinc impulse at the few sample instances that are not zero.

But all of this is just a special case of sinc interpolation. You're still doing sinc interpolation, just choosing a very special case so most of the calculations can be skipped.

So if you ignore the sub sample positioning you will get exactly the same as if you just placed a 1 where you want a sinc, and zeros elsewhere, and then ran the stream through the sinc filter. It will be exactly the same as creating the naive aliased signal, and then lowpass filtering it with the sinc. (The sinc effectively being a lowpass filter).

You could explain the effect as pulsewidth jitter, but then you'd have to look at what the jitter actual is. It wont be a nice low frequency wobble, it'll be a high frequency inharmonic signal. This wont get you nice a nice harmonic pwm effect. It'll get you inharmonic modulation noise that happens to be the same as the aliasing described in the previous paragraph.

But to sum up. The accuracy of the sub sample positioning basically equates to the effective level of oversampling. If you only have 4 bit sub sample accuracy, then you are effectively 16x over sampling the oscillator. Cause what you're doing is creating an impulse train at 16x the sample rate, and then downsampling it. With 32 bit sub sample accuracy, you're 4 billion times oversampling it.

Post

Thanks for that pretty well clarifies what I started to get the gist of. I really need to stop trying to use my intuition for these sorts of things. I have very often thought, "there is now way that will be audible". Closely followed by "why the hell does this sound so crap".
Because I used to do more graphical stuff I tend to rely on a time-domain graphical view of audio in which a cubic spline can look pretty much identical to a sine wave. For square waves I tend to think as long as there is no step transition and you have the ringing it will sound fine.

Post

Another quick question:

If I am just using minBLEP to do a pwm/saw/tri + sync. Is there any advantage in minimum phase step? Would the implementation (circular buffer + accumulator) be any different than for a non min phase BLEP?
I suspect it has something to do with implementing the sync but I can't quite see how it is any different.

Post

GameSmith wrote:Another quick question:

If I am just using minBLEP to do a pwm/saw/tri + sync. Is there any advantage in minimum phase step? Would the implementation (circular buffer + accumulator) be any different than for a non min phase BLEP?
I suspect it has something to do with implementing the sync but I can't quite see how it is any different.
There is no advantage with minimum phase step other than slightly shorter latency. Unfortunately there is the disadvantage with minimum phase step that the latency will not be a simple integer number of samples (and it'll be frequency dependent). You don't need minimum phase for sync either.

http://www.signaldust.com/files/sync.flac is short example of basic linear-phase BLEPs doing PWM and sync (at the same time, for various waveforms). It's not totally clean implementation (some frequency noise-modulation and other special sauce in the oscillators but it doesn't affect the BLEPs really); you can get a lot more pure sound if you want.

Post

Another way that it does work quite good is to do a regular BLEP with polynomials (polyBLEP), maybe four or eight samples before and after the step are more than enough, and you don't have to deal with problems with PWM, your discontinuities are always the best placed that the datatype can handle and oversampled to infinity.

Post Reply

Return to “DSP and Plugin Development”