org.jfugue
Class EventManager

java.lang.Object
  |
  +--org.jfugue.EventManager

public class EventManager
extends java.lang.Object

Places musical data into the MIDI sequence.

Version:
2.0
Author:
David Koelle

Constructor Summary
EventManager()
           
 
Method Summary
 void addEvent(int command, int data1, int data2, int data3, long duration)
          Adds a ShortMessage.NOTE_ON event to the current track, using attack and decay velocity values.
 void addEvent(int command, int data1, int data2, long duration)
          Adds a MIDI event to the current track.
 void advanceTrackTimer(long duration)
          Advances the timer for the current track by the specified duration, which is specified in Pulses Per Quarter (PPQ)
 javax.sound.midi.Sequence getSequence()
          Returns the current sequence, which is a collection of tracks.
 long getTrackTimer()
          Returns the timer for the current track.
 void setCurrentTrack(byte track)
          Sets the current track, or channel, to which new events will be added.
 void setTrackTimer(long newTime)
          Sets the timer for the current track by the given time, which is specified in Pulses Per Quarter (PPQ)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventManager

public EventManager()
Method Detail

setCurrentTrack

public void setCurrentTrack(byte track)
Sets the current track, or channel, to which new events will be added.
Parameters:
track - the track to select

advanceTrackTimer

public void advanceTrackTimer(long duration)
Advances the timer for the current track by the specified duration, which is specified in Pulses Per Quarter (PPQ)
Parameters:
duration - the duration to increase the track timer

setTrackTimer

public void setTrackTimer(long newTime)
Sets the timer for the current track by the given time, which is specified in Pulses Per Quarter (PPQ)
Parameters:
newTime - the time at which to set the track timer

getTrackTimer

public long getTrackTimer()
Returns the timer for the current track.
Returns:
the timer value for the current track, specified in Pulses Per Quarter (PPQ)

addEvent

public void addEvent(int command,
                     int data1,
                     int data2,
                     long duration)
Adds a MIDI event to the current track. If the command passed to addEvent is a ShortMessage.NOTE_ON command, then this method will automatically add a ShortMessage.NOTE_OFF command for the note, using the duration parameter to space the NOTE_OFF command properly.
Parameters:
command - the MIDI command represented by this message
data1 - the first data byte
data2 - the second data byte
duration - for Note events, the duration of the note

addEvent

public void addEvent(int command,
                     int data1,
                     int data2,
                     int data3,
                     long duration)
Adds a ShortMessage.NOTE_ON event to the current track, using attack and decay velocity values. This method will automatically add a ShortMessage.NOTE_OFF command for the note, using the duration parameter to space the NOTE_OFF command properly.
Parameters:
command - the NOTE_ON command. If another command is given, this method will call addEvent(command, data1, data2, duration)
data1 - the first data byte, which contains the note value
data2 - the second data byte for the NOTE_ON event, which contains the attack velocity
data3 - the second data byte for the NOTE_OFF event, which contains the decay velocity
duration - the duration of the note

getSequence

public javax.sound.midi.Sequence getSequence()
Returns the current sequence, which is a collection of tracks. If your goal is to add events to the sequence, you don't want to use this method to get the sequence; instead, use the addEvent methods to add your events.
Returns:
the current sequence