olofson / audiality2

A realtime scripted modular audio engine for video games and musical applications.
http://audiality.org/
zlib License
79 stars 5 forks source link

Smoother ramping/filtering modes for the 'dc' generator unit #156

Open olofson opened 10 years ago

olofson commented 10 years ago

We now have a DC generator with discrete stepping and linear ramping modes. (See #182.) This idea originally came up as a tool for replacing the hardcoded builtin wave rendering code in the core (see #152), but this unit could be (ab)used for a lot of other things.

However, only pulse and linear ramps makes it a bit limited, and there is also an issue with aliasing distorsion when generating continuous audio. The latter is due to transients not being band limited (same problem as when "abusing" wtosc; see #167 and #222), but both of these issues could be addressed to great extent by adding higher degree curves, as alternatives to the current STEP and LINEAR modes.

Some ideas:

  1. Cubic step: Each ramp starts and ends with zero derivative (horizontal lines), with a smooth 3rd degree curve in between. This might be useful and easy to control in some cases, but considering that it's effectively a smoothed variant of STEP, it's probably to be considered a bit of a special effect.
  2. Cubic spline: Each ramp starts with whatever derivative the generator output has at that time, and ends with the derivative of an imaginary straight line between the start and end points, with a smooth 3rd degree curve in between. This should allow the rendering of very smooth arbitrary waveforms, but has the side effect of producing lots of overshoot in extreme cases, due to it's inherent "trend extrapolating" nature.
olofson commented 7 years ago

Might nick some code or ideas from the 'env' unit for this...? The cosine spline mode seems particularly appropriate; probably better than the proposed cubic step.

However, the LUT based design doesn't lend itself very well to matching initial and final derivates, as suggested for the "cubic spline" mode... I suppose one could adjust the start and end points, but it kind of feels like an ordinary cubic spline solution is more appropriate for that.