Exemple #1
0
    def __init__(self, showPredictions=False, predictor="MM", dataFile="data/noteData_ex_random.pickle"):
        self.model = Model(dataFile)
        import utils
        self.showPredictions = showPredictions
        self.currNoteState = [0] * utils.numNotes
        self.predictionState = [False] * utils.numNotes
        self.keyRects = []
        self.actionQueue = []
        if predictor not in ["MM", "MM3", "HMM", "Q"]:
            predictor = "MM"
        self.predictor = predictor
        self.octave = 1 #assumes that note 48 is in the data...
        for note, val in enumerate(self.currNoteState):
            self.keyRects.append(utils.makeNoteRect(note, utils.numNotes))
        self.allNotes = []
        self.modelRects = [] #(note, (left, top, width, height))
        self.noteRects = [] #(note, (left, top, width, height))
        self.soundMapping = utils.initSoundMappings()
        self.confMatList = []
        self.confMatrix = np.zeros((12, 12), dtype=np.int)
        self.avgF1s = []
        self.memoryList = []
        self.cpuList = []

        self.mmPreds = []
        self.mmConfMatList = []
        self.mmConfMatrix = np.zeros((12, 12), dtype=np.int)
        self.mmAvgF1s = []
        self.mm3Preds = []
        self.mm3ConfMatList = []
        self.mm3ConfMatrix = np.zeros((12, 12), dtype=np.int)
        self.mm3AvgF1s = []
        self.hmmPreds = []
        self.hmmConfMatList = []
        self.hmmConfMatrix = np.zeros((12, 12), dtype=np.int)
        self.hmmAvgF1s = []
        self.qPreds = []
        self.qConfMatList = []
        self.qConfMatrix = np.zeros((12, 12), dtype=np.int)
        self.qAvgF1s = []
        #MODELS#
        mmModel, mmModel3, hmmModel, qModel = self.model.train()
        self.mmModel = mmModel
        self.mmModel3 = mmModel3
        self.hmmModel = hmmModel
        self.qModel = qModel
Exemple #2
0
import sys, pygame, cPickle, time
from model import *

if __name__ == "__main__":
    assert (len(sys.argv) == 2)
    model = Model("data/noteData_ex_random.pickle")
    import utils
    pygame.init()
    pygame.mixer.init(44100, -16, 2, buffer=512)
    pygame.mixer.set_num_channels(12)
    toUnpickle = sys.argv[1]
    data = cPickle.load(file(toUnpickle))
    soundMappings = utils.initSoundMappings()
    for val in data:
        note = val[0]
        t = val[1] - origTime
        soundMappings[note].play(loops=-1)
        time.sleep(t / 10000)
        soundMappings[note].stop()