Class MIDITrack

java.lang.Object
   |
   +----MIDITrack

public class MIDITrack
extends Object
A MIDITrack-instance stores all MIDI-events of a track. It includes methods for deleting and inserting MIDI-events.

Variable Index

 o eventVector
Vector for storing MIDI-events.
 o trackNumber
Number (or ID) of track.
 o valid
Marks track as valid (or not).

Constructor Index

 o MIDITrack(FileInputStream)
Creates an MIDITrack, reading its data from concerning file.

Method Index

 o deleteEvent(int, int, int, byte[])
Removes all MIDI-events described by the parameters.
 o deleteEvent(MIDIEvent, int)
Removes all events equal to specified MIDI-event.
 o fromMIDI(FileInputStream)
All neccessary MIDITrack-data is read from a standard MIDI-file.
 o fromTXT(FileInputStream)
All neccessary MIDITrack-data is read from an ASCII MIDITXT-file.
 o insertEvent(MIDIEvent)
Inserts specified MIDIEvent to eventVector if not exists jet.
 o setTrackNumber(int)
Sets trackID.
 o size()
Size in Bytes needed to represent this MIDITrack in a standard MIDI-file.
 o toMIDI(FileOutputStream)
Writes itself to a standard MIDI-file.
 o toTXT(FileOutputStream)
Writes itself to an ASCII MIDITXT-file.
 o trackNumber()
Returns trackID.
 o valid()
Returns valid.

Variables

 o trackNumber
 int trackNumber
Number (or ID) of track.

 o valid
 boolean valid
Marks track as valid (or not).

 o eventVector
 Vector eventVector
Vector for storing MIDI-events.

Constructors

 o MIDITrack
 public MIDITrack(FileInputStream readFile) throws MIDIException
Creates MIDI-track concerning to the specified file.
Throws Exception if MIDI-track is not creatable with this file.

Filetype must be declared before: setFileType.

Methods

 o valid
 public boolean valid()
Returns valid.

 o trackNumber
 public int trackNumber()
Returns TrackID.

 o setTrackNumber
 public void setTrackNumber(int i)
Sets TrackID to i.

 o fromTXT
 void fromTXT(FileInputStream readFile) throws MIDIException
Reads all data for MIDI-track from ASCII MIDITXT-file readFile.
Throws Exception if MIDI-track is not creatable with this file.

This method should only be called by the constructor!

 o fromMIDI
 void fromMIDI(FileInputStream readFile) throws MIDIException
Reads all data for MIDI-track from standard MIDI-file readFile.
Throws Exception if MIDI-track is not creatable with this file.

This method should only be called by the constructor!

 o toTXT
 public void toTXT(FileOutputStream writeFile) throws MIDIException
Writes whole MIDITrack to ASCII MIDITXT-file writeFile.
Throws Exception if an IOError occurs.

 o toMIDI
 public void toMIDI(FileOutputStream writeFile) throws MIDIException
Writes whole MIDITrack to standard MIDI-file writeFile.
Throws Exception if an IOError occurs.

 o size
 public int size() throws MIDIException
Amount of Bytes needed to represent MIDI-track in a standard MIDI-file.
Throws Exception if MIDI-events are found, that are not representable
in a standard MIDI-file.

 o insertEvent
 void insertEvent(MIDIEvent insert)
Inserts MIDIEvent insert to eventVector if equal Event does not exist.
(All equal MIDIEvents are deleted before inserting!)

 o deleteEvent
 void deleteEvent(int absTime,
                  int status,
                  int chn,
                  byte data[])
Every MIDI-event that is described by the parameters is deleted.
absTime...absTime of event, or any time if absTime = -1.
status...event has statusByte status, or any statusByte if status = -1.
chn...event is send to MIDI-channel chn, or any MIDI-channel if chn = -1.
data[]...event has this following dataBytes, any if data = null.

If data is not null, data.length must be same as amount of dataBytes of event.
Each dataByte must be equal to events dataBytes, except dataBytes valued -1.

If event is not a voice-message, you must set chn to the lower 4bit of status.
(eg. to delete event with statusByte = 0xf7, status = 0xfn, chn = 0x07)

 o deleteEvent
 void deleteEvent(MIDIEvent compare,
                  int chn)
Every MIDI-event that is equal to MIDIEvent compare is deleted.
Also see deleteEvent.