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

timed_series = Musa::Series::Constructors.S({ time: 0r, value: 60 },
                                            { time: 1r, value: 64 })
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



170
171
172
173
174
175
176
177
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-play-timed.rb', line 170

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



160
161
162
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-play-timed.rb', line 160

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



158
159
160
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-play-timed.rb', line 158

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 = sequencer.play_timed(timed_series) { |values| }
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



203
204
205
206
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-play-timed.rb', line 203

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



186
187
188
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-play-timed.rb', line 186

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