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.
-
division
- The amount of parts each quarter (frame) is divided in.
-
format
- The format or type of the MIDI-file.
-
numTracks
- Number of tracks existing in this MIDI-file.
-
RMID
- Marks MIDI-file to be IFF-compatible.
-
SMPTE
- Number of frames per second.
-
trackVector
- Vector that stores all MIDI-tracks.
-
MIDI(FileInputStream)
- Constructs a MIDI-instance concerning to the specified file.
-
deleteEvent(int, int, int, int, byte[])
- Removes all MIDI-events described by the parameters.
-
deleteMIDI(MIDI)
- Deletes all MIDI-events that are equal to the ones in the specified MIDI-object.
-
deleteTrack(int)
- Deletes one MIDI-track.
-
fromMIDI(FileInputStream)
- All neccessary MIDI-data is read from a standard MIDI-file.
-
fromTXT(FileInputStream)
- All neccessary MIDI-data is read from an ASCII MIDITXT-file.
-
insertMIDI(MIDI)
- Inserts all MIDI-events of the specified MIDI-object.
-
posOfTrack(int)
- Returns the position of a MIDI-track in the trackVector.
-
setEndOfTrack()
- An EndOfTrack-Event is stored at the end of each MIDI-track.
-
size()
- Size in Bytes needed to represent this MIDI-object in a standard MIDI-file.
-
timeCorrect()
- Returns corrective value for different time-based events.
-
toMIDI(FileOutputStream)
- Writes itself to a standard MIDI-file.
-
toTXT(FileOutputStream)
- Writes itself to an ASCII MIDITXT-file.
RMID
boolean RMID
- IFF-compatible if true.
format
int format
- 0...SingleTrack,1...MultiTrack,2...Song.
numTracks
int numTracks
- Number of tracks in this MIDI-object.
SMPTE
int SMPTE
- Framerate: 24, 25, 29 or 30 frames per second.
0 if PPQN instead of SMPTE.
division
int division
- Number of parts each quarter (frame) is divided in.
trackVector
Vector trackVector
- Vector stores all MIDI-tracks.
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.
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!
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!
toTXT
public void toTXT(FileOutputStream writeFile) throws MIDIException
- Writes all MIDI-data to ASCII MIDITXT-file writeFile.
Throws Exception if an error occurs.
toMIDI
public void toMIDI(FileOutputStream writeFile) throws MIDIException
- Writes all MIDI-data to standard MIDI-file writeFile.
Throws Exception if an error occurs.
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.
setEndOfTrack
void setEndOfTrack()
- Inserts exactly one EndOfTrack-event at the end of each track.
timeCorrect
double timeCorrect(MIDI m)
- Returns a double value, that when multiplied to any MIDI m events
absTime, ensures same timeBased time-counting.
insertMIDI
public void insertMIDI(MIDI insMidi)
- All MIDI-events represented by insMidi are inserted into this MIDI-instance,
if they are not existing yet.
deleteMIDI
public void deleteMIDI(MIDI delMidi)
- All events represented by delMidi are deleted from this MIDI-instance.
deleteTrack
public void deleteTrack(int trk)
- MIDI-track with number trk is deleted from this MIDI-instance.
posOfTrack
int posOfTrack(int trk)
- Position in trackVector for MIDI-track numbered trk is returned.
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)