|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.softsynth.jmsl.MusicJob
com.softsynth.jmsl.ParallelCollection
com.softsynth.jmsl.SequentialCollection
com.softsynth.jmsl.Player
public class Player
A Player has a sequence of MusicShapes and one Instrument to interpret MusicShape data. Since it is
a SequentialCollection, it can execute these shapes in sequence or choose using a behavior.
Example:
// Stick two simple shapes into a Player and play the Player - printing output
public static void main(String args[]) {
// build a MusicShape
MusicShape s1 = new MusicShape(4);
s1.add(1.0, 10, 20, 30);
s1.add(1.0, 11, 20, 30);
// build another one
MusicShape s2 = new MusicShape(4);
s2.add(0.5, 100, 20, 30);
s2.add(0.5, 101, 20, 30);
s2.add(0.5, 102, 20, 30);
s2.add(0.5, 103, 20, 30);
// Build a Player and add these two MusicShapes
Player p = new Player();
p.add(s1);
p.add(s2);
p.setRepeats(10);
// Plug in a Playable that prints a message every time the Player repeats
p.addRepeatPlayable(new MessagePrinter("repeats"));
// Use default behavior: choose a new child randomly every repeat
p.setBehavior(new UniformRandomBehavior());
// go!
p.launch(JMSL.now());
}
| Field Summary |
|---|
| Fields inherited from class com.softsynth.jmsl.MusicJob |
|---|
repeatCount |
| Constructor Summary | |
|---|---|
Player()
Construct a Player with a default Instrument. |
|
Player(Instrument ins)
Construct a Player with an instrument to use to play all its children |
|
| Method Summary | |
|---|---|
double |
internalRepeat(double playTime)
Every repeat, either choose next MusicShape if acting sequentially or choose one using Behavior |
static void |
main(java.lang.String[] args)
Stick two MusicShapes into two Players and play the Players, printing output. |
double |
start(double startTime)
open() Instrument and return startTime |
double |
stop(double stopTime)
close() Instrument and return stopTime |
| Methods inherited from class com.softsynth.jmsl.SequentialCollection |
|---|
getBehavior, print, setBehavior |
| 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 Player(Instrument ins)
public Player()
| Method Detail |
|---|
public double start(double startTime)
throws java.lang.InterruptedException
start in interface Composablestart in class MusicJobjava.lang.InterruptedException - thrown if Thread.interrupt() called.
public double stop(double stopTime)
throws java.lang.InterruptedException
stop in interface Composablestop in class MusicJobjava.lang.InterruptedException - thrown if Thread.interrupt() called.
public double internalRepeat(double playTime)
throws java.lang.InterruptedException
internalRepeat in interface ComposableinternalRepeat in class SequentialCollectionjava.lang.InterruptedException - if the thread running this Composable is interruptedpublic static void main(java.lang.String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||