|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.softsynth.jmsl.MusicJob com.softsynth.jmsl.ParallelCollection com.softsynth.jmsl.SequentialCollection
public class SequentialCollection
A sequential collection launches each of its Composable children in sequence.
Can alternatively use a user-defined behavior function to choose which child to
launch every repeat (see Behavior). If behavior function returns null child, it signals finish(), so even a
colleciton with 10000 repeat count will terminate early if child returned is null.
If Behavior itself is null, collection acts strictly sequentially.
Can switch back and forth between these modes.
Example of building a SequentialCollection with two stock MusicJobs. The
collection will act behaviorally using UniformRandomBehavior which chooses
a child randomly upon each of 5 repeats.
SequentialCollection seqCol = new SequentialCollection(new MusicJob(), new MusicJob()); seqCol.setBehavior(new UniformRandomBehavior()); seqCol.setRepeats(5); seqCol.launch(JMSL.now());
Field Summary |
---|
Fields inherited from class com.softsynth.jmsl.MusicJob |
---|
repeatCount |
Constructor Summary | |
---|---|
SequentialCollection()
Simple constructor. |
|
SequentialCollection(Composable child1)
Conveniant constructor which automatically adds one Composable child to the sequential hierarchy. |
|
SequentialCollection(Composable child1,
Composable child2)
Conveniant constructor which automatically adds two Composable children to the sequential hierarchy. |
|
SequentialCollection(Composable child1,
Composable child2,
Composable child3)
Conveniant constructor which automatically adds three Composable children to the sequential hierarchy. |
|
SequentialCollection(Composable child1,
Composable child2,
Composable child3,
Composable child4)
Conveniant constructor which automatically adds four Composable children to the sequential hierarchy. |
Method Summary | |
---|---|
Behavior |
getBehavior()
Retrieve the class that chooses a child to launch. |
double |
internalRepeat(double playTime)
Every repeat, either choose next child if acting sequentially (ie getBehavior() == null) or choose one using Behavior. |
static void |
main(java.lang.String[] args)
|
void |
print()
|
void |
setBehavior(Behavior b)
Plug in a class satisfying the Behavior interface, which chooses which child to launch every repeat. |
Methods inherited from class com.softsynth.jmsl.ParallelCollection |
---|
get, halt, printHierarchy, set |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SequentialCollection()
public SequentialCollection(Composable child1)
public SequentialCollection(Composable child1, Composable child2)
public SequentialCollection(Composable child1, Composable child2, Composable child3)
public SequentialCollection(Composable child1, Composable child2, Composable child3, Composable child4)
Method Detail |
---|
public void setBehavior(Behavior b)
public Behavior getBehavior()
public double internalRepeat(double playTime) throws java.lang.InterruptedException
internalRepeat
in interface Composable
internalRepeat
in class ParallelCollection
java.lang.InterruptedException
- if the thread running this Composable is interrupted.public void print()
print
in class ParallelCollection
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |