Class: Musa::Sequencer::BaseSequencer::PlayControl Private
- Inherits:
-
EventHandler
- Object
- EventHandler
- Musa::Sequencer::BaseSequencer::PlayControl
- Defined in:
- lib/musa-dsl/sequencer/base-sequencer-implementation-play.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 operations.
Manages play lifecycle including pause/continue and after callbacks. Extends EventHandler to support custom events and hierarchical control.
Pause/Continue
When paused:
- Stores continuation parameters (series state, evaluator, etc.)
- Stops processing series
- Awaits continue call
When continued:
- Restores continuation parameters
- Resumes play from stored position
After Callbacks
Executed after play completes, with optional delay in bars.
Instance Attribute Summary collapse
-
#do_after ⇒ Array<Hash>
readonly
private
After callbacks with delays (only on natural termination).
-
#do_on_stop ⇒ Array<Proc>
readonly
private
Callbacks when play stops (any reason, including manual stop).
Instance Method Summary collapse
-
#after(bars = nil) { ... } ⇒ void
private
Registers callback to execute after play completes naturally (series exhausted).
-
#continue ⇒ void
private
Continues from pause.
-
#initialize(parent, on_stop: nil, after_bars: nil, after: nil) ⇒ PlayControl
constructor
private
Creates play control with optional callbacks.
-
#on_stop { ... } ⇒ void
private
Registers callback for when play stops (any reason, including manual stop).
-
#pause ⇒ void
private
Pauses play and stores continuation state.
-
#store_continuation(sequencer:, serie:, neumalang_context:, mode:, decoder:, play_eval:, mode_args:) ⇒ void
private
Stores state for continue operation.
Constructor Details
#initialize(parent, on_stop: nil, after_bars: nil, after: nil) ⇒ PlayControl
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 control with optional callbacks.
272 273 274 275 276 277 278 279 280 |
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-play.rb', line 272 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 after(, &after) if after end |
Instance Attribute Details
#do_after ⇒ Array<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 (only on natural termination).
262 263 264 |
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-play.rb', line 262 def do_after @do_after end |
#do_on_stop ⇒ Array<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 callbacks when play stops (any reason, including manual stop).
260 261 262 |
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-play.rb', line 260 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 play completes naturally (series exhausted). Not called on manual stop.
357 358 359 360 |
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-play.rb', line 357 def after( = nil, &block) ||= 0 @do_after << { bars: .rationalize, block: block } end |
#continue ⇒ 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.
Continues from pause.
Restores paused state and resumes play using stored continuation.
329 330 331 332 |
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-play.rb', line 329 def continue super @continuation_sequencer&.continuation_play(@continuation_parameters) 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 play stops (any reason, including manual stop).
341 342 343 |
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-play.rb', line 341 def on_stop(&block) @do_on_stop << block end |
#pause ⇒ 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.
Pauses play and stores continuation state.
Sets paused flag. Continuation must be stored separately via store_continuation.
290 291 292 |
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-play.rb', line 290 def pause @paused = true end |
#store_continuation(sequencer:, serie:, neumalang_context:, mode:, decoder:, play_eval:, mode_args:) ⇒ 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.
Stores state for continue operation.
Saves all parameters needed to resume play from current position. Called automatically by _play when paused.
310 311 312 313 314 315 316 317 318 319 320 |
# File 'lib/musa-dsl/sequencer/base-sequencer-implementation-play.rb', line 310 def store_continuation(sequencer:, serie:, neumalang_context:, mode:, decoder:, play_eval:, mode_args:) @continuation_sequencer = sequencer @continuation_parameters = { serie: serie, control: self, neumalang_context: neumalang_context, mode: mode, decoder: decoder, play_eval: play_eval, mode_args: mode_args } end |