コード例 #1
0
ファイル: model.py プロジェクト: shinglyu/MusicPupil
def collectFeats(trainFeats, featType):
   #trainFeats structure:
   # [
   #  { 
   #    name:'score1',
   #    scoreFeats:{ feat1name:[1,2,3...], feat2name:[2,3,4...] ...},
   #    perfFeats:{ feat1name:[1,2,3...], feat2name:[2,3,4...] ...}
   #  }
   #  { 
   #     name:'score2',
   #     scoreFeats:{ feat1name:[1,2,3...], feat2name:[2,3,4...] ...},
   #     perfFeats:{ feat1name:[1,2,3...], feat2name:[2,3,4...] ...}
   #  }
   # ]
   #
   # collectedFeats structure (scoreFeats for example):
   #  {
   #     feat1name: [1,2,3....2 3 4,...3 9 4,...],
   #     feat2name: [1,2,3....2 3 4,...3 9 4,...],
   #  }
   #
   #logging.printDebug("trainFeats: ")
   #logging.printDebug(trainFeats)
   collectedFeats = {}
   for featName in getattr(config, featType+'List'):
      collectedFeats[featName] = []
      #logging.printDebug(trainFeats)
      logging.printDebug(featName)
      for score in trainFeats:
         logging.printDebug(score)
         #logging.printDebug("featName: " + featName)
         #logging.printDebug("featType: " + featType)
         collectedFeats[featName].extend(score[featType][featName])
   return collectedFeats
コード例 #2
0
def collectFeats(trainFeats, featType):
    #trainFeats structure:
    # [
    #  {
    #    name:'score1',
    #    scoreFeats:{ feat1name:[1,2,3...], feat2name:[2,3,4...] ...},
    #    perfFeats:{ feat1name:[1,2,3...], feat2name:[2,3,4...] ...}
    #  }
    #  {
    #     name:'score2',
    #     scoreFeats:{ feat1name:[1,2,3...], feat2name:[2,3,4...] ...},
    #     perfFeats:{ feat1name:[1,2,3...], feat2name:[2,3,4...] ...}
    #  }
    # ]
    #
    # collectedFeats structure (scoreFeats for example):
    #  {
    #     feat1name: [1,2,3....2 3 4,...3 9 4,...],
    #     feat2name: [1,2,3....2 3 4,...3 9 4,...],
    #  }
    #
    #logging.printDebug("trainFeats: ")
    #logging.printDebug(trainFeats)
    collectedFeats = {}
    for featName in getattr(config, featType + 'List'):
        collectedFeats[featName] = []
        #logging.printDebug(trainFeats)
        logging.printDebug(featName)
        for score in trainFeats:
            logging.printDebug(score)
            #logging.printDebug("featName: " + featName)
            #logging.printDebug("featType: " + featType)
            collectedFeats[featName].extend(score[featType][featName])
    return collectedFeats
コード例 #3
0
def extractOnsetDiffQNote(sample):
    scoreOffsets = [s['offset'] for s in sample['score'].flat.notes.offsetMap]
    perfOffsets = [p['offset'] for p in sample['perf'].flat.notes.offsetMap]
    perfStartOffset = perfOffsets[0]

    ratio = extractTempoRatio(sample)
    normalizedPerfOffsets = [(p - perfStartOffset) / ratio
                             for p in perfOffsets]

    weakStartOffset = getWeakStartOffset(sample)
    shiftedPerfOffsets = map(lambda x: x + weakStartOffset,
                             normalizedPerfOffsets)

    logging.printDebug("scoreOffsets:")
    logging.printDebug(scoreOffsets)
    logging.printDebug("perfOffsets:")
    logging.printDebug(perfOffsets)
    logging.printDebug("shiftedPerfOffsets:")
    logging.printDebug(shiftedPerfOffsets)
    logging.printDebug("normalizedPerfOffsets:")
    logging.printDebug(normalizedPerfOffsets)

    offsetDiff = [s - p for s, p in zip(scoreOffsets, shiftedPerfOffsets)]
    return offsetDiff
コード例 #4
0
ファイル: perfFeature.py プロジェクト: shinglyu/MusicPupil
def extractOnsetDiffQNote1(sample):
   scoreOffsets = [s['offset'] for s in sample['score'].flat.notes.offsetMap]
   perfOffsets = [p['offset'] for p in sample['perf'].flat.notes.offsetMap]
   perfStartOffset = perfOffsets[0]

   ratio = extractTempoRatio1(sample)
   normalizedPerfOffsets= [(p - perfStartOffset) / ratio for p in perfOffsets]

   weakStartOffset = getWeakStartOffset(sample)
   shiftedPerfOffsets = map(lambda x: x + weakStartOffset, normalizedPerfOffsets) 

   logging.printDebug("scoreOffsets:")
   logging.printDebug(scoreOffsets)
   logging.printDebug("perfOffsets:")
   logging.printDebug(perfOffsets)
   logging.printDebug("shiftedPerfOffsets:")
   logging.printDebug(shiftedPerfOffsets)
   logging.printDebug("normalizedPerfOffsets:")
   logging.printDebug(normalizedPerfOffsets)
   
   offsetDiff = [ s - p for s, p in zip(scoreOffsets, shiftedPerfOffsets)]
   return offsetDiff