Package com.softsynth.jmsl
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
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.
- startDelay
- start()
- startPlayables.play() optional
- startPause
- internalRepeat(), launches all its children at once
- repeat()
- repeatPlayables.play() optional
- repeatPause (loop back to repeat() for getRepeats() times)
- stopDelay
- stopPlayables.play() optional
- 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
Constructors Constructor Description ParallelCollection()
Conveniant constructors for quickly building a hierarchy.ParallelCollection(Composable child1)
Construct a parallel collection with specified childParallelCollection(Composable child1, Composable child2)
Construct a parallel collection with specified childrenParallelCollection(Composable child1, Composable child2, Composable child3)
Construct a parallel collection with specified childrenParallelCollection(Composable child1, Composable child2, Composable child3, Composable child4)
Construct a parallel collection with specified children -
Method Summary
Modifier and Type Method Description Composable
get(int i)
synonym for getChild(), return the i'th Composable in this Composablevoid
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 govoid
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 ComposableMethods 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, getRepeatPlayables, getRepeats, getStartDelay, getStartPause, getStartPlayables, getStartTime, getStopDelay, getStopPlayables, 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 Details
-
ParallelCollection
public ParallelCollection()Conveniant constructors for quickly building a hierarchy. -
ParallelCollection
Construct a parallel collection with specified child -
ParallelCollection
Construct a parallel collection with specified children -
ParallelCollection
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
replace the Composable at element i with new Composable -
get
synonym for getChild(), return the i'th Composable in this Composable -
internalRepeat
public double internalRepeat(double playTime) throws java.lang.InterruptedExceptionExecute all children in parallel.- Specified by:
internalRepeat
in interfaceComposable
- Overrides:
internalRepeat
in classMusicJob
- Returns:
- stopTime
- Throws:
java.lang.InterruptedException
- thrown if Thread.interrupt() called.
-
halt
public void halt()Stop all children.- Specified by:
halt
in interfaceComposable
- Overrides:
halt
in classMusicJob
-
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 interfaceComposable
- Overrides:
printHierarchy
in classMusicJob
-
print
public void print() -
main
public static void main(java.lang.String[] args)Stuff some jobs into a parallel collection and watch 'em go
-