(self, pianoroll)
return midi_data
Decodes pianoroll into midi.
Decodes pianoroll into midi.
Decodes pianoroll into midi .
def decode_to_midi(self, pianoroll):
    """Decodes pianoroll into midi."""
    # NOTE: Assumes four separate instruments ordered from high to low.
    midi_data = pretty_midi.PrettyMIDI()
    duration = self.qpm / 60 * self.shortest_duration
    tt, pp, ii = pianoroll.shape
    for i in range(ii):
      notes = []
      for p in range(pp):
        for t in range(tt):
          if pianoroll[t, p, i]:
            notes.append(
                pretty_midi.Note(
                    velocity=100,
                    pitch=self.min_pitch + p,
                    start=t * duration,
                    end=(t + 1) * duration))
      notes = merge_held(notes)

      instrument = pretty_midi.Instrument(program=self.programs[i] - 1)
      instrument.notes.extend(notes)
      midi_data.instruments.append(instrument)
    return midi_data
def decode_to_midi ( self , pianoroll ) : # NOTE: Assumes four separate instruments ordered from high to low. midi_data = pretty_midi . PrettyMIDI ( ) duration = self . qpm / 60 * self . shortest_duration tt , pp , ii = pianoroll . shape for i in range ( ii ) : notes = [ ] for p in range ( pp ) : for t in range ( tt ) : if pianoroll [ t , p , i ] : notes . append ( pretty_midi . Note ( velocity = 100 , pitch = self . min_pitch + p , start = t * duration , end = ( t + 1 ) * duration ) ) notes = merge_held ( notes ) instrument = pretty_midi . Instrument ( program = self . programs [ i ] - 1 ) instrument . notes . extend ( notes ) midi_data . instruments . append ( instrument ) return midi_data