JMSL Tutorial: JSyn and JMSL, playing a SynthNote designed in Wire
In the previous tutorial, we handed the class name of a stock SynthNote
(one that ships with JSyn) to JSynInsFromClassName. In this tutorial, we
design one of our own SynthNote in Wire. Note that you must own a
JSyn developer's license to unlock the export Java source code feature
in Wire.
IMPORTANT: A SynthNote, by definition, must have a "frequency" and an "amplitude" input port.
JMSL's use of SynthNote assumes
you follow this convention, so you must use this exact spelling. Of course you may name your other input ports anything you like.
We will build a one-oscillator SynthNote with an amplitude envelope.
The second frame of the envelope will be the sustain point.
-
Start up Wire, and select Add -> SynthNote patch.
-
Double click on the patch to reveal a new window with the patch's
contents. You should just see two input ports (frequency and amplitude)
and one output port. This is the minimum requirement for a SynthNote.
-
Add a square wave oscillator (Add -> oscillators -> SquareOscillatorBL)
-
Add an envelope player (control -> Envelope Player) and an Envelope Module
(data -> EnvelopeModule). Double click the EnvelopeModule and set
the second frame to sustain (select "S" radio button and highlight the
second breakpoint with the mouse). Check "AutoStop" so that this
when this SynthNote finishes playing a note, it will stop and conserve
processing power.
-
Connect your units so they look like this. Note that we added an
InputPort called "rate" (Add -> External ports -> InputPort). We
named it "rate", left the minimum at 0, set the Value to 1.0, and the Maximum
to 2.0. Initially will will not use rate, but we will later in the
tutorial, so keep it in mind.
-
Test your patch by connecting a LineOut to the top patch (in the other
editor window). Click the "play keys" button and type on the computer keyboard.
You will hear notes play as you press. Click and hold a key to test
that it sustains.
-
Export the Java source for this patch (File -> Export Java Source) and
compile it. Make sure you export Java source from the patch itself
(the window with all the subunits in it), not from the top patch
with the LineOut Examine the exported source.
Note that the source includes a method called setStage() which is called
by noteOn and noteOff. This is important when designing your own
SynthNotes from scratch (without Wire's help). Important: we edited the
source exported by Wire and changed the package name to jmsltutorial.
-
Finally, a tiny variation on the preceding tutorial example will play your
new sound. Just change the "FilteredSawtoothBL" classname to match
the package name and class name of your patch (in this case, jmsltutorial.TutSquare
)
Here is a variation on our previous applet, using the new sound.
See complete applet source here. Note
that there's hardly any code since we inherit from the previous applet.
(C) 1997 Phil Burk and Nick Didkovsky, All Rights Reserved
JMSL is based upon HMSL (C) Phil Burk, Larry Polansky and David Rosenboom.