com.e1.mxdublin
Class Trail

java.lang.Object
  extended by com.e1.mxdublin.core.SeqEvent
      extended by com.e1.mxdublin.Trail
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
TrailClockStat, TrailEventList

public abstract class Trail
extends SeqEvent

Basic implementation of the dublin callback object.

A trail looks like a thread where it do something (like playing a note, sending a bang) and then call next() of event() method to be called again.

By design, a trail always loop over it self if it has played all the events. Also, a trail never knows when it should be started or stopped.


Field Summary
protected  boolean clocked
          Tells if the trail is waiting for a new event.
 boolean globalStart
          By setting this to true, when the user issue a global start, this trail will also be started.
 boolean globalStop
          By setting this to true, when the user issue a global stop, this trail will also be stopped.
protected  int last
          The value in quarter note when the last event/next has been issued.
 int quantizeCtrl
          Start/stop quantizing reference.
protected  boolean started
          Tells if the trail has been started.
 TrailView view
          The editor of this this trail, if it can be edited.
 
Fields inherited from class com.e1.mxdublin.core.SeqEvent
mandatory
 
Constructor Summary
Trail()
           
Trail(String name)
          Trail constructor.
 
Method Summary
 void dispose()
          Remove trail from registry and cancels any events.
 void event(int tm)
          Sets when the next call should be issued since start or reset.
 void eventf(float tm)
          Sets when the next call should be issued since start or reset
protected  TrailView factoryView(DublinProject project)
          Trails must returns a Swing TrailView object if they want to provide a gui editor to this trail.
static Trail fromXML(Element e)
          Return the Trail from the XML representation.
 String getName()
          Return trail name.
 int getTime()
          Return the current trail time in sequencer PPQ since the last start or reset.
 boolean isRunning()
          Returns true if the trail is running.
protected  void loadElement(Element e)
          Called when the trail is instantiated from fromXML(Element).
 void next(int tm)
          Sets when the next call should be issued since now.
 void nextf(float tm)
          Sets when the next call should be issued since now.
 void reset()
          Reset the event count to 0, so the reference of the event() method will be based on when this method has been called.
 void run()
          The action to be performed by this com.e1.mxdublin.core.SeqEvent based event.
 TrailView showView(DublinProject project)
           
 void start()
          Start trail by quantizing value from quantizeCtrl.
 void start(int tm)
          Starts trail now + tm.
 void stop()
          Stop trail and cancel any previous events.
abstract  void tick()
          Method to be called by the sequencer that has been sync by event() and next().
protected  Element toBaseXML()
          Returns the representation of this abstract trail.
 void toggle()
          Toggle the state of the trail.
 String toString()
          Return trail identification, setted by @see setName().
 Element toXML()
          Returns the XML representation of this Trail.
 
Methods inherited from class com.e1.mxdublin.core.SeqEvent
cancel, eventDebug
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

last

protected int last
The value in quarter note when the last event/next has been issued. This field will have a value of -1 on trail startup.


clocked

protected boolean clocked
Tells if the trail is waiting for a new event.


started

protected boolean started
Tells if the trail has been started.


globalStart

public boolean globalStart
By setting this to true, when the user issue a global start, this trail will also be started. If you don't want to start this trail when the user issue a global start, set this to false


globalStop

public boolean globalStop
By setting this to true, when the user issue a global stop, this trail will also be stopped. If you don't want to stop this trail when the user issue a global stop, set this to false


quantizeCtrl

public int quantizeCtrl
Start/stop quantizing reference. The default value is one quarter note. This quantizing will be done based on the last call to DublinSystem.markqn(). This method is called by the dublin instance when start without trails name or start_ref is used.


view

public TrailView view
The editor of this this trail, if it can be edited.

Constructor Detail

Trail

public Trail()

Trail

public Trail(String name)
Trail constructor. This will also register the trail to the DublinSystem class.

Method Detail

start

public void start()
Start trail by quantizing value from quantizeCtrl.

The trail startup will be quantized based on the last start or start_ref issued.


start

public void start(int tm)
Starts trail now + tm.

Parameters:
tm - time to start from now

stop

public void stop()
Stop trail and cancel any previous events.


toggle

public void toggle()
Toggle the state of the trail. If it is started, it will be stopped. If it is stopped, it will be started.


next

public void next(int tm)
Sets when the next call should be issued since now.

Parameters:
tm - since now to call tick in 480 PPQ

event

public void event(int tm)
Sets when the next call should be issued since start or reset.

Parameters:
tm - since start() to call tick in 480 PPQ

nextf

public void nextf(float tm)
Sets when the next call should be issued since now.

Parameters:
tm - since now to call tick in float (1.0 = 480PPQ)

eventf

public void eventf(float tm)
Sets when the next call should be issued since start or reset

Parameters:
tm - since start() to call tick in float (1.0 = 480PPQ)

reset

public void reset()
Reset the event count to 0, so the reference of the event() method will be based on when this method has been called. Be sure to make this call before any event or next() !


getTime

public int getTime()
Return the current trail time in sequencer PPQ since the last start or reset.

Returns:
trail time in 480 PPQ

dispose

public void dispose()
Remove trail from registry and cancels any events. The trail will be useless after this call.


getName

public String getName()
Return trail name. (toString also returns the trail status)


toString

public String toString()
Return trail identification, setted by @see setName(). Returns also the status of the trail.

Overrides:
toString in class Object
Returns:
String

isRunning

public boolean isRunning()
Returns true if the trail is running.

Returns:
true if the trail has issued new events

tick

public abstract void tick()
Method to be called by the sequencer that has been sync by event() and next().


loadElement

protected void loadElement(Element e)
Called when the trail is instantiated from fromXML(Element). Trails that support this feature should override this method to read extra definition from the XML element.

Parameters:
e - the original generic trail definition

fromXML

public static Trail fromXML(Element e)
Return the Trail from the XML representation. Once the Trail is instantiated with the right type, loadElement(Element) will be called.

Parameters:
e - the XML element

toBaseXML

protected Element toBaseXML()
Returns the representation of this abstract trail. The extended trail should then add specific data to the element. This means that this method will create a `trail` element with the attribute `type` and `name`.

Returns:
the basic XML representation

toXML

public Element toXML()
Returns the XML representation of this Trail. Returns null if the trail doesn't support serialization (the default).

Returns:
the Trail representation in XML

factoryView

protected TrailView factoryView(DublinProject project)
Trails must returns a Swing TrailView object if they want to provide a gui editor to this trail.

Returns:
trail view of this trail.

showView

public final TrailView showView(DublinProject project)

run

public void run()
Description copied from class: SeqEvent
The action to be performed by this com.e1.mxdublin.core.SeqEvent based event.

Specified by:
run in interface Runnable
Specified by:
run in class SeqEvent