com.softsynth.midifile
Class MIDIFileImage

java.lang.Object
  extended by com.softsynth.midifile.MIDIFileImage
All Implemented Interfaces:
MIDIFileListener

public class MIDIFileImage
extends java.lang.Object
implements MIDIFileListener

Contains an image of a MIDIFile.

Author:
Phil Burk (C) 1999 SoftSynth.com

Field Summary
 int currentTrackIndex
           
 short division
           
 int format
           
 int ticksPerBeat
           
 MIDIFileTrack[] tracks
           
 
Constructor Summary
MIDIFileImage()
           
 
Method Summary
 void handleBeginTrack(int index)
          Called at the beginning of each track
 void handleEndTrack(int index)
          Called at the end of each track
 void handleEvent(int ticks, int command, int data1, int data2)
          Called when a MIDI Message event is encountered.
 void handleHeader(int format, int numTracks, short division)
          Called when the header is parsed.
 void handleMetaEvent(int ticks, int type, byte[] b)
          Called when a MetaEvent is encountered.
 void handleSysExF0(int ticks, byte[] b)
          Called when an F0 SysEx event is encountered.
 void handleSysExF7(int ticks, byte[] b)
          Called when an F7 SysEx event is encountered.
static void main(java.lang.String[] args)
           
 void print()
           
 double ticksToSeconds(int ticks)
          Scan tempo map to determine real-time for a given tick.
 void write(MIDIFileOutput mfout)
          Write a MIDIFile image object to a MIDIFile on disk.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tracks

public MIDIFileTrack[] tracks

format

public int format

division

public short division

currentTrackIndex

public int currentTrackIndex

ticksPerBeat

public int ticksPerBeat
Constructor Detail

MIDIFileImage

public MIDIFileImage()
Method Detail

ticksToSeconds

public double ticksToSeconds(int ticks)
Scan tempo map to determine real-time for a given tick.


handleHeader

public void handleHeader(int format,
                         int numTracks,
                         short division)
Called when the header is parsed.

Specified by:
handleHeader in interface MIDIFileListener
Parameters:
format - Format of file. 0, 1 or 2.
numTracks -
division -

handleBeginTrack

public void handleBeginTrack(int index)
Called at the beginning of each track

Specified by:
handleBeginTrack in interface MIDIFileListener
Parameters:
index - Track index starting at zero

handleEndTrack

public void handleEndTrack(int index)
Called at the end of each track

Specified by:
handleEndTrack in interface MIDIFileListener
Parameters:
index - Track index starting at zero

handleSysExF0

public void handleSysExF0(int ticks,
                          byte[] b)
Called when an F0 SysEx event is encountered.

Specified by:
handleSysExF0 in interface MIDIFileListener
Parameters:
ticks - MIDIFile time-stamp
b - bytes read from file for SysEx. May be null.

handleSysExF7

public void handleSysExF7(int ticks,
                          byte[] b)
Called when an F7 SysEx event is encountered.

Specified by:
handleSysExF7 in interface MIDIFileListener
Parameters:
ticks - MIDIFile time-stamp
b - bytes read from file for SysEx. May be null.

handleMetaEvent

public void handleMetaEvent(int ticks,
                            int type,
                            byte[] b)
Called when a MetaEvent is encountered.

Specified by:
handleMetaEvent in interface MIDIFileListener
Parameters:
ticks - MIDIFile time-stamp
type - MetaEvent type, from 0 to 127.
b - bytes read from file for SysEx. May be null.

handleEvent

public void handleEvent(int ticks,
                        int command,
                        int data1,
                        int data2)
Called when a MIDI Message event is encountered.

Specified by:
handleEvent in interface MIDIFileListener
Parameters:
ticks - MIDIFile time-stamp
command - MIDI Command, eg. NOTE_ON.
data1 - First data byte of message.
data2 - Second optional data byte of message.

print

public void print()

write

public void write(MIDIFileOutput mfout)
           throws java.io.IOException
Write a MIDIFile image object to a MIDIFile on disk.

Throws:
java.io.IOException

main

public static void main(java.lang.String[] args)