DixShtix

com.dixshtix.midi
Class Track

java.lang.Object
  |
  +--com.dixshtix.midi.Track
All Implemented Interfaces:
Chunk

public class Track
extends java.lang.Object
implements Chunk

Wrapper class for array of Event.

The MTrk chunk type is where actual song data is stored. It is simply a stream of MIDI events (and non-MIDI events), preceded by delta-time values.

Version:
0.1
Author:
Richard C. Penner II

Field Summary
(package private)  byte[] data
          A stream of bytes, usually full of Midi data.
(package private)  Event[] events
          Musical (MIDI) events.
static byte[] kDefaultType
          Each Track has a type of 'MTrk'.
(package private)  byte[] tr_type
          Four bytes indicating the Chunk type.
 
Fields inherited from interface com.dixshtix.midi.Chunk
kMThd, kMTrk
 
Constructor Summary
Track(byte[] data)
          Construct a MIDI Track from Midi data bytes.
Track(byte[] data, boolean eot_magic, EventType[] incl, EventType[] excl, EventCallback pre_processor)
          Construct a MIDI Track from Midi data bytes, with some pre-processing.
Track(byte[] tr_type, byte[] data)
          Construct a Track from raw data, with possibly a non-std tr_type.
Track(byte[] tr_type, byte[] data, Event[] events)
          Construct a Track from raw data.
Track(Event[] events, boolean eot_magic, boolean add_eot, boolean running_status, EventCallback unknown_processor)
          Construct a MIDI Track from Midi events, with some processing.
 
Method Summary
 byte[] getData()
          Returns arbitrary array of bytes.
 Event[] getEvents()
          Returns array of events.
 int getLength()
          Track length in number of bytes.
 byte[] getType()
          Returns Chunk Type of the Track.
 void setEvents(Event[] evnts)
          Set the MIDI events, keeping the data synchronized.
 void setEvents(Event[] evnts, boolean eot_magic, boolean add_eot, boolean running_status, EventCallback unknown_processor)
          Set the MIDI Events, with options when creating the data.
 java.lang.String toString()
          Produce a short, human-readable string.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

kDefaultType

public static final byte[] kDefaultType
Each Track has a type of 'MTrk'.
See Also:
Chunk.kMTrk

tr_type

byte[] tr_type
Four bytes indicating the Chunk type. Normally these are the same as Chunk.kMTrk, but other Tracks can exist and have non-Midi data.

data

byte[] data
A stream of bytes, usually full of Midi data. This is just raw data in the event this is not Midi data.

events

Event[] events
Musical (MIDI) events.
See Also:
Event
Constructor Detail

Track

public Track(byte[] tr_type,
             byte[] data,
             Event[] events)
Construct a Track from raw data.
Parameters:
tr_type - Four characters which represent the track type.
data - A stream of bytes.
events - Possibly a stream of MIDI Events.

Track

public Track(byte[] data)
Construct a MIDI Track from Midi data bytes. This assumes a default tr_type and constructs events from the wonderful function Event.decode(byte[],boolean,EventType[],EventType[],EventCallback,EventCallback).
Parameters:
data - A stream of bytes.

Track

public Track(byte[] data,
             boolean eot_magic,
             EventType[] incl,
             EventType[] excl,
             EventCallback pre_processor)
Construct a MIDI Track from Midi data bytes, with some pre-processing. This assumes a default tr_type and constructs events from the wonderful function Event.decode(byte[],boolean,EventType[],EventType[],EventCallback,EventCallback).
Parameters:
data - A stream of bytes.
eot_magic - Substitute zero-length text for End of Track. Allows for easy appends.
incl - List of EventTypes to include, excluding all others.
excl - List of EventTypes to exclude. Not compatible with incl.
pre_processor - WriteBack to pre-massage event stream.

Track

public Track(Event[] events,
             boolean eot_magic,
             boolean add_eot,
             boolean running_status,
             EventCallback unknown_processor)
Construct a MIDI Track from Midi events, with some processing.
Parameters:
events - Possibly a stream of MIDI Events.
eot_magic - Use zero-length text events to mark end of Track.
add_eot - Force array to end with End of Track Event.
running_status - Compress Voice output (marginally).
unknown_processor - Don't throw Errors if defined.
See Also:
Event.encode(Event[],boolean,boolean,boolean,EventCallback)

Track

public Track(byte[] tr_type,
             byte[] data)
Construct a Track from raw data, with possibly a non-std tr_type.
Parameters:
tr_type - Four characters which represent the track type.
data - A stream of bytes.
Method Detail

getLength

public int getLength()
Track length in number of bytes.

getType

public byte[] getType()
Returns Chunk Type of the Track.

getData

public byte[] getData()
Returns arbitrary array of bytes. This is exactly what you store in the file.

getEvents

public Event[] getEvents()
Returns array of events.

setEvents

public void setEvents(Event[] evnts)
Set the MIDI events, keeping the data synchronized.

setEvents

public void setEvents(Event[] evnts,
                      boolean eot_magic,
                      boolean add_eot,
                      boolean running_status,
                      EventCallback unknown_processor)
Set the MIDI Events, with options when creating the data.
Parameters:
evnts - Array of MIDI events in out internal format.
eot_magic - Use zero-length text events to mark end of Track.
add_eot - Force array to end with End of Track Event.
running_status - Compress Voice output (marginally).
unknown_processor - Don't throw Errors if defined.

toString

public java.lang.String toString()
Produce a short, human-readable string. This String only describes the Track header, and not the events.
Overrides:
toString in class java.lang.Object

DixShtix