def getPDF(triplets): global all_chorales all_chorales = to_array.read_all_csv_chorales() # List of counters, indexed by attribute C = [{}, {}, {}, {}, {}, {}, {}, {}, {}] for chorale in all_chorales: addCount(C, chorale, triplets) with open('counters', 'w') as f: f.write(str(C)) f.close() return getPDFarray(C)
def getPDF(triplets): global all_chorales all_chorales = to_array.read_all_csv_chorales() # List of counters, indexed by attribute C= [{}, {}, {}, {}, {}, {}, {}, {}, {}] for chorale in all_chorales: addCount(C, chorale, triplets) with open('counters', 'w') as f: f.write(str(C)) f.close() return getPDFarray(C)
def predict_viterbi9(chorale_name,MODE): #predicts for viterbi9, the new eighth note model all_chorales = to_array.read_all_csv_chorales() filename= MODE + chorale_name + '.mxl.csv' DIR = 'viterbi9' triplets_dict={} model=pdf9.getPDF(triplets_dict) triplets=[] for key in triplets_dict: triplets.append(triplets_dict[key]) if not os.path.exists(DIR): os.mkdir(DIR) stitchFilename=DIR+'/'+filename[5:] print stitchFilename with open(stitchFilename, 'w') as f: f.write(str(viterbi8.generate_alto(model, triplets, all_chorales, filename)))
def predict_viterbi9(chorale_name, MODE): #predicts for viterbi9, the new eighth note model all_chorales = to_array.read_all_csv_chorales() filename = MODE + chorale_name + '.mxl.csv' DIR = 'viterbi9' triplets_dict = {} model = pdf9.getPDF(triplets_dict) triplets = [] for key in triplets_dict: triplets.append(triplets_dict[key]) if not os.path.exists(DIR): os.mkdir(DIR) stitchFilename = DIR + '/' + filename[5:] print stitchFilename with open(stitchFilename, 'w') as f: f.write( str(viterbi8.generate_alto(model, triplets, all_chorales, filename)))
def getPDF(triplets): global all_chorales all_chorales = to_array.read_all_csv_chorales() # List of counters, indexed by attribute C = [{}, {}, {}, {}, {}, {}, {}, {}, {}] for chorale in all_chorales: print chorale addCount(C, chorale, triplets) break with open('counters', 'w') as f: part = 0 for attr in C: f.write(str(part) + '\n') f.write(str(attr)) f.write('\n\n') part += 1 f.close() return getPDFarray(C)
def getPDF(triplets): global all_chorales all_chorales = to_array.read_all_csv_chorales() # List of counters, indexed by attribute C= [{}, {}, {}, {}, {}, {}, {}, {}, {}] for chorale in all_chorales: print chorale addCount(C, chorale, triplets) break with open('counters', 'w') as f: part=0 for attr in C: f.write(str(part)+'\n') f.write(str(attr)) f.write('\n\n') part+=1 f.close() return getPDFarray(C)
import viterbi, viterbi4, viterbi8, viterbi9, simple6, simple1, simple2, simple3, simple7, to_array, pdf, pdf1, pdf2, pdf3, pdf9, pdf4, pdf6, pdf7, pdf8, os, sys all_chorales = to_array.read_all_csv_chorales() filename = 'MAJORbwv411.mxl.csv' """ DIR = 'viterbi' triplets_dict={} model=pdf.getPDF(triplets_dict) triplets=[] for key in triplets_dict: triplets.append(triplets_dict[key]) if not os.path.exists(DIR): os.mkdir(DIR) stitchFilename=DIR+'/'+filename[5:] with open(stitchFilename, 'w') as f: f.write(str(viterbi.generate_alto(model, triplets, all_chorales, file1))) """ DIR = 'viterbi9' triplets_dict = {} model = pdf9.getPDF(triplets_dict) triplets = [] for key in triplets_dict: triplets.append(triplets_dict[key]) if not os.path.exists(DIR): os.mkdir(DIR) stitchFilename = DIR + '/' + filename[5:] with open(stitchFilename, 'w') as f: f.write( str(viterbi9.generate_alto(model, triplets, all_chorales, filename)))
def run_all_predictions(chorale_name,MODE): all_chorales = to_array.read_all_csv_chorales() filename= MODE + chorale_name + '.mxl.csv' """ DIR = 'viterbi' triplets_dict={} model=pdf.getPDF(triplets_dict) triplets=[] for key in triplets_dict: triplets.append(triplets_dict[key]) if not os.path.exists(DIR): os.mkdir(DIR) stitchFilename=DIR+'/'+filename[5:] with open(stitchFilename, 'w') as f: f.write(str(viterbi.generate_alto(model, all_chorales, file1))) """ # Simple model DIR = 'simple2' triplets_dict={} model=pdf2.getPDF(triplets_dict) triplets=[] for key in triplets_dict: triplets.append(triplets_dict[key]) if not os.path.exists(DIR): os.mkdir(DIR) stitchFilename=DIR+'/'+filename[5:] with open(stitchFilename, 'w') as f: f.write(str(simple2.generate_alto(model, all_chorales, filename))) # Simple model 2 DIR = 'simple3' triplets_dict={} model=pdf3.getPDF(triplets_dict) triplets=[] for key in triplets_dict: triplets.append(triplets_dict[key]) if not os.path.exists(DIR): os.mkdir(DIR) stitchFilename=DIR+'/'+filename[5:] with open(stitchFilename, 'w') as f: f.write(str(simple3.generate_alto(model, all_chorales, filename))) # Intermediate model 1 DIR = 'simple1' triplets_dict={} model=pdf1.getPDF(triplets_dict) triplets=[] for key in triplets_dict: triplets.append(triplets_dict[key]) if not os.path.exists(DIR): os.mkdir(DIR) stitchFilename=DIR+'/'+filename[5:] with open(stitchFilename, 'w') as f: f.write(str(simple1.generate_alto(model, all_chorales, filename))) # Intermediate model 2 DIR = 'simple7' triplets_dict={} model=pdf7.getPDF(triplets_dict) triplets=[] for key in triplets_dict: triplets.append(triplets_dict[key]) if not os.path.exists(DIR): os.mkdir(DIR) stitchFilename=DIR+'/'+filename[5:] with open(stitchFilename, 'w') as f: f.write(str(simple7.generate_alto(model, all_chorales, filename))) # Intermediate model 3 DIR = 'simple6' triplets_dict={} model=pdf6.getPDF(triplets_dict) triplets=[] for key in triplets_dict: triplets.append(triplets_dict[key]) if not os.path.exists(DIR): os.mkdir(DIR) stitchFilename=DIR+'/'+filename[5:] with open(stitchFilename, 'w') as f: f.write(str(simple6.generate_alto(model, all_chorales, filename))) # Viterbi without links between alto notes DIR = 'viterbi4' triplets_dict={} model=pdf4.getPDF(triplets_dict) triplets=[] for key in triplets_dict: triplets.append(triplets_dict[key]) if not os.path.exists(DIR): os.mkdir(DIR) stitchFilename=DIR+'/'+filename[5:] with open(stitchFilename, 'w') as f: f.write(str(viterbi4.generate_alto(model, triplets, all_chorales, filename))) # Viterbi with links between alto notes DIR = 'viterbi8' triplets_dict={} model=pdf8.getPDF(triplets_dict) triplets=[] for key in triplets_dict: triplets.append(triplets_dict[key]) if not os.path.exists(DIR): os.mkdir(DIR) stitchFilename=DIR+'/'+filename[5:] with open(stitchFilename, 'w') as f: f.write(str(viterbi8.generate_alto(model, triplets, all_chorales, filename)))
def run_all_predictions(chorale_name, MODE): all_chorales = to_array.read_all_csv_chorales() filename = MODE + chorale_name + '.mxl.csv' """ DIR = 'viterbi' triplets_dict={} model=pdf.getPDF(triplets_dict) triplets=[] for key in triplets_dict: triplets.append(triplets_dict[key]) if not os.path.exists(DIR): os.mkdir(DIR) stitchFilename=DIR+'/'+filename[5:] with open(stitchFilename, 'w') as f: f.write(str(viterbi.generate_alto(model, all_chorales, file1))) """ # Simple model DIR = 'simple2' triplets_dict = {} model = pdf2.getPDF(triplets_dict) triplets = [] for key in triplets_dict: triplets.append(triplets_dict[key]) if not os.path.exists(DIR): os.mkdir(DIR) stitchFilename = DIR + '/' + filename[5:] with open(stitchFilename, 'w') as f: f.write(str(simple2.generate_alto(model, all_chorales, filename))) # Simple model 2 DIR = 'simple3' triplets_dict = {} model = pdf3.getPDF(triplets_dict) triplets = [] for key in triplets_dict: triplets.append(triplets_dict[key]) if not os.path.exists(DIR): os.mkdir(DIR) stitchFilename = DIR + '/' + filename[5:] with open(stitchFilename, 'w') as f: f.write(str(simple3.generate_alto(model, all_chorales, filename))) # Intermediate model 1 DIR = 'simple1' triplets_dict = {} model = pdf1.getPDF(triplets_dict) triplets = [] for key in triplets_dict: triplets.append(triplets_dict[key]) if not os.path.exists(DIR): os.mkdir(DIR) stitchFilename = DIR + '/' + filename[5:] with open(stitchFilename, 'w') as f: f.write(str(simple1.generate_alto(model, all_chorales, filename))) # Intermediate model 2 DIR = 'simple7' triplets_dict = {} model = pdf7.getPDF(triplets_dict) triplets = [] for key in triplets_dict: triplets.append(triplets_dict[key]) if not os.path.exists(DIR): os.mkdir(DIR) stitchFilename = DIR + '/' + filename[5:] with open(stitchFilename, 'w') as f: f.write(str(simple7.generate_alto(model, all_chorales, filename))) # Intermediate model 3 DIR = 'simple6' triplets_dict = {} model = pdf6.getPDF(triplets_dict) triplets = [] for key in triplets_dict: triplets.append(triplets_dict[key]) if not os.path.exists(DIR): os.mkdir(DIR) stitchFilename = DIR + '/' + filename[5:] with open(stitchFilename, 'w') as f: f.write(str(simple6.generate_alto(model, all_chorales, filename))) # Viterbi without links between alto notes DIR = 'viterbi4' triplets_dict = {} model = pdf4.getPDF(triplets_dict) triplets = [] for key in triplets_dict: triplets.append(triplets_dict[key]) if not os.path.exists(DIR): os.mkdir(DIR) stitchFilename = DIR + '/' + filename[5:] with open(stitchFilename, 'w') as f: f.write( str(viterbi4.generate_alto(model, triplets, all_chorales, filename))) # Viterbi with links between alto notes DIR = 'viterbi8' triplets_dict = {} model = pdf8.getPDF(triplets_dict) triplets = [] for key in triplets_dict: triplets.append(triplets_dict[key]) if not os.path.exists(DIR): os.mkdir(DIR) stitchFilename = DIR + '/' + filename[5:] with open(stitchFilename, 'w') as f: f.write( str(viterbi8.generate_alto(model, triplets, all_chorales, filename)))
import viterbi, viterbi4, viterbi8, viterbi9, simple6, simple1, simple2, simple3, simple7, to_array, pdf, pdf1, pdf2, pdf3, pdf9, pdf4, pdf6, pdf7, pdf8, os, sys all_chorales = to_array.read_all_csv_chorales() filename='MAJORbwv411.mxl.csv' """ DIR = 'viterbi' triplets_dict={} model=pdf.getPDF(triplets_dict) triplets=[] for key in triplets_dict: triplets.append(triplets_dict[key]) if not os.path.exists(DIR): os.mkdir(DIR) stitchFilename=DIR+'/'+filename[5:] with open(stitchFilename, 'w') as f: f.write(str(viterbi.generate_alto(model, triplets, all_chorales, file1))) """ DIR = 'viterbi9' triplets_dict={} model=pdf9.getPDF(triplets_dict) triplets=[] for key in triplets_dict: triplets.append(triplets_dict[key]) if not os.path.exists(DIR): os.mkdir(DIR) stitchFilename=DIR+'/'+filename[5:] with open(stitchFilename, 'w') as f: