Class ParallelCollection

java.lang.Object
com.softsynth.jmsl.MusicJob
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
  • Constructor Details

    • 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 Details

    • 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