JMSL Tutorial: Player

A JMSL Player is a sequential collection of MusicShapes with an Instrument. When the Player runs through its MusicShape data, it interprets each element with its own Instrument, regardless of the Instrument found in the MusicShape itself.

This applet demonstrates a Player loaded with five MusicShapes, each with 3 elements.  The Player uses UniformRandomBehavior to play a different MusicShape each time it repeats.  We instantiate two SynthNoteAllPortsInstruments, and provide a gui button to swap them back and forth into the Player.

This is also a good opportnuity to present the MusicShape.prefab() method, which conveniently generates random MusicShape data.  For dimensions indexed greater than 3, it generates random data between the low and high limits for that dimension.

Note that when the instrument switches from FilteredSawtoothBL to Brass, the same MusicShape data is interpreted without a problem, even though the MusicShape initially generated  for FilteredSawtoothBL have seven dimensions, while Brass uses 5.  This is the power of DimensionNameSpace and DimensionNameSpaceTranslator.  Each time Player gets an element from a MusicShape, it checks if the Instrument has a DimensionNameSpace.  If it does, it translates from the DimensionNameSpace of the MusicShape to the DimensionNameSpace of the Instrument.  That way, if a dimension is named "cutoff", it will be used by FilteredSawtoothBL, and ignored by Brass.
 

You need a Java-enabled browser to view this applet 

View the source for this applet here.

You can set up a Player with custom Instruments and Interpreters three ways:

  1. Use the constructor public Player(Instrument) which automatically plugs in the specified Instrument
  2. Use a default instrument initially with the constructor public Player() and then call setInstrument(Instrument)
  3. Use a default instrument with the constructor public Player() and then call getInstrument().setInterpreter(Interpreter)
Next, let's share a MusicShape among two Players, and see that each Player can use its own Instrument and Interpreter to launch the MusicShape as it likes.
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.