(midi_path, min_pitch=36, max_pitch=84)
return ns, notes
Load midi as a notesequence.
Load midi as a notesequence.
Load midi as a notesequence .
def load_midi(midi_path, min_pitch=36, max_pitch=84):
  """Load midi as a notesequence."""
  midi_path = util.expand_path(midi_path)
  ns = note_seq.midi_file_to_sequence_proto(midi_path)
  pitches = np.array([n.pitch for n in ns.notes])
  velocities = np.array([n.velocity for n in ns.notes])
  start_times = np.array([n.start_time for n in ns.notes])
  end_times = np.array([n.end_time for n in ns.notes])
  valid = np.logical_and(pitches >= min_pitch, pitches <= max_pitch)
  notes = {'pitches': pitches[valid],
           'velocities': velocities[valid],
           'start_times': start_times[valid],
           'end_times': end_times[valid]}
  return ns, notes
def load_midi ( midi_path , min_pitch = 36 , max_pitch = 84 ) : midi_path = util . expand_path ( midi_path ) ns = note_seq . midi_file_to_sequence_proto ( midi_path ) pitches = np . array ( [ n . pitch for n in ns . notes ] ) velocities = np . array ( [ n . velocity for n in ns . notes ] ) start_times = np . array ( [ n . start_time for n in ns . notes ] ) end_times = np . array ( [ n . end_time for n in ns . notes ] ) valid = np . logical_and ( pitches >= min_pitch , pitches <= max_pitch ) notes = { 'pitches' : pitches [ valid ] , 'velocities' : velocities [ valid ] , 'start_times' : start_times [ valid ] , 'end_times' : end_times [ valid ] } return ns , notes