Skip to content

Commit

Permalink
Add python-midi to project
Browse files Browse the repository at this point in the history
  • Loading branch information
evanmhm authored and andrewda committed Mar 3, 2017
1 parent f19ac4a commit c0e56a3
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 36 deletions.
20 changes: 20 additions & 0 deletions examples/example_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import midi
# Instantiate a MIDI Pattern (contains a list of tracks)
pattern = midi.Pattern()
# Instantiate a MIDI Track (contains a list of MIDI events)
track = midi.Track()
# Append the track to the pattern
pattern.append(track)
# Instantiate a MIDI note on event, append it to the track
on = midi.NoteOnEvent(tick=0, velocity=20, pitch=midi.G_3)
track.append(on)
# Instantiate a MIDI note off event, append it to the track
off = midi.NoteOffEvent(tick=100, pitch=midi.G_3)
track.append(off)
# Add the end of track event, append it to the track
eot = midi.EndOfTrackEvent(tick=1)
track.append(eot)
# Print out the pattern
print pattern
# Save the pattern to disk
midi.write_midifile("example.mid", pattern)
3 changes: 3 additions & 0 deletions examples/example_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import midi
pattern = midi.read_midifile("test.mid")
print pattern
Binary file added midi/mary.mid
Binary file not shown.
Binary file added midi/test.mid
Binary file not shown.
Binary file removed output.mid
Binary file not shown.
5 changes: 2 additions & 3 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import src.markov as markov
from markov import MarkovChain
import loadMIDI
import midi

from . import args

Expand All @@ -11,9 +11,8 @@ def __init__(self):
self.args = args

def run(self):
loadMIDI.testWrite()
mc = MarkovChain(10)
mc.add_file('bible.txt')
mc.add_file('book.txt')
while (True):
str = raw_input('\npress enter to generate new text')
print str
Expand Down
33 changes: 0 additions & 33 deletions src/loadMIDI.py

This file was deleted.

0 comments on commit c0e56a3

Please sign in to comment.