|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.softsynth.jmsl.util.MIDIFileToMusicShape
public class MIDIFileToMusicShape
MIDIFileToMusicShape Parse a MidiFile and build a ParallelCollection of MusicShape
If the MidiFile is Type 1 (which includes Track chunks), one MusicShape will be created for each
track.
If the Midifile is Type 0 (one single mixed track), one MusicShape will be created for each Midi
Channel detected.
Usage:
MIDIFileToMusicShape mf2ms = new MIDIFileToMusicShape(); String filename = "myMidiFile.MID"; mf2ms.convertMIDIFile(filename); ParallelCollection p = mf2ms.getParallelCollection(); // subtract the startTime of the first event from all event times (optional) mf2ms.startAtZero(); // durations of MusicShapes in ParallelCollection are in absolute time. // To convert to delta (relative) time, do this, which operates on the // MusicShapes in p, and converts their time dimensions: mf2ms.differentiate(); // if you are going to play these with amplitudes ranging 0..1 do this: mf2ms.normalizeAmplitudes();
Constructor Summary | |
---|---|
MIDIFileToMusicShape()
|
Method Summary | |
---|---|
void |
convertMIDIFile(java.io.InputStream stream)
Read a midi file from an input stream and convert it to a a ParallelCollection of MusicShape |
void |
convertMIDIFile(java.lang.String fileName)
Read a midi file from disk and convert it to a ParallelCollection of MusicShape |
void |
differentiate()
Midi tracks are read into MusicShapes with absolute time in dimension 0. |
ParallelCollection |
getParallelCollection()
|
java.util.Vector |
getTempi()
|
java.util.Vector |
getTimeSignatures()
|
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 |
normalizeAmplitudes()
Scale midi velocities 0..127 to amplitudes 0..1 |
void |
setDebug(boolean b)
Show or hide printed messages |
void |
startAtZero()
Look for start time of first event of each MusicShape, and find the earliest. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MIDIFileToMusicShape()
Method Detail |
---|
public ParallelCollection getParallelCollection()
public java.util.Vector getTimeSignatures()
public void setDebug(boolean b)
public void handleHeader(int format, int numTracks, short division)
handleHeader
in interface MIDIFileListener
format
- Format of file. 0, 1 or 2.numTracks
- division
- public void handleBeginTrack(int index)
handleBeginTrack
in interface MIDIFileListener
index
- Track index starting at zeropublic void handleEndTrack(int index)
handleEndTrack
in interface MIDIFileListener
index
- Track index starting at zeropublic void handleSysExF0(int ticks, byte[] b)
handleSysExF0
in interface MIDIFileListener
ticks
- MIDIFile time-stampb
- bytes read from file for SysEx. May be null.public void handleSysExF7(int ticks, byte[] b)
handleSysExF7
in interface MIDIFileListener
ticks
- MIDIFile time-stampb
- bytes read from file for SysEx. May be null.public void handleMetaEvent(int ticks, int type, byte[] b)
handleMetaEvent
in interface MIDIFileListener
ticks
- MIDIFile time-stamptype
- MetaEvent type, from 0 to 127.b
- bytes read from file for SysEx. May be null.public void handleEvent(int ticks, int command, int data1, int data2)
handleEvent
in interface MIDIFileListener
ticks
- MIDIFile time-stampcommand
- MIDI Command, eg. NOTE_ON.data1
- First data byte of message.data2
- Second optional data byte of message.public void convertMIDIFile(java.lang.String fileName) throws java.io.IOException
java.io.IOException
public void convertMIDIFile(java.io.InputStream stream) throws java.io.IOException
java.io.IOException
public void differentiate()
public void normalizeAmplitudes()
public void startAtZero()
public java.util.Vector getTempi()
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |