sky.monome.sequencer
Class SequencerEngine<S extends Sequencer<S,B>,B extends ButtonManager<B>>


java.lang.Object

  extended by java.lang.Thread

      extended by sky.monome.sequencer.SequencerEngine<S,B>

Type Parameters:
S - Type of sequencers that use these sequencer engines.
B - Type of button managers used by the sequencers that use these sequencer engines.
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
MultiSequencerGroup.SpecificSequencerEngine

public class SequencerEngine<S extends Sequencer<S,B>,B extends ButtonManager<B>>
extends java.lang.Thread

Engine of a sequencer. The engine is responsible for the iteration over the sequence of the sequencer.

Author:
PJ Skyman

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected  int divisions
          Number of divisions by quarter note used by this sequencer engine.
protected  Monome monome
          Logical Monome device for refreshings.
protected  SynchronizedList<S> sequencers
          List of sequencers that use this sequencer engine.
protected  float tempo
          Tempo used by this sequencer engine.
protected  double timeBetweenSteps
          Calculated time between two consecutive steps, in milliseconds.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SequencerEngine(Monome monome, float tempo, int divisions, S... sequencers)
          Constructs a sequencer engine with the specified logical Monome device, the specified tempo, the specified number of divisions by quarter note, and driving specified sequencers.
 
Method Summary
 void addSequencer(S sequencer)
          Adds the specified sequencer to the list of associated sequencers.
 int getDivisions()
          Returns the number of divisions by quarter note currently used by this sequencer engine.
 S[] getSequencers()
          Returns an array of all associated sequencers.
 float getTempo()
          Returns the current tempo of this sequencer engine.
 double getTimeBetweenSteps()
          Returns the calculated time between two consecutive steps.
 void refreshMonome()
          Refreshes the physical Monome device.
 void removeSequencer(S sequencer)
          Removes the specified sequencer from the list of associated sequencers.
 void removeSequencers()
          Removes all sequencers from the list of associated sequencers.
 void run()
          Invoked by the virtual machine to execute this thread.
 void setDivisions(int divisions)
          Modifies the number of divisions by quarter note of this sequencer engine.
 void setTempo(float tempo)
          Modifies the tempo of this sequencer engine.
 void setTempo(float tempo, int divisions)
          Modified the tempo and the number of divisions by quarter note currently used by this sequencer engine.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

timeBetweenSteps


protected double timeBetweenSteps
Calculated time between two consecutive steps, in milliseconds. Since SkyMonome v1.3, this field is not final anymore.


tempo


protected float tempo
Tempo used by this sequencer engine.

Since:
SkyMonome v1.3

divisions


protected int divisions
Number of divisions by quarter note used by this sequencer engine.

Since:
SkyMonome v1.3

sequencers


protected final SynchronizedList<S extends Sequencer<S,B>> sequencers
List of sequencers that use this sequencer engine.


monome


protected final Monome monome
Logical Monome device for refreshings.

Constructor Detail

SequencerEngine


public SequencerEngine(Monome monome,

                       float tempo,

                       int divisions,

                       S... sequencers)
Constructs a sequencer engine with the specified logical Monome device, the specified tempo, the specified number of divisions by quarter note, and driving specified sequencers. These sequencers can also be added after the construction.

Parameters:
monome - Logical Monome device for refreshings.
tempo - Tempo, in number of quarter notes by minute.
divisions - Number of divisions by quarter note.
sequencers - Sequencers that will be driven by this sequencer engine.
Method Detail

getDivisions


public int getDivisions()
Returns the number of divisions by quarter note currently used by this sequencer engine.

Returns:
The number of divisions by quarter note currently used by this sequencer engine.
Since:
SkyMonome v1.3

setDivisions


public void setDivisions(int divisions)
Modifies the number of divisions by quarter note of this sequencer engine.

Parameters:
divisions - New number of divisions by quarter note used by this sequencer engine.
Since:
SkyMonome v1.3

getTempo


public float getTempo()
Returns the current tempo of this sequencer engine.

Returns:
The current tempo of this sequencer engine.
Since:
SkyMonome v1.3

setTempo


public void setTempo(float tempo)
Modifies the tempo of this sequencer engine.

Parameters:
tempo - New tempo for this sequencer engine.
Since:
SkyMonome v1.3

setTempo


public void setTempo(float tempo,

                     int divisions)
Modified the tempo and the number of divisions by quarter note currently used by this sequencer engine.

Parameters:
tempo - New tempo for this sequencer engine.
divisions - New number of divisions by quarter note used by this sequencer engine.
Since:
SkyMonome v1.3

getSequencers


public S[] getSequencers()
Returns an array of all associated sequencers.

Returns:
An array of all associated sequencers.

addSequencer


public void addSequencer(S sequencer)
Adds the specified sequencer to the list of associated sequencers.

Parameters:
sequencer - Sequencer to add to the list of associated sequencers.

removeSequencer


public void removeSequencer(S sequencer)
Removes the specified sequencer from the list of associated sequencers.

Parameters:
sequencer - Sequencer to remove from the list of associated sequencers.

removeSequencers


public void removeSequencers()
Removes all sequencers from the list of associated sequencers.


refreshMonome


public void refreshMonome()

                   throws MonomeException
Refreshes the physical Monome device. This method garantees the fastest way to refresh the physical Monome device, but the difference is significant only when your Monome tree is very deep.

Throws:
MonomeException - When the Monome device can't be refreshed.

getTimeBetweenSteps


public double getTimeBetweenSteps()
Returns the calculated time between two consecutive steps.

Returns:
The calculated time between two consecutive steps.

run


public void run()
Invoked by the virtual machine to execute this thread.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread