signal/hf-osc
src/signal/hf-osc.tur
defn
hf-sawtooth
(hf-sawtooth [freq :float sample-rate :float])
band-limited sawtooth Signal Function.
Parameters
| freq | frequency in Hz | |
| sample-rate | the rate the signal will be sampled at, in Hz |
Returns
An SF: ignores its input signal and emits a rising ramp in [-1, 1) with the downward step at the end of each cycle smoothed by PolyBLEP. It is 0 at t = 0 (the smoothed step is centered on the cycle boundary) and crosses zero again mid-cycle.
Example
((hf-sawtooth 440.0 48000.0) (constant 0.0))
defn
hf-square
(hf-square [freq :float dutycycle :float sample-rate :float])
band-limited square/pulse Signal Function.
Parameters
| freq | frequency in Hz | |
| dutycycle | duty cycle in [0, 1]: the fraction of each cycle spent at +1 | |
| sample-rate | the rate the signal will be sampled at, in Hz |
Returns
An SF emitting +1.0 for the on-portion of each cycle and -1.0 otherwise, with both edges smoothed by PolyBLEP.
Example
((hf-square 220.0 0.5 48000.0) (constant 0.0))
defn
hf-triangle
(hf-triangle [freq :float sample-rate :float])
band-limited triangle Signal Function.
Parameters
| freq | frequency in Hz | |
| sample-rate | the rate the signal will be sampled at, in Hz |
Returns
An SF that rises from -1.0 to 1.0 over the first half of each cycle and falls back over the second, with both corners rounded by PolyBLAMP.
Example
((hf-triangle 440.0 48000.0) (constant 0.0))
Internal definitions
__hf_fmod-- compute floating-point modulo.__hf_phase-- cycle position of time t at freq Hz, in [0, 1).__hf_dt-- phase advance per sample, clamped to a usable range.__hf_blep-- PolyBLEP residual for a unit-height step at phase 0.__hf_blamp-- PolyBLAMP residual for a unit slope change at phase 0.