JMSL Tutorial: MusicJob

Recall that JMSL’sComposable interface is the glue that lets polymorphic musical objects be scheduled together.

You will probably never have to write an object that implements Composable from scratch.JMSL comes with a number of very flexible Composables that can be customized.

One such Composable is called MusicJob.

A MusicJob does something repeatedly over time. What does it do? Anything you can code in Java!

It can update a JSyn SynthCircuit, send a Midi note, perform a calculation, poll and organize incoming data, print a message, do some drawing, etc. In fact, MusicJob does more than one thing. It has actions scheduled for when it starts, others for when it repeats, and others when it stops. It puts delays before some of these actions, and pauses after others. You have control over these durations, and of course you have control over the actions themselves.

A MusicJob schedules itself as follows:

  1. startDelay
  2. start()
  3. callPlayables( startPlayables ) optional
  4. startPause
  5. repeat()
  6. callPlayables( repeatPlayables ) optional
  7. repeatPause (loop back to repeat() for getRepeats() times)
  8. stopDelay
  9. callPlayables( stopPlayables ) optional
  10. stop()

The start(), repeat(), and stop() methods outlined above are stubs which can be overridden in a class that extends MusicJob.For example, start() might open a database connection, repeat() might pull data from it every 5 seconds, and stop() might close the database connection.
 

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