Class MIDI

java.lang.Object
   |
   +----MIDI

class MIDI
extends Object
An instance of MIDI stores a whole standard MIDI-file existing of the header
and the tracks with MIDI-Events.
This class also provides methods to insert and delete other MIDI-instances
of itself, and methods to delete a MIDITrack or MIDIEvents.

Variable Index

 o division
The amount of parts each quarter (frame) is divided in.
 o format
The format or type of the MIDI-file.
 o numTracks
Number of tracks existing in this MIDI-file.
 o RMID
Marks MIDI-file to be IFF-compatible.
 o SMPTE
Number of frames per second.
 o trackVector
Vector that stores all MIDI-tracks.

Constructor Index

 o MIDI(FileInputStream)
Constructs a MIDI-instance concerning to the specified file.

Method Index

 o deleteEvent(int, int, int, int, byte[])
Removes all MIDI-events described by the parameters.
 o deleteMIDI(MIDI)
Deletes all MIDI-events that are equal to the ones in the specified MIDI-object.
 o deleteTrack(int)
Deletes one MIDI-track.
 o fromMIDI(FileInputStream)
All neccessary MIDI-data is read from a standard MIDI-file.
 o fromTXT(FileInputStream)
All neccessary MIDI-data is read from an ASCII MIDITXT-file.
 o insertMIDI(MIDI)
Inserts all MIDI-events of the specified MIDI-object.
 o posOfTrack(int)
Returns the position of a MIDI-track in the trackVector.
 o setEndOfTrack()
An EndOfTrack-Event is stored at the end of each MIDI-track.
 o size()
Size in Bytes needed to represent this MIDI-object in a standard MIDI-file.
 o timeCorrect()
Returns corrective value for different time-based events.
 o toMIDI(FileOutputStream)
Writes itself to a standard MIDI-file.
 o toTXT(FileOutputStream)
Writes itself to an ASCII MIDITXT-file.

Variables

 o RMID
 boolean RMID
IFF-compatible if true.

 o format
 int format
0...SingleTrack,1...MultiTrack,2...Song.

 o numTracks
 int numTracks
Number of tracks in this MIDI-object.

 o SMPTE
 int SMPTE
Framerate: 24, 25, 29 or 30 frames per second.
0 if PPQN instead of SMPTE.

 o division
 int division
Number of parts each quarter (frame) is divided in.

 o trackVector
 Vector trackVector
Vector stores all MIDI-tracks.

Constructors

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

Filetype must be declared before: setFileType.

Methods

 o fromTXT
 void fromTXT(FileInputStream readFile) throws MIDIException
Reads all data for MIDI-object from ASCII MIDITXT-file readFile.
Throws Exception if MIDI-object 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-object from standard MIDI-file readFile.
Throws Exception if MIDI-object 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 all MIDI-data to ASCII MIDITXT-file writeFile.
Throws Exception if an error occurs.

 o toMIDI
 public void toMIDI(FileOutputStream writeFile) throws MIDIException
Writes all MIDI-data to standard MIDI-file writeFile.
Throws Exception if an error occurs.

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

 o setEndOfTrack
 void setEndOfTrack()
Inserts exactly one EndOfTrack-event at the end of each track.

 o timeCorrect
 double timeCorrect(MIDI m)
Returns a double value, that when multiplied to any MIDI m events
absTime, ensures same timeBased time-counting.

 o insertMIDI
 public void insertMIDI(MIDI insMidi)
All MIDI-events represented by insMidi are inserted into this MIDI-instance,
if they are not existing yet.

 o deleteMIDI
 public void deleteMIDI(MIDI delMidi)
All events represented by delMidi are deleted from this MIDI-instance.

 o deleteTrack
 public void deleteTrack(int trk)
MIDI-track with number trk is deleted from this MIDI-instance.

 o posOfTrack
 int posOfTrack(int trk)
Position in trackVector for MIDI-track numbered trk is returned.

 o deleteEvent
 public void deleteEvent(int trk,
                         int absTime,
                         int status,
                         int chn,
                         byte data[])
Every MIDI-event that is described by the parameters is deleted.
trk...event is in MIDI-track numbered trk, or in any MIDI-track if trk = -1.
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)