def debugProperlyFilledScore(scoreL, instL): for i in range(len(scoreL)): score = scoreL[i] inst = instL[i] for measure in score.measures: if not measure.checkProperlyFilled(): errorS = ': ' for note in measure.notes: errorS += str(note.pitch) + str(note.dur) + ' ' errorS += 'mm length = ' + str(measure.length) + ' ' raise Exception, inst + ' ' + str(measure.num) + errorS ##### END FUNCTION DEFINITIONS ###### ####################################### ########### BEGIN MAIN BODY ########### ####################################### # BEGIN instance declarations instL = [] for pair in instD.items(): key = pair[0] instL.append(key) configSet = ConfigSet() configSet.setTiming(ticks, master_tupletL, temp_tupletL, topL) configSet.setInsts(instL) configSet.readFile() for inst in instL: score = Score(instD[inst]) for config in configSet.configsL: if config.instS == inst: score.addVariables(config) # inherited from Object.addVariables score.fileread(inst, config) scoreL.append(score) for score in scoreL: for measure in score.measures: measure.addVariables(score.config) measure.removeDuplicateNotes() piece = Piece(scoreL) piece.get_all_notes() #piece.sort_notes_in_mm(scoreL) #piece.sieve_pitches(scoreL, c_dom_seventhL) # optional 3rd arg of variance amp, default 3 for i in range(len(scoreL)): ly_file = open(directory + instL[i] + '.ly', 'w') current_score = scoreL[i] current_score.setMutatingStatus(1) feedbackD = current_score.makeFeedbackD() current_score.mutateByMarkov2(current_score.config, feedbackD) # some feedback must be incorporate at this point # for measure construction, even though most of # the method is still Markovian current_score.mutateByFeedback(feedbackD) # do all other feedback-based mutations scoreL[i].filewrite(instL[i]) header = Header(current_score.config) ly_file.write(header.ly_output(instL[i])) ly_file.write(current_score.printopen(instL[i])) ly_file.write(current_score.ly_output(config)) ly_file.write(current_score.printclose()) ly_file.close()
### END GLOBAL VARIABLE DECLARATIONS ### ####################################### ########### BEGIN MAIN BODY ########### ####################################### # BEGIN instance declarations config = Config() config.readFile() config.masterTupletL = master_tupletL config.tempTupletL = temp_tupletL config.ticksI = ticks config.instS = inst config.topL = topL header = Header(config) score = Score(instD[inst]) score.addVariables(config) # END instance declarations print header.ly_output(inst) score.setTempo(180, 180) # min, max score.construct(config) score.filewrite(inst) print score.printopen(inst) #print score.debug_out() print score.ly_output(config) print score.printclose() ############ END MAIN BODY ############