They can replace the older oscili and oscil functions used in previous incarnations of RTcmix/cmix. They can also partially replace the tablei and table and array/table functions used for generating longer-span control envelopes. This cute trick is accomplished by creating an Ooscili or Ooscil object with the frequency set to 1.0/dur where dur is the time-span of the control function.
The values returned by the Ooscili::next() method
will be interpolated between points in the original wavetable/function
table array. The wavetable/function table array will be accessed cyclically
at a rate determined by the frequency set for the Ooscili object.
Again, Ooscil does the same thing but no interpolation.
The nexti method for the Ooscil object will interpolate sample values like Ooscili always does. For most interpolation situations, Ooscili is a better choice.
#include <Ougens.h> Ooscili *theOscil; int MYINSTRUMENT::init(float p[], int n_args) { ... theOscil = new Ooscili(freq, 2); // assumes makegen 2 for waveform ... } int MYINSTRUMENT::run() { float out[2]; ... for (i = 0; i < framesToRun(); i++) { out[0] = theOscil->next(); } ... }
#include <Ougens.h> Ooscili *theEnv; int resetsamps, resetcount; int MYINSTRUMENT::init(float p[], int n_args) { float dur; dur = p[2]; ... theEnv = new Ooscili(1.0/dur, 1); // assumes makegen 1 for envelope resetsamps = 100; // update the envelope only once every 100 samps resetcount = 0; ... } int MYINSTRUMENT::run() { float out[2]; float amp; ... for (i = 0; i < framesToRun(); i++) { if (resetcount >= resetsamps) // update the envelope { amp = theEnv->next(currentFrame()); resetcount = 0; } increment(); } ... }