0

Does anybody know a Java MIDI parser that will parse a MIDI into a tree like data structure where the nodes will be items such as the MTrks? I am doing some work on analyzing written music music and I want a format that contains hundreds of sample songs. Does anybody have a favorite format?

Mikhail
  • 7,749
  • 11
  • 62
  • 136
  • MIDI may not be the best, depending on what analysis you are trying to perform. MIDI was originally for simple control of synthesizers, not written form of music. While you can convert somewhat, many of the written elements are lost. – Brad Apr 09 '12 at 01:53
  • Any suggestions as to a better file format would be greatly appreciated. – Mikhail Apr 09 '12 at 02:09
  • It is hard to suggest something without knowing what kind of analysis you are trying to perform. – Brad Apr 09 '12 at 02:16
  • For now, my instrument decodes a "note" and I want to compare this note to note in the sheet music. – Mikhail Apr 09 '12 at 02:17
  • What is your instrument? "Decodes" from what? "Decodes" to what? what format is the sheet music in now? Do you need some sort of OCR for printed or scanned music? Or is it in some electronic format? – Brad Apr 09 '12 at 02:19
  • I have the acquisition part working. The acquisition happens in real time and results in two variables the note ("C#4") and an associated time. – Mikhail Apr 09 '12 at 02:22

2 Answers2

1

Actually MIDI file is a list of MIDI events, where event is a note, expression change, sustain pedal etc. Events are grouped by MIDI channel. So anyway you will work with events. What about parser, have you tried out http://docs.oracle.com/javase/6/docs/api/javax/sound/midi/package-summary.html?

Alexey Berezkin
  • 1,513
  • 1
  • 10
  • 18
  • I was aware of the javax parser but I am targeting a platform without javax (Android). I probably should have made that clear. – Mikhail Apr 09 '12 at 09:16
  • 1
    Even if your target platform does not have full JavaSE implementation, you can use standard Java libraries just as imported JARs to your project. There is utilities that allow using JARs in Android. – Alexey Berezkin Apr 09 '12 at 09:20
0

There's also a bare-bones Java implementation of the MIDI file format up on Google Code:

http://code.google.com/p/android-midi-lib/

LeffelMania
  • 12,765
  • 4
  • 32
  • 34