Permalink
Browse files

Logging and loading adjustments

  • Loading branch information...
1 parent c9f2954 commit 6cc2869161632a2d4800aa33e38f7e2673260027 @hexahedria committed Aug 1, 2015
Showing with 10 additions and 8 deletions.
  1. +7 −6 midi_to_statematrix.py
  2. +3 −2 multi_training.py
@@ -1,7 +1,7 @@
import midi, numpy
-lowerBound = 36
-upperBound = 92
+lowerBound = 24
+upperBound = 102
def midiToNoteStateMatrix(midifile):
@@ -31,17 +31,18 @@ def midiToNoteStateMatrix(midifile):
evt = track[pos]
if isinstance(evt, midi.NoteEvent):
- try:
+ if (evt.pitch < lowerBound) or (evt.pitch >= upperBound):
+ pass
+ # print "Note {} at time {} out of bounds (ignoring)".format(evt.pitch, time)
+ else:
if isinstance(evt, midi.NoteOffEvent) or evt.velocity == 0:
state[evt.pitch-lowerBound] = [0, 0]
else:
state[evt.pitch-lowerBound] = [1, 1]
- except IndexError:
- print "Note {} at time {} out of bounds (ignoring)".format(evt.pitch, time)
elif isinstance(evt, midi.TimeSignatureEvent):
if evt.numerator not in (2, 4):
# We don't want to worry about non-4 time signatures. Bail early!
- print "Found time signature event {}. Bailing!".format(evt)
+ # print "Found time signature event {}. Bailing!".format(evt)
return statematrix
try:
View
@@ -3,7 +3,7 @@
from data import *
import cPickle as pickle
-batch_width = 5 # number of sequences in a batch
+batch_width = 8 # number of sequences in a batch
batch_len = 16*8 # length of each sequence
division_len = 16 # interval between possible start locations
@@ -22,13 +22,14 @@ def loadPieces(dirpath):
continue
pieces[name] = outMatrix
- print "Loaded {}".format(name)
+ # print "Loaded {}".format(name)
return pieces
def getPieceSegment(pieces):
piece_output = random.choice(pieces.values())
start = random.randrange(0,len(piece_output)-batch_len,division_len)
+ # print "Range is {} {} {} -> {}".format(0,len(piece_output)-batch_len,division_len, start)
seg_out = piece_output[start:start+batch_len]
seg_in = noteStateMatrixToInputForm(seg_out)

0 comments on commit 6cc2869

Please sign in to comment.