We can write quick and dirty Instruments that simply bang a JSyn circuit in play(), or we can be more rigorous and follow some good design principles that will extend the life and utility of your instruments.
Good JMSL Instrument design follows the following principles:
Now for the nuts and bolts: Instrument's most important method
is play(). This is called by MusicShape for example, as it iterates
through all its elements, handing each to its instrument's play() method,
and waiting for the time returned by play() before proceeding to the next
element. So the task we have to accomplish is bang SineCircuit in
the Instrument's play() method.
Check the source for SineInstrument
here. Read it carefully. Use it as a template for your own JSyn Instrument
design. But we reiterate here, that if you just want to use a SynthNote
and play it with full control over each of its SynthInputs, you can just
use JMSL's SynthNoteAllPortsInstrument. If you don't care about note-by-note
timbral control, just use JSynInsFromClassName. Only design your
own Instruments from scratch if the definition of what it does truly falls
outside the paradigm of applying a parameter list to a synthesizer's inputs
and banging it.
Next, we will have the great satisfaction of building a MusicShape,
handing it one of our SineInstruments, and starting it up.
Previous | Tutorial Index | Tutorial Contents | Next |
(C) 2003 Nick Didkovsky, All Rights Reserved