Class: Musa::Sequencer::BaseSequencer::PlayTimedControl Private

Inherits:
EventHandler show all
Defined in:
lib/musa-dsl/sequencer/base-sequencer-implementation-play-timed.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Control object for play_timed operations.

Manages lifecycle of timed series playback with callbacks. Simpler than PlayControl - no pause/continue support.

Examples:

Basic play_timed control

control = sequencer.play_timed(timed_series) { |values| ... }
control.on_stop { puts "Playback finished!" }
control.after(2r) { puts "2 bars after end" }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, on_stop: nil, after_bars: nil, after: nil) ⇒ PlayTimedControl

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Creates play_timed control with callbacks.

Parameters:

  • parent (EventHandler)

    parent event handler

  • on_stop (Proc, nil) (defaults to: nil)

    stop callback

  • after_bars (Rational, nil) (defaults to: nil)

    delay for after callback

  • after (Proc, nil) (defaults to: nil)

    after callback block



164
165
166
167
168
169
170
171
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-play-timed.rb', line 164

def initialize(parent, on_stop: nil, after_bars: nil, after: nil)
  super parent
  @do_on_stop = []
  @do_after = []

  @do_on_stop << on_stop if on_stop
  self.after after_bars, &after if after
end

Instance Attribute Details

#do_afterArray<Hash> (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns after callbacks with delays.

Returns:

  • (Array<Hash>)

    after callbacks with delays



154
155
156
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-play-timed.rb', line 154

def do_after
  @do_after
end

#do_on_stopArray<Proc> (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns stop callbacks.

Returns:

  • (Array<Proc>)

    stop callbacks



152
153
154
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-play-timed.rb', line 152

def do_on_stop
  @do_on_stop
end

Instance Method Details

#after(bars = nil) { ... } ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Registers callback to execute after playback terminates naturally (series exhausted). NOT called on manual stop (.stop).

Examples:

Delayed callback

control.after(4r) { puts "4 bars after playback ends" }

Parameters:

  • bars (Numeric, nil) (defaults to: nil)

    delay in bars after natural termination (default: 0)

Yields:

  • after callback block



196
197
198
199
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-play-timed.rb', line 196

def after(bars = nil, &block)
  bars ||= 0
  @do_after << { bars: bars.rationalize, block: block }
end

#on_stop { ... } ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Registers callback for when playback stops (any reason, including manual stop).

Yields:

  • stop callback block



180
181
182
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-play-timed.rb', line 180

def on_stop(&block)
  @do_on_stop << block
end