edu.columbia.ee.csmit.MidiKaraoke.examples
Class RawParserExample

java.lang.Object
  extended by edu.columbia.ee.csmit.MidiKaraoke.examples.RawParserExample

public class RawParserExample
extends java.lang.Object

Shows how to use the RawMidiMessageParser. The RawMidiMessageParser basically can parse a single MidiCommand, which might be a NoteOn, ControlChange, Lyric, etc.

    public static void main(String[] args) {

        if(args.length == 0){
            System.out.println("Usage: RawParserExample [midi file name]");
            return;
        }


        try {

            File file = new File(args[0]);
            Sequence mySeq = MidiSystem.getSequence(file);

            RawMidiMessageParser parser = new RawMidiMessageParser();

            Track[] tracks = mySeq.getTracks();

            for (int i = 0; i < tracks.length; i++) {
                for (int j = 0; j < tracks[i].size(); j++) {
                    MidiEvent me = tracks[i].get(j);
                    MidiCommand mc = parser.parse(me.getMessage());

                    System.out.println(i + "(" + me.getTick() + "): " + mc);
                }
            }


        } catch (Exception e) {
            System.out.println("Problem!");
            e.printStackTrace();
            System.out.println(e.toString());
        }

    }

 


Constructor Summary
RawParserExample()
           
 
Method Summary
static void main(java.lang.String[] args)
          Shows how to use the RawMidiMessageParser to parse midi commands in a Sequence.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RawParserExample

public RawParserExample()
Method Detail

main

public static void main(java.lang.String[] args)
Shows how to use the RawMidiMessageParser to parse midi commands in a Sequence. Prints out the midi commands it reads.

Parameters:
args - the command line arguments. The first (and only) argument should be the name of a midi file.