PolyBLEP oscillators

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

S0lo wrote: Thu Jul 09, 2020 9:12 pm On a quick look at it, I'd say your doing it correctly since you've also added linear interpolation to the ELSE part. Although linear interpolation will still produce some aliasing, it's better than none. cubic is better.

Let me ask, Where is the waveform coming from? The waveform it self has to be band limited. If the user is simply drawing the waveform on screen then it's most certainly not band limited.

Try a waveform taken from a wave file or song. And play it at it's root frequency that it was recorded on. Any other frequencies will produce higher and higher aliasing as you go far from the root.

The reason PolyBLEP works well for saw/square is because you are generating those waveforms on the fly through formulas that produce only 1 discontinuity at that edge which PolyBLEP fixes. It's not because saw/square is special. To prove that, record a saw to a wavetable then play it again with PolyBLEP at a far frequency than what it was recorded on. You will hear aliasing with saw and square
I only use one waveform/wavetable per tone generator. No band limiting. I'm sorry if I led you to believe that, or I were unaware that PolyBlep only worked for band limited waveforms.

I optimistically, naively just hoped that since "my" PolyBlep worked so great with a saw, and I saw there was different implementations for square, and triangle, perhaps there was a way to make it work with any, even hand drawn waveforms. Actually I don't mind if I have to check for discontinuity anywhere during sampling, meaning not just at the end.
"Scuba divers work best under pressure!"

https://www.youtube.com/user/DKDiveDude (Original music and hardware videos)

Post

Been there. No shame. This is one complex topic in dsp.

BTW, any recorded wav or snipet of an mp3 track is already band limited when you play it at it's root frequency.
DKDiveDude wrote: Thu Jul 09, 2020 9:33 pmActually I don't mind if I have to check for discontinuity anywhere during sampling, meaning not just at the end.
If your pitch shifting is not so far. You could just try it on all samples, without checking for discontinuities. After all, it is an interpolater between two samples.
www.solostuff.net
Advice is heavy. So don’t send it like a mountain.

Post

In your polyblep code, the value of 'correction' is tuned for a step from -1 to +1. If your saw has such a step, the correction will antialias it as expected. But if the step is anything different, you need to scale the correction accordingly otherwise you will be making things worse rather than better.

If you calculate the difference d=(first sample in buffer)-(last sample in buffer) then multiply correction by d/2 before adding it in, things might sound better with an arbitrary waveform (if the only discontinuity is at the point where the buffer 'wraps around').

[The polyblep code also expects the waveform to have the same slope on either side of the discontinuity, which is true for a saw but not for a general wave - you should really antialias the change in slope too. But scaling the correction value should get you started, at least.]

Post

kryptonaut wrote: Fri Jul 10, 2020 4:34 pm In your polyblep code, the value of 'correction' is tuned for a step from -1 to +1. If your saw has such a step, the correction will antialias it as expected. But if the step is anything different, you need to scale the correction accordingly otherwise you will be making things worse rather than better.

If you calculate the difference d=(first sample in buffer)-(last sample in buffer) then multiply correction by d/2 before adding it in, things might sound better with an arbitrary waveform (if the only discontinuity is at the point where the buffer 'wraps around').

[The polyblep code also expects the waveform to have the same slope on either side of the discontinuity, which is true for a saw but not for a general wave - you should really antialias the change in slope too. But scaling the correction value should get you started, at least.]
Thanks I'll try that! Above when you write first and last sample in buffer, by buffer I assume you mean my wavetable right?
"Scuba divers work best under pressure!"

https://www.youtube.com/user/DKDiveDude (Original music and hardware videos)

Post

DKDiveDude wrote: Fri Jul 10, 2020 4:46 pm Thanks I'll try that! Above when you write first and last sample in buffer, by buffer I assume you mean my wavetable right?
Well, it really means the values immediately after and immediately before any discontinuity (abrupt step) which I imagined would coincide with the start and end of your wavetable/buffer, as is the case for a naive saw.

Post

Bumped to this demonstration of polyBLEP in action.

Could it be possible to compare different methods mentioned in this thread (plots in 1st page in this thread, linked source codes) there by just adding the method of each (as like both bpleb(t, dt) functions there (can be located in Common -tab)) ... meaning, would usage of each method otherwise be same so that you don't have to write seperate code for each method? (Noobalert!)

Post

PolyBLEP oscillators are great, especially when use in combination with oversampling. I tested 4x oversampling with a windowed sinc decimation. The spectrum looked quite ideal. But now I wonder how to implement a triangle PolyBLEP. Maybe integration of the quadratic expressions will do it.

Post

I think you want to look at "BLAMP" methods for triangle waves

Post

Cool tip, thanks. I found a paper "ROUNDING CORNERS WITH BLAMP" which I will study.
I found out that a 50/50 triangular wave can be anti aliased very easily with the "standard" 2 sample polyBLEP which is used for saw and pulse. You only need the Expression t + t + t * t + 1 on all 4 corners and scale it, it really works!

Post Reply

Return to “DSP and Plugin Development”