org.jfugue
Class StreamingMidiEventManager

java.lang.Object
  extended by org.jfugue.StreamingMidiEventManager

public class StreamingMidiEventManager
extends java.lang.Object

Assists the StreamingMidiRenderer in converting Patterns to MIDI.

Version:
3.2
Author:
David Koelle
See Also:
StreamingPlayer

Constructor Summary
StreamingMidiEventManager(javax.sound.midi.Sequence sequence)
           
 
Method Summary
 void addEvent(int command, int data1)
          Adds a MIDI event to the current track.
 void addEvent(int command, int data1, int data2)
          Adds a MIDI event to the current track.
 void addMetaMessage(int type, byte[] bytes)
          Adds a MetaMessage to the current track.
 void addNoteOffEvent(int data1, int data2, int data3, boolean addNoteOn, boolean addNoteOff)
           
 void addNoteOnEvent(int data1, int data2, int data3, boolean addNoteOn, boolean addNoteOff)
          Adds a ShortMessage.NOTE_ON event to the current track, using attack and decay velocity values.
 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 setCurrentLayer(byte layer)
          Sets the current layer within the track to which new events will be added.
 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

StreamingMidiEventManager

public StreamingMidiEventManager(javax.sound.midi.Sequence sequence)
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

setCurrentLayer

public void setCurrentLayer(byte layer)
Sets the current layer within the track 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)

addMetaMessage

public void addMetaMessage(int type,
                           byte[] bytes)
Adds a MetaMessage to the current track.

Parameters:
command - the MIDI command represented by this message
data1 - the first data byte
data2 - the second data byte

addEvent

public void addEvent(int command,
                     int data1)
Adds a MIDI event to the current track.

Parameters:
command - the MIDI command represented by this message
data1 - the first data byte

addEvent

public void addEvent(int command,
                     int data1,
                     int data2)
Adds a MIDI event to the current track.

Parameters:
command - the MIDI command represented by this message
data1 - the first data byte
data2 - the second data byte

addNoteOnEvent

public void addNoteOnEvent(int data1,
                           int data2,
                           int data3,
                           boolean addNoteOn,
                           boolean addNoteOff)
Adds a ShortMessage.NOTE_ON event to the current track, using attack and decay velocity values. Also adds a ShortMessage.NOTE_OFF command for the note, using the duration parameter to space the NOTE_OFF command properly. Both the NOTE_ON and NOTE_OFF events can be suppressed. This is useful when notes are tied to other notes.

Parameters:
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
addNoteOn - whether a ShortMessage.NOTE_ON event should be created for for this event. For the end of a tied note, this should be false; otherwise it should be true.
addNoteOff - whether a ShortMessage.NOTE_OFF event should be created for for this event. For the start of a tied note, this should be false; otherwise it should be true.

addNoteOffEvent

public void addNoteOffEvent(int data1,
                            int data2,
                            int data3,
                            boolean addNoteOn,
                            boolean addNoteOff)

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