The Faust oscillators.lib comes with many different
implementations of oscillators for various waveforms.
At some point one might still need a behavior not included
and lower level approaches are necessary.
This example shows how to use a
phasor to read a wavetable with a
This implementation has an additional
trigger input for resetting the phase
of the oscillator on each positive
This can come handy in various applications,
especially for phase-sensitive transients,
as for example in kick drums.
The example is derived from Barkati et. al (2013) and part of the
// some basic stuff
sr = SR;
twopi = 2.0*ma.PI;
// define the waveform in table
ts = 1<<16; // size = 65536 samples (max of unsigned short)
time = (+(1) ~ _ ) , 1 : - ;
sinewave = ((float(time) / float(ts)) * twopi) : sin;
phase = os.hs_phasor(ts,freq,trig);
// read from table
sin_osc( freq) = rdtable(ts ,sinewave , int(phase)) ;
// generate a one sample impulse from the gate
trig = pm.impulseExcitation(reset);
reset = button ("reset");
freq = hslider("freq", 100, 0, 16000, 0.00001);
// offset = hslider("offset", 0, 0, 1, 0.00001);
process = sin_osc(freq);
Karim Barkati and Pierre Jouvelot.
Synchronous programming in audio processing: a lookup table oscillator case study.
ACM Computing Surveys (CSUR), 46(2):1–35, 2013.