Interpolating between Waveforms

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

mistertoast wrote: My new synth is 8x (or 16x--we'll see) oversampled, and it's pure hard-edged saw with an oversample filter. No table--just one line of osc code. This lets me do any kind of weird hard-sync, audiorate manipulations, fm, am, ring, PD, PWM, ANYTHING. I like this approach better. It's all trade-offs. There are many, many ways to make an oscillator. As long as the osc doesn't have a large section of missing high harmonics or nasty aliasing, I'm happy.
Sorry for the serious thread necro here, but can somebody explain how this would work?

If you generate a saw analytically into a buffer, you've already got aliasing? No kind of filtering after the fact will remove it, right? Or am I misunderstanding?

Post

kuniklo wrote:Sorry for the serious thread necro here, but can somebody explain how this would work?

If you generate a saw analytically into a buffer, you've already got aliasing? No kind of filtering after the fact will remove it, right? Or am I misunderstanding?
OK, if you can ask nearly two years later, I guess I can answer 9 months later ;-)

Think of it in terms of where the edge (reset of the sawtooth) occurs. I'll pick a real high note as an example, not just to keep the numbers small, but to show why the higher the note, the worse the aliasing for a sawtooth—looking at things from the time domain.

C9 (and octave above the note note on the piano) is 8372.018 Hz. At 44.1 kHz, that would be period of 5.2675472 samples. So, let's say you start the sawtooth ramp rising at sample #0, at a level of -1.0. At sample #1 through #5, the sawtooth is still rising. When it comes time to generate sample #6, we realize that the sawtooth timed out 0.2675472 samples after the last sample we generated, so it's time to reset the saw now—our earliest chance. So, that period was really 6 samples long, and the note would be flat if we kept this up.

We're smart though—we don't start the next cycle at sample #6, conceptually—we start counting from that "virtual" sample position at 5.2675472. So, the next reset will be at 10.5350944 (2 x 5.2675472). So, we get to sample #11 before having an opportunity to reset the saw.

If you're following, our first cycle had a 6 sample period, and the second had a 5 sample period. The next will be at sample #16 (for 5-sample period again, at 15.8...), then #22 (a 6-sample period, at 21.07...). As you might figure by now, the period modulates between 5 and 6, to average 5.2675472. Modulates—the key word here. You hear that modulation as aliased tones. And it should be obvious why high tones have worse aliasing—here you're modulating between periods of 5 and 6 samples; for the lowest note on the piano, you'd be modulating between a period of 1603 and 1604 samples—a much smaller relative error.

And it should be obvious from this explanation that there is no way to get rid of it—it's part of the definition of how you are making this waveform. That's why you need to do something different.

Post

That makes sense. In my own experiments the degree of over sampling it takes to make this "raw" approach work is just too expensive.
Last edited by kuniklo on Sat Feb 18, 2012 12:00 am, edited 1 time in total.

Post

it definitely is, especially when you consider that using a technique like blep you can mix in six samples from an impulse once for every reset to get results just as good as you'd get with any reasonable level of oversampling and decimation filter.

so the cost is much, much lower. there is no way you could over-sample the same way. when you use a system like blep or blit rather than oversampling the information is already there - it's the fractional part of the offset into the current sample. we don't need to quantize this value, we just take it as-is with full accuracy and apply the filter directly with no in-between stages.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post

What happened to mistertoast and his synth ?

Post

I've browsed the BLEP stuff and was initially a little put off by the math but I think it's another one of those DSP things that looks really complicated presented in formal theory but is actually pretty simple to implement. So I'll probably take a crack at it in one of my synths soon.

Post

the math for blit is as follows:

take your windowed sinc impulse and insert it at a fractional position using interpolation.

blep is the following:

before inserting your impulse, integrate it.

minblep the following:

oh, and also take the minimum phase transformed version of it.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post Reply

Return to “DSP and Plugin Development”