JMSL Tutorial: JSyn and JMSL, Controlling all input ports of a SynthNote

The previous two tutorials showed you how to play SynthNote events by specifying duration, pitch, amplitude, and hold time.  There's a lot more to sound than that! For example, the SynthNote we designed in the previous tutorial has an input port called "rate" which we could not control with JSynInsFromClassName. Other SynthNotes will have other input ports you'd like to control. For example, FilteredSawtoothBL which ships with JSyn has SynthInputs called "cutoff", "Rate", and ":resonance".  Here we show you how to control all these custom input ports.

A powerful subclass of JSynInsFromClassName, called SynthNoteAllPortsInstrument gives you this control. You may want to review the tutorial on DimensionNameSpace before proceeding.

When SynthNoteAllPortsInstrument is handed a SynthNote, it "sniffs out" all its input ports and builds a DimensionNameSpace, keeping dimensions 0..3 the standard duration, pitch, amplitude, hold, and assigning dimensions higher than 3 to these custom input ports.  Our TutSquare had one extra input port called rate, so we will see that in Dimension 4.

DimensionNameSpace built by SynthNoteAllPortsInstrument for tutorial.TutSquare
0 duration
1 pitch
2 amplitude
3 hold
4 rate

Note that besides the four common names "duration", "pitch", "amplitude", and "hold", that one additional dimension name show up as well (in bold above).  This is unique to TutSquare and was discovered by SynthNoteAllPortsInstrument. Now any MusicShape that has rate values in dimension 4 can use this instrument to control this parameter.  You could add these values by hand like so...

// add an event with 5 second duration, pitch 60, amp = 0.5, hold = 4.8 sec, rate = 2.0 (fast attack)
myShape.add(5.0, 60, 0.5, 4.8, 2.0);

The applet  below plays a hand-coded MusicShape with a SynthNoteAllPortsInstrument that uses TutSquare

The essential code follows:

     ins = new SynthNoteAllPortsInstrument(8, "jmsltutorial.TutSquare");

  // construct a new MusicShape with the same DimensionNameSpace as the instrument
     myShape = new MusicShape(ins.getDimensionNameSpace()); 
     myShape.add(5.0, 60, 0.5, 4.8, 2.0);    // fast attack rate = 2.0
     myShape.add(5.0, 70, 0.5, 4.8, 0.1);    // slow attack rate = 0.1

You need a Java-enabled browser to view this applet. 

View complete source
Previous Tutorial Index Tutorial Contents Next

  (C) 1997 Phil Burk and Nick Didkovsky, All Rights Reserved
  JMSL is based upon HMSL (C) Phil Burk, Larry Polansky and David Rosenboom.