(ns)
return velocity_range
Derive a VelocityRange proto from a NoteSequence.
Derive a VelocityRange proto from a NoteSequence.
Derive a VelocityRange proto from a NoteSequence .
def velocity_range_from_sequence(ns):
  """Derive a VelocityRange proto from a NoteSequence."""
  velocities = [note.velocity for note in ns.notes]
  velocity_max = np.max(velocities) if velocities else 0
  velocity_min = np.min(velocities) if velocities else 0
  velocity_range = music_pb2.VelocityRange(min=velocity_min, max=velocity_max)
  return velocity_range
def velocity_range_from_sequence ( ns ) : velocities = [ note . velocity for note in ns . notes ] velocity_max = np . max ( velocities ) if velocities else 0 velocity_min = np . min ( velocities ) if velocities else 0 velocity_range = music_pb2 . VelocityRange ( min = velocity_min , max = velocity_max ) return velocity_range