Friday, January 27, 2017

JFugue Jython Example 11. See the Contents of a MIDI File in Human-Readable and Machine-Parseable Staccato Format

This is Example 11 from JFugue website (JFugue Examples) in Jython.



# JFugue 11. See the Contents of a MIDI File in Human-Readable
# and Machine-Parseable Staccato Format

'''
Want to see the music in your MIDI file? Of course,
you could load it in a sheet music tool. Here's how you can load it
with JFugue. You'll get a Pattern of your music, which you can then
pick apart in interesting ways (for example, count how many "C" notes
there are... that's coming up in a few examples)
'''

import sys
sys.path.append("C:/jfugue-5.0.7.jar")

from java.io import File, FileNotFoundException
from org.jfugue.midi import MidiFileManager


try:
    pattern = MidiFileManager.loadPatternFromMidi(File("RowYourBoat.mid"))
except FileNotFoundException:
    print "file not found"
    pattern = None

pat = pattern.toString().split(" ")
for p in pat: print p

No comments:

Post a Comment