예제 #1
0
  def testEncodeNoteSequence(self):
    encoder = music_encoders.TextMelodyEncoder(
        steps_per_quarter=4, min_pitch=21, max_pitch=108)
    encoder_absolute = music_encoders.TextMelodyEncoderAbsolute(
        steps_per_second=4, min_pitch=21, max_pitch=108)

    ns = music_pb2.NoteSequence()
    ns.tempos.add(qpm=60)
    testing_lib.add_track_to_sequence(
        ns, 0,
        [(60, 127, 0.0, 0.25), (62, 127, 0.25, 0.75), (64, 127, 1.25, 2.0)])
    ids = encoder.encode_note_sequence(ns)
    ids_absolute = encoder_absolute.encode_note_sequence(ns)

    expected_ids = [
        43,  # ON(60)
        45,  # ON(62)
        2,   # HOLD(62)
        3,   # OFF(62)
        2,   # REST
        47,  # ON(64)
        2,   # HOLD(64)
        2    # HOLD(64)
    ]

    self.assertEqual(expected_ids, ids)
    self.assertEqual(expected_ids, ids_absolute)
예제 #2
0
 def score_encoders(self):
   return [
       ('performance', music_encoders.MidiPerformanceEncoder(
           steps_per_second=100,
           num_velocity_bins=32,
           min_pitch=21,
           max_pitch=108,
           add_eos=self.add_eos_symbol)),
       ('melody', music_encoders.TextMelodyEncoderAbsolute(
           steps_per_second=10, min_pitch=21, max_pitch=108))
   ]
예제 #3
0
 def score_encoders(self):
     return [('melody',
              music_encoders.TextMelodyEncoderAbsolute(steps_per_second=10,
                                                       min_pitch=MIN_PITCH,
                                                       max_pitch=MAX_PITCH))
             ]