(self, steps, from_left=False)
Sets the length of the sequence to the specified number of steps.

    If the event sequence is not long enough, pads with silence to make the
    sequence the specified length. If it is too long, it will be truncated to
    the requested length.

    Note that this will append a STEP_END event to the end of the sequence if
    there is an unfinished step.

    Args:
      steps: How many quantized steps long the event sequence should be.
      from_left: Whether to add/remove from the left instead of right.
Sets the length of the sequence to the specified number of steps.
Sets the length of the sequence to the specified number of steps .
def set_length(self, steps, from_left=False):
    """Sets the length of the sequence to the specified number of steps.

    If the event sequence is not long enough, pads with silence to make the
    sequence the specified length. If it is too long, it will be truncated to
    the requested length.

    Note that this will append a STEP_END event to the end of the sequence if
    there is an unfinished step.

    Args:
      steps: How many quantized steps long the event sequence should be.
      from_left: Whether to add/remove from the left instead of right.
    """
    if from_left:
      raise NotImplementedError('from_left is not supported')

    # First remove any trailing end events.
    self.trim_trailing_end_events()
    # Then add an end step event, to close out any incomplete steps.
    self._events.append(
        PolyphonicEvent(event_type=PolyphonicEvent.STEP_END, pitch=None))
    # Then trim or pad as needed.
    if self.num_steps < steps:
      self._append_silence_steps(steps - self.num_steps)
    elif self.num_steps > steps:
      self._trim_steps(self.num_steps - steps)
    # Then add a trailing end event.
    self._events.append(
        PolyphonicEvent(event_type=PolyphonicEvent.END, pitch=None))
    assert self.num_steps == steps
def set_length ( self , steps , from_left = False ) : if from_left : raise NotImplementedError ( 'from_left is not supported' ) # First remove any trailing end events. self . trim_trailing_end_events ( ) # Then add an end step event, to close out any incomplete steps. self . _events . append ( PolyphonicEvent ( event_type = PolyphonicEvent . STEP_END , pitch = None ) ) # Then trim or pad as needed. if self . num_steps < steps : self . _append_silence_steps ( steps - self . num_steps ) elif self . num_steps > steps : self . _trim_steps ( self . num_steps - steps ) # Then add a trailing end event. self . _events . append ( PolyphonicEvent ( event_type = PolyphonicEvent . END , pitch = None ) ) assert self . num_steps == steps