Exemplo n.º 1
0
def recordAll(score, args, splitRecord = [], counter = 1): #score needs to be flat
   #splitRecord is used to split the original score into pieces
   #because it is possible that the splitRecord is generated by structural 
   #analysis in the future, so we seperate the score splitting code after all 
   #recording are finished
   #record perfs and generate split file
   if len(score) == 0:
      #splitRecFilename= args.outputDir
      #splitRecFilename+= settings.getScoreName(args.scoreFilename)+'.split.json'
      splitRecFilename = settings.getSplitRecFilename(args.scoreFilename, 
                                                      args.outputDir)
      with open(splitRecFilename, 'w') as f:
         simplejson.dump(splitRecord, f, indent = 3)

      print('[INFO] splitting record saved to ' + splitRecFilename)
      return
   else:
      try:
         print("[INFO] Now playing score."),
         print("You can start to record anytime by pressing Ctrl+c")
         record.playStream(score); #provide stop button
      except KeyboardInterrupt:
         pass
      print("[INFO] =====Now recording phrase no." + str(counter) + "=====")
      #recLogFilename = settings.getRecLogFilename(args.scoreFilename +'.'+ str(counter))
      #recLogFilename = args.outputDir + settings.getScoreName(args.scoreFilename)
      #recLogFilename += '.'+ str(counter) + '.log'
      recLogFilename = settings.getRecLogFilename(counter, 
                                                  args.scoreFilename, 
                                                  args.outputDir)
      settings.printDebug(recLogFilename)
      record.record(score, recLogFilename)
      perf = musicGenerator.generatePerf(score, recLogFilename)
      #outFilename= args.outputDir + settings.getScoreName(args.scoreFilename)
      #outFilename+= '.'+ str(counter) + '.perf' + settings.defaultOutputFormat
      outFilename = settings.getOutFilename(counter, 
                                            args.scoreFilename,
                                            args.outputDir)
      musicGenerator.savePerf2File(perf, outFilename)
      scoreHead= score[:len(perf)]
      #if settings.DEBUG:
      #   settings.printDebug('')
      #   scoreHead.show('text')

      scoreTail= score[len(perf):]
      #if settings.DEBUG:
         #settings.printDebug('')
         #scoreTail.show('text')
      scoreHeadOffsets = [n.offset for n in scoreHead]
      splitRecord.append(scoreHeadOffsets)
      settings.printDebug(splitRecord)
      #splitRecord.extend(scoreHead)
      #capture mouse
      #pos = pygame.mouse.get_pos()
      #print("mouse position: "+pos)
      recordAll(scoreTail, args, splitRecord, counter+1)
Exemplo n.º 2
0
def recordAll(score, args, counter=1):  # score needs to be flat
    if len(score) == 0:
        return
    else:
        print("[INFO] Now recording phrase no." + str(counter))
        record.playStream(score)
        # provide stop button
        recLogFilename = settings.getRecLogFilename(args.scoreFilename + str(counter))
        record.record(recLogFilename)
        perf = musicGenerator.generatePerf(score, recLogFilename)
        musicGenerator.savePerf2File(perf, arg.outputFilename + str(counter))
        scoreTail = score[len(perf) :]
        recordAll(scoreTail, args, counter + 1)
def recordAll(score, args, counter = 1): #score needs to be flat
   if len(score) == 0:
      return
   else:
      try:
         print("[INFO] Now playing score. You can start to record anytime by pressing Ctrl+c")
         record.playStream(score); #provide stop button
      except KeyboardInterrupt:
         pass
      print("[INFO] =====Now recording phrase no." + str(counter) + "=====")
      #recLogFilename = settings.getRecLogFilename(args.scoreFilename +'.'+ str(counter))
      recLogFilename = args.outputDir + settings.getScoreName(args.scoreFilename)
      recLogFilename += '.'+ str(counter) + '.log'
      record.record(score, recLogFilename);
      perf = musicGenerator.generatePerf(score, recLogFilename)
      outFilename= args.outputDir + settings.getScoreName(args.scoreFilename)
      outFilename+= '.'+ str(counter) + '.perf' + settings.defaultOutputFormat
      musicGenerator.savePerf2File(perf, outFilename)
      scoreTail= score[len(perf):]
      recordAll(scoreTail, args, counter+1)