danger.audio
Class MidiWriter

java.lang.Object
  extended by danger.audio.MidiWriter


public class MidiWriter
extends Object

Write a standard Midi file. OS 2.3


Field Summary
protected  int mCurrentTime
           
protected  ByteArrayOutputStream mCurrentTrack
           
protected  int mDivision
           
protected  int mFormat
           
protected  ByteArrayOutputStream mHeader
           
protected  int mLastTime
           
protected  int mNumberOfTracks
           
protected  Vector mTracks
           
 
Constructor Summary
MidiWriter()
           
 
Method Summary
 void afterTouch(byte channel, byte note, byte velocity, int time)
           
 void channelPressure(byte channel, byte velocity, int time)
           
 void controlChange(byte channel, byte controlNumber, byte controlValue, int time)
           
 void endTrack()
           
 void endTrack(int time)
           
 void header(int format, int division)
           
 void metaEvent(byte type, byte[] data, int time)
           
 void newTrack()
           
 void noteOff(byte channel, byte note, byte velocity, int time)
           
 void noteOn(byte channel, byte note, byte velocity, int time)
           
 void NRPN(byte channel, byte lsb, byte msb, byte value, int time)
          Non registered parameters
 void pitchBend(byte channel, byte lsb, byte msb, int time)
           
 void programBankChange(byte channel, byte programNumber, byte bankNumber, int time)
           
 void programChange(byte channel, byte programNumber, int time)
           
 void RPN(byte channel, byte lsb, byte msb, byte value, int time)
          GM Registered parameters
 void setTempo(int tempo, int time)
           
protected  void store16bit(ByteArrayOutputStream mf, int data)
           
protected  void store32bit(ByteArrayOutputStream mf, int data)
           
 void sysex(byte[] data)
           
 byte[] toByteArray()
          After providing all events, call this to return the finalized midi file.
protected  void writeTime(ByteArrayOutputStream track, int time)
           
protected  void writeVarLength(ByteArrayOutputStream mf, int value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mHeader

protected ByteArrayOutputStream mHeader

mCurrentTrack

protected ByteArrayOutputStream mCurrentTrack

mTracks

protected Vector mTracks

mCurrentTime

protected int mCurrentTime

mLastTime

protected int mLastTime

mFormat

protected int mFormat

mNumberOfTracks

protected int mNumberOfTracks

mDivision

protected int mDivision
Constructor Detail

MidiWriter

public MidiWriter()
Method Detail

toByteArray

public byte[] toByteArray()
After providing all events, call this to return the finalized midi file. This will clean up all the internal structures, thus rendering this object invalid.


header

public void header(int format,
                   int division)

newTrack

public void newTrack()

endTrack

public void endTrack()

endTrack

public void endTrack(int time)

setTempo

public void setTempo(int tempo,
                     int time)

metaEvent

public void metaEvent(byte type,
                      byte[] data,
                      int time)

noteOff

public void noteOff(byte channel,
                    byte note,
                    byte velocity,
                    int time)

noteOn

public void noteOn(byte channel,
                   byte note,
                   byte velocity,
                   int time)

afterTouch

public void afterTouch(byte channel,
                       byte note,
                       byte velocity,
                       int time)

channelPressure

public void channelPressure(byte channel,
                            byte velocity,
                            int time)

sysex

public void sysex(byte[] data)

controlChange

public void controlChange(byte channel,
                          byte controlNumber,
                          byte controlValue,
                          int time)

programBankChange

public void programBankChange(byte channel,
                              byte programNumber,
                              byte bankNumber,
                              int time)

programChange

public void programChange(byte channel,
                          byte programNumber,
                          int time)

pitchBend

public void pitchBend(byte channel,
                      byte lsb,
                      byte msb,
                      int time)

RPN

public void RPN(byte channel,
                byte lsb,
                byte msb,
                byte value,
                int time)
GM Registered parameters


NRPN

public void NRPN(byte channel,
                 byte lsb,
                 byte msb,
                 byte value,
                 int time)
Non registered parameters


writeTime

protected void writeTime(ByteArrayOutputStream track,
                         int time)

writeVarLength

protected void writeVarLength(ByteArrayOutputStream mf,
                              int value)

store32bit

protected void store32bit(ByteArrayOutputStream mf,
                          int data)

store16bit

protected void store16bit(ByteArrayOutputStream mf,
                          int data)