In Gibber, a Synth simply wraps an oscillator and an envelope together and allows it accept note messages. The FMSynth is a more complex synth that implements FMSynthesis; the Poly synth stacks multiple oscillators to play chords.
There are six types of oscillators in Gibber: Sine, Tri, Pulse, Saw, InvSaw and Square. All accept an initial frequency value and a volume in their constructors with defaults of 440 for frequency and .25 for volume. Below is code to create a 330 Hz square wave:
s = Square(330, .1);
Oscillators all expose the frequency and mix parameters for control. Thus we could change the frequency of the above oscillator using:
s.frequency = 880;
If you wish to sequence a continuous tone, using oscillators is the way to go. However, if you would like to play notes with a defined attack / decay envelope you will want to use the Synth object.
The Synth object takes a waveform (as outlined above) and a volume in its constructor. The default waveform is triangle. To tell a Synth to play a note we use the note command.
s = Synth(); s.note("A4");
The above code snippet creates a synth and tells it to play the note A in the 4th octave. Once you have a synth created you can then sequence it using one of the various sequencing objects. The synth object also has attack and decay properties that can be set; it defaults to using a 100ms attack and 100ms decay. You can also change the waveShape property to change the type of oscillator used.
s = Synth(); s.attack = 10; // measured in ms s.waveShape = "square";
The FMSynth adds an extra oscillator to the Synth object that modulates its frequency. This synth is described in detail in the tutorial on FMSynthesis that can be loaded from within Gibber. The parameters of its constructor are:
carrier to modulation ratio, modulator index, attack, decay
You can also pass a string to the constructor to load a preset. Right now there are only two presets “gong” and “brass” but more will be added in the future. Thus, to play a gong sound:
f = FMSynth("gong"); f.note("F2");
The poly synth layers five oscillators in order to play chord pads or stabs. Its constructor accepts a chord for it to play. Instead of sending the Poly synth a “note” commnand we instead call the “trig” method and pass in a volume; this will then play the chord at the volume specified. Example:
p = Poly("C4m7"); p.trig(.5); p.trg(.2);
Like the Synth object, you can adjust the attack, decay and waveShape parameters of the Poly object. View the tutorial patch named “chords + arp” for more details on using the Poly object.