Пример #1
0
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()
Пример #2
0
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

import fileinput, os, random, re, sys, time
from noclergy_configSet import ConfigSet

#######################################
########### BEGIN VARIABLES ###########
#######################################

instsL = sys.argv[1:] # all but mutate_config.py itself

#######################################
########### BEGIN MAIN BODY ###########
#######################################

# BEGIN instance declarations
configSet = ConfigSet()
configSet.setInsts(instsL)
configSet.readFile()
configSet.readFeedback()
configSet.alter('art')
configSet.alter('dyn')
configSet.alter('rest')
#config.alter('tuplet', config.modTupletI)
print configSet.writeFile()

############ END MAIN BODY ############