com.softsynth.jmsl
Class ParallelCollection

java.lang.Object
  extended by com.softsynth.jmsl.MusicJob
      extended by com.softsynth.jmsl.ParallelCollection
All Implemented Interfaces:
Composable, Playable, java.lang.Runnable
Direct Known Subclasses:
Measure, QueueCollection, SequentialCollection, Staff

public class ParallelCollection
extends MusicJob

Parallel Collection for JMSL Collections can contain other Composable objects which allows a hierarchy to be created. A Parallel Collection launches all its children at the same time

  1. startDelay
  2. start()
  3. startPlayables.play() optional
  4. startPause
  5. internalRepeat(), launches all its children at once
  6. repeat()
  7. repeatPlayables.play() optional
  8. repeatPause (loop back to repeat() for getRepeats() times)
  9. stopDelay
  10. stopPlayables.play() optional
  11. stop()


This class is Serializable, so it can be written to and read from a stream. We recommend you use this feature for network pieces rather than saving your objects to disk as a durable record of a piece. When/if this class definition changes in a future version of JMSL, an attempt to read an old object will break.
Note also that anything you put in a collection has to be Serializable for the collection to successfully serialize.

Author:
Phil Burk and Nick Didkovsky

Field Summary
 
Fields inherited from class com.softsynth.jmsl.MusicJob
repeatCount
 
Constructor Summary
ParallelCollection()
          Conveniant constructors for quickly building a hierarchy.
ParallelCollection(Composable child1)
          Construct a parallel collection with specified child
ParallelCollection(Composable child1, Composable child2)
          Construct a parallel collection with specified children
ParallelCollection(Composable child1, Composable child2, Composable child3)
          Construct a parallel collection with specified children
ParallelCollection(Composable child1, Composable child2, Composable child3, Composable child4)
          Construct a parallel collection with specified children
 
Method Summary
 Composable get(int i)
          synonym for getChild(), return the i'th Composable in this Composable
 void halt()
          Stop all children.
 double internalRepeat(double playTime)
          Execute all children in parallel.
static void main(java.lang.String[] args)
          Stuff some jobs into a parallel collection and watch 'em go
 void print()
           
 void printHierarchy(int level)
          Very helpful printing function: print yourself and print all your children, who in turn print themselves and all THEIR children.
 void set(Composable child, int i)
          replace the Composable at element i with new Composable
 
Methods inherited from class com.softsynth.jmsl.MusicJob
add, addPlayLurker, addRepeatPlayable, addStartPlayable, addStopPlayable, advanceCurrentTime, contains, elements, finish, finishAll, getChild, getChildren, getCurrentTime, getDataTranslator, getDuration, getInstrument, getName, getParent, getPlayLurkers, getRepeatCount, getRepeatPause, getRepeats, getStartDelay, getStartPause, getStartTime, getStopDelay, getTimeStretch, getTransposition, indexOf, insert, isRunning, launch, launch, play, play, printHierarchy, remove, remove, removeAll, removeAllPlayLurkers, removeAllRepeatPlayables, removeAllStartPlayables, removeAllStopPlayables, removePlayLurker, removeRepeatPlayable, removeStartPlayable, removeStopPlayable, repeat, run, setCurrentTime, setDataTranslator, setDuration, setInstrument, setName, setParent, setRepeatPause, setRepeats, setStartDelay, setStartPause, setStartTime, setStopDelay, setTimeStretch, setTransposition, size, start, stop, timeStretch, transposition, waitForDone
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParallelCollection

public ParallelCollection()
Conveniant constructors for quickly building a hierarchy.


ParallelCollection

public ParallelCollection(Composable child1)
Construct a parallel collection with specified child


ParallelCollection

public ParallelCollection(Composable child1,
                          Composable child2)
Construct a parallel collection with specified children


ParallelCollection

public ParallelCollection(Composable child1,
                          Composable child2,
                          Composable child3)
Construct a parallel collection with specified children


ParallelCollection

public ParallelCollection(Composable child1,
                          Composable child2,
                          Composable child3,
                          Composable child4)
Construct a parallel collection with specified children

Method Detail

set

public void set(Composable child,
                int i)
replace the Composable at element i with new Composable


get

public Composable get(int i)
synonym for getChild(), return the i'th Composable in this Composable


internalRepeat

public double internalRepeat(double playTime)
                      throws java.lang.InterruptedException
Execute all children in parallel.

Specified by:
internalRepeat in interface Composable
Overrides:
internalRepeat in class MusicJob
Returns:
stopTime
Throws:
java.lang.InterruptedException - thrown if Thread.interrupt() called.

halt

public void halt()
Stop all children.

Specified by:
halt in interface Composable
Overrides:
halt in class MusicJob

printHierarchy

public void printHierarchy(int level)
Very helpful printing function: print yourself and print all your children, who in turn print themselves and all THEIR children. Use indenting to show hierarchy.

Specified by:
printHierarchy in interface Composable
Overrides:
printHierarchy in class MusicJob

print

public void print()
Overrides:
print in class MusicJob

main

public static void main(java.lang.String[] args)
Stuff some jobs into a parallel collection and watch 'em go