com.frinika.sequencer
Class FrinikaTrackWrapper

java.lang.Object
  extended by com.frinika.sequencer.FrinikaTrackWrapper

public class FrinikaTrackWrapper
extends java.lang.Object

An extended version of the Track class in javax.sound.midi. The purpose of the extension is to make the Sequencer player able to request all events for a given tick, rather than having to perform a binary search, or keeping a track index to get them. For the track mapping to remain consistent - it is important NOT to modify the MidiEvent objects separately. If a MIDI event needs to be changed, it should be removed and then added again to this Track.

Author:
Peter Johan Salomonsen

Field Summary
static int CHANNEL_FROM_EVENT
          Indicates that the channel defined in the multievents should not be overridden by the channel set in this track
 
Method Summary
 boolean add(javax.sound.midi.MidiEvent event)
          Add a MidiEvent to the track - note that you should normally use MultiEvents instead of MidiEvents
 void attachToSequence()
           
 void clear()
          clear this track of all events except the "META END OF TRACK" (PJL tempo track rebuild)
 void detachFromSequence()
           
 javax.sound.midi.MidiEvent get(int index)
          Return MidiEvent at a given index in the track
 java.util.Vector<javax.sound.midi.MidiMessage> getControllerStateAtTick(long tick)
          Return a list of midimessages in order to restore controller states at a specific tick.
 EditHistoryContainer getEditHistoryContainer()
           
 java.util.Vector<javax.sound.midi.MidiEvent> getEventsForTick(long tick)
          Used by the sequencer player to get the messages it should play at a certain position
 int getMidiChannel()
           
 javax.sound.midi.MidiDevice getMidiDevice()
           
 FrinikaSequence getSequence()
           
 long lastTickUsed()
           
 boolean remove(javax.sound.midi.MidiEvent event)
          Remove a MidiEvent from the track - Note that you should normally use MultiEvents instead of MidiEvents
 void setMidiChannel(int midiChannel)
          Set the midi channel for this track
 void setMidiDevice(javax.sound.midi.MidiDevice midiDevice)
           
 void setSequence(FrinikaSequence sequence)
           
 int size()
          Return number of MidiEvents in track
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHANNEL_FROM_EVENT

public static final int CHANNEL_FROM_EVENT
Indicates that the channel defined in the multievents should not be overridden by the channel set in this track

See Also:
Constant Field Values
Method Detail

clear

public void clear()
clear this track of all events except the "META END OF TRACK" (PJL tempo track rebuild)


add

public boolean add(javax.sound.midi.MidiEvent event)
Add a MidiEvent to the track - note that you should normally use MultiEvents instead of MidiEvents

Parameters:
event -
Returns:

remove

public boolean remove(javax.sound.midi.MidiEvent event)
Remove a MidiEvent from the track - Note that you should normally use MultiEvents instead of MidiEvents

Parameters:
event -
Returns:

size

public int size()
Return number of MidiEvents in track

Returns:

get

public javax.sound.midi.MidiEvent get(int index)
Return MidiEvent at a given index in the track

Parameters:
index -
Returns:

getEventsForTick

public java.util.Vector<javax.sound.midi.MidiEvent> getEventsForTick(long tick)
Used by the sequencer player to get the messages it should play at a certain position

Parameters:
tick -
Returns:

getControllerStateAtTick

public java.util.Vector<javax.sound.midi.MidiMessage> getControllerStateAtTick(long tick)
Return a list of midimessages in order to restore controller states at a specific tick. Used when looping a sequence, or when starting playback in the middle of the song. This is a replacement for the chasing mechanism in the JSE RealtimeSequencer implementation.

Parameters:
tick -
Returns:

getSequence

public FrinikaSequence getSequence()
Returns:
Returns the sequence.

setSequence

public void setSequence(FrinikaSequence sequence)

getMidiChannel

public int getMidiChannel()
Returns:
Returns the midi channel for this track

setMidiChannel

public void setMidiChannel(int midiChannel)
Set the midi channel for this track

Parameters:
midiChannel -

getMidiDevice

public javax.sound.midi.MidiDevice getMidiDevice()
Returns:
Returns the midiDevice.

setMidiDevice

public void setMidiDevice(javax.sound.midi.MidiDevice midiDevice)
Parameters:
midiDevice - The midiDevice to set.

getEditHistoryContainer

public EditHistoryContainer getEditHistoryContainer()

attachToSequence

public void attachToSequence()

detachFromSequence

public void detachFromSequence()

lastTickUsed

public long lastTickUsed()