(self, note, feature, step_length=None)
Compute numeric value of hit/velocity/offset for a note.

    For now, only allow one note per instrument per quantization time step.
    This means at 16th note resolution we can't represent some drumrolls etc.
    We just take the note with the highest velocity if there are multiple notes.

    Args:
      note: A Note object from a NoteSequence.
      feature: A string, either 'hit', 'velocity', or 'offset'.
      step_length: Time duration in seconds of a quantized step. This only needs
        to be defined when the feature is 'offset'.

    Raises:
      ValueError: Any feature other than 'hit', 'velocity', or 'offset'.

    Returns:
      The numeric value of the feature for the note.
Compute numeric value of hit/velocity/offset for a note.
Compute numeric value of hit / velocity / offset for a note .
def _get_feature(self, note, feature, step_length=None):
    """Compute numeric value of hit/velocity/offset for a note.

    For now, only allow one note per instrument per quantization time step.
    This means at 16th note resolution we can't represent some drumrolls etc.
    We just take the note with the highest velocity if there are multiple notes.

    Args:
      note: A Note object from a NoteSequence.
      feature: A string, either 'hit', 'velocity', or 'offset'.
      step_length: Time duration in seconds of a quantized step. This only needs
        to be defined when the feature is 'offset'.

    Raises:
      ValueError: Any feature other than 'hit', 'velocity', or 'offset'.

    Returns:
      The numeric value of the feature for the note.
    """

    def _get_offset(note, step_length):
      true_onset = note.start_time
      quantized_onset = step_length * note.quantized_start_step
      diff = quantized_onset - true_onset
      return diff/step_length

    if feature == 'hit':
      if note:
        return 1.
      else:
        return 0.

    elif feature == 'velocity':
      if note:
        return note.velocity/127.  # Switch from [0, 127] to [0, 1] for tensors.
      else:
        return 0.  # Default velocity if there's no note is 0

    elif feature == 'offset':
      if note:
        offset = _get_offset(note, step_length)
        return offset*2  # Switch from [-0.5, 0.5] to [-1, 1] for tensors.
      else:
        return 0.  # Default offset if there's no note is 0

    else:
      raise ValueError('Unlisted feature: ' + feature)
def _get_feature ( self , note , feature , step_length = None ) : def _get_offset ( note , step_length ) : true_onset = note . start_time quantized_onset = step_length * note . quantized_start_step diff = quantized_onset - true_onset return diff / step_length if feature == 'hit' : if note : return 1. else : return 0. elif feature == 'velocity' : if note : return note . velocity / 127. # Switch from [0, 127] to [0, 1] for tensors. else : return 0. # Default velocity if there's no note is 0 elif feature == 'offset' : if note : offset = _get_offset ( note , step_length ) return offset * 2 # Switch from [-0.5, 0.5] to [-1, 1] for tensors. else : return 0. # Default offset if there's no note is 0 else : raise ValueError ( 'Unlisted feature: ' + feature )