Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // bass synth
- // 1 = SinOsc
- // 2 = TriOsc
- public class SomeSynth
- {
- // null references to two types of oscillators
- SinOsc @ sin1;
- SinOsc @ sin2;
- TriOsc @ tri1;
- TriOsc @ tri2;
- // initialize the oscillators, connect them to dac and set gain to zero
- fun void init(int osc1, int osc2)
- {
- if (osc1 == 1) new SinOsc @=> sin1 => dac;
- if (osc1 == 2) new TriOsc @=> tri1 => dac;
- if (osc2 == 1) new SinOsc @=> sin2 => dac;
- if (osc2 == 2) new TriOsc @=> tri2 => dac;
- this.noteOff();
- }
- fun void noteOff()
- {
- 0 => sin1.gain => tri1.gain => sin2.gain => tri2.gain;
- }
- }
- SomeSynth ss;
- ss.init(1, 2); // create a SinOsc and a TriOsc
Advertisement
Add Comment
Please, Sign In to add comment