(control_signal_fns, disable_conditioning_fn,
                           control_events, performance, control_state)
return PerformanceControlState(
      current_perf_index=idx, current_perf_step=step)
Extend a performance control sequence.

  Extends `control_events` -- a sequence of control signal value tuples -- to be
  one event longer than `performance`, so the next event of `performance` can be
  conditionally generated.

  This function is meant to be used as the `extend_control_events_callback`
  in the `_generate_events` method of `EventSequenceRnnModel`.

  Args:
    control_signal_fns: A list of functions that map time step to desired
        control value, or None if not using control signals.
    disable_conditioning_fn: A function that maps time step to whether or not
        conditioning should be disabled, or None if there is no conditioning or
        conditioning is not optional.
    control_events: The control sequence to extend.
    performance: The Performance being generated.
    control_state: A PerformanceControlState tuple containing the current
        position in `performance`. We maintain this so as not to have to
        recompute the total performance length (in steps) every time we want to
        extend the control sequence.

  Returns:
    The PerformanceControlState after extending the control sequence one step
    past the end of the generated performance.
Extend a performance control sequence.
Extend a performance control sequence .
def _extend_control_events(control_signal_fns, disable_conditioning_fn,
                           control_events, performance, control_state):
  """Extend a performance control sequence.

  Extends `control_events` -- a sequence of control signal value tuples -- to be
  one event longer than `performance`, so the next event of `performance` can be
  conditionally generated.

  This function is meant to be used as the `extend_control_events_callback`
  in the `_generate_events` method of `EventSequenceRnnModel`.

  Args:
    control_signal_fns: A list of functions that map time step to desired
        control value, or None if not using control signals.
    disable_conditioning_fn: A function that maps time step to whether or not
        conditioning should be disabled, or None if there is no conditioning or
        conditioning is not optional.
    control_events: The control sequence to extend.
    performance: The Performance being generated.
    control_state: A PerformanceControlState tuple containing the current
        position in `performance`. We maintain this so as not to have to
        recompute the total performance length (in steps) every time we want to
        extend the control sequence.

  Returns:
    The PerformanceControlState after extending the control sequence one step
    past the end of the generated performance.
  """
  idx = control_state.current_perf_index
  step = control_state.current_perf_step

  while idx < len(performance):
    if performance[idx].event_type == note_seq.PerformanceEvent.TIME_SHIFT:
      step += performance[idx].event_value
    idx += 1

    control_event = tuple(f(step) for f in control_signal_fns)
    if disable_conditioning_fn is not None:
      control_event = (disable_conditioning_fn(step), control_event)
    control_events.append(control_event)

  return PerformanceControlState(
      current_perf_index=idx, current_perf_step=step)
def _extend_control_events ( control_signal_fns , disable_conditioning_fn , control_events , performance , control_state ) : idx = control_state . current_perf_index step = control_state . current_perf_step while idx < len ( performance ) : if performance [ idx ] . event_type == note_seq . PerformanceEvent . TIME_SHIFT : step += performance [ idx ] . event_value idx += 1 control_event = tuple ( f ( step ) for f in control_signal_fns ) if disable_conditioning_fn is not None : control_event = ( disable_conditioning_fn ( step ) , control_event ) control_events . append ( control_event ) return PerformanceControlState ( current_perf_index = idx , current_perf_step = step )