Class: Musa::Sequencer::Sequencer
- Extended by:
- Forwardable
- Defined in:
- lib/musa-dsl/sequencer/sequencer-dsl.rb
Overview
High-level DSL wrapper for BaseSequencer.
Provides user-friendly interface with block context management via
with method. Wraps BaseSequencer methods to automatically evaluate
blocks in DSL context, enabling clean musical composition code.
DSL Context
Blocks passed to scheduling methods (now, at, wait, play, every, move)
are evaluated in DSL context via with, providing access to sequencer
methods and allowing for cleaner composition syntax.
Delegation
Delegates most methods to either BaseSequencer or DSLContext:
- Timing: beats_per_bar, ticks_per_beat, position, tick, reset
- Scheduling: now, at, wait, play, play_timed, every, move
- Events: launch, on
- Inspection: size, empty?, everying, playing, moving
Musical Applications
Provides composer-friendly API for:
- Musical composition scripts
- Interactive sequencing
- Live coding
- Algorithmic composition
Defined Under Namespace
Classes: DSLContext
Instance Method Summary collapse
-
#at(position, *value_parameters, **key_parameters) { ... } ⇒ EventHandler
Schedules block to execute at specified position.
-
#beats_per_bar ⇒ Integer?
Returns beats per bar (time signature numerator).
-
#before_tick { ... } ⇒ Object
Registers handler called before each tick.
-
#debug ⇒ Boolean
Returns or enables debug mode.
-
#empty? ⇒ Boolean
Checks if sequencer has no scheduled events.
-
#event_handler ⇒ EventHandler
Returns the event handler for launch/on events.
-
#every(interval, duration: nil, till: nil, **options) { ... } ⇒ EveryControl
Executes block repeatedly at interval.
-
#everying ⇒ EveryingControl
Returns control for active every loops.
-
#initialize(beats_per_bar = nil, ticks_per_beat = nil, offset: nil, sequencer: nil, logger: nil, do_log: nil, do_error_log: nil, log_position_format: nil, dsl_context_class: nil, keep_block_context: nil) { ... } ⇒ Sequencer
constructor
Creates sequencer with optional initialization block.
-
#launch(event_name, *parameters, **key_parameters) ⇒ void
Triggers an event by name.
-
#logger ⇒ Logger?
Returns the sequencer's logger instance.
-
#move(from: nil, to: nil, duration: nil, step: nil, **options) {|value| ... } ⇒ MoveControl
Interpolates values over time.
-
#moving ⇒ MovingControl
Returns control for active move interpolations.
-
#now(*value_parameters, **key_parameters) { ... } ⇒ EventHandler
Executes block immediately at current position.
-
#offset ⇒ Rational?
Returns the sequencer's starting position offset.
-
#on(event_name) { ... } ⇒ void
Registers handler for named event.
-
#on_debug_at { ... } ⇒ Object
Registers debug handler for specific position.
-
#on_error {|Exception| ... } ⇒ Object
Registers error handler for sequencer errors.
-
#on_fast_forward { ... } ⇒ Object
Registers handler called during fast-forward operations.
-
#play(serie, decoder: nil, mode: nil, **options) {|element| ... } ⇒ PlayControl
Plays a series using the decoder.
-
#play_timed(timed_serie, **options) {|element, duration| ... } ⇒ PlayControl
Plays a timed series with explicit timing.
-
#playing ⇒ PlayingControl
Returns control for active play operations.
-
#position ⇒ Rational
Returns current sequencer position in bars.
-
#position=(value) ⇒ void
Sets the current sequencer position.
-
#quantize_position(reference, step, offset: nil) ⇒ Rational
Quantizes a position to a grid.
-
#raw_at(position) { ... } ⇒ Object
Schedules block at position without DSL context wrapping.
-
#reset ⇒ void
Resets sequencer to initial state.
-
#run ⇒ void
Runs the sequencer until all events complete.
-
#size ⇒ Integer
Returns number of scheduled events.
-
#tick ⇒ void
Advances sequencer by one tick and processes events.
-
#tick_duration ⇒ Rational?
Returns duration of a single tick.
-
#ticks_per_bar ⇒ Integer?
Returns total ticks per bar.
-
#ticks_per_beat ⇒ Integer?
Returns ticks per beat (timing resolution).
-
#wait(duration, *value_parameters, **key_parameters) { ... } ⇒ EventHandler
Schedules block after waiting specified duration.
- #with(*value_parameters, **key_parameters, &block) ⇒ Object
Constructor Details
#initialize(beats_per_bar = nil, ticks_per_beat = nil, offset: nil, sequencer: nil, logger: nil, do_log: nil, do_error_log: nil, log_position_format: nil, dsl_context_class: nil, keep_block_context: nil) { ... } ⇒ Sequencer
Creates sequencer with optional initialization block.
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 |
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 395 def initialize( = nil, ticks_per_beat = nil, offset: nil, sequencer: nil, logger: nil, do_log: nil, do_error_log: nil, log_position_format: nil, dsl_context_class: nil, keep_block_context: nil, &block) @sequencer = sequencer @sequencer ||= BaseSequencer.new , ticks_per_beat, offset: offset, logger: logger, do_log: do_log, do_error_log: do_error_log, log_position_format: log_position_format dsl_context_class ||= DSLContext @dsl = dsl_context_class.new @sequencer, keep_block_context: keep_block_context @dsl.with &block if block_given? end |
Instance Method Details
#at(position, *value_parameters, **key_parameters) { ... } ⇒ EventHandler
Schedules block to execute at specified position.
Delegated from Musa::Sequencer::Sequencer::DSLContext#at.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 249
|
#beats_per_bar ⇒ Integer?
Returns beats per bar (time signature numerator).
Delegated from BaseSequencer#beats_per_bar.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 84
|
#before_tick { ... } ⇒ Object
Registers handler called before each tick.
Delegated from BaseSequencer#before_tick.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 154
|
#debug ⇒ Boolean
Returns or enables debug mode.
Delegated from Musa::Sequencer::Sequencer::DSLContext#debug.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 232
|
#empty? ⇒ Boolean
Checks if sequencer has no scheduled events.
Delegated from BaseSequencer#empty?.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 126
|
#event_handler ⇒ EventHandler
Returns the event handler for launch/on events.
Delegated from BaseSequencer#event_handler.
197 198 199 200 201 202 203 204 205 206 |
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 197 def_delegators :@sequencer, :beats_per_bar, :ticks_per_beat, :ticks_per_bar, :tick_duration, :offset, :size, :empty?, :on_debug_at, :on_error, :on_fast_forward, :before_tick, :raw_at, :tick, :reset, :position=, :event_handler |
#every(interval, duration: nil, till: nil, **options) { ... } ⇒ EveryControl
Executes block repeatedly at interval.
Delegated from Musa::Sequencer::Sequencer::DSLContext#every.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 293
|
#everying ⇒ EveryingControl
Returns control for active every loops.
Delegated from Musa::Sequencer::Sequencer::DSLContext#everying.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 318
|
#launch(event_name, *parameters, **key_parameters) ⇒ void
This method returns an undefined value.
Triggers an event by name.
Delegated from Musa::Sequencer::Sequencer::DSLContext#launch.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 339
|
#logger ⇒ Logger?
Returns the sequencer's logger instance.
Delegated from Musa::Sequencer::Sequencer::DSLContext#logger.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 225
|
#move(from: nil, to: nil, duration: nil, step: nil, **options) {|value| ... } ⇒ MoveControl
Interpolates values over time.
Delegated from Musa::Sequencer::Sequencer::DSLContext#move.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 305
|
#moving ⇒ MovingControl
Returns control for active move interpolations.
Delegated from Musa::Sequencer::Sequencer::DSLContext#moving.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 332
|
#now(*value_parameters, **key_parameters) { ... } ⇒ EventHandler
Executes block immediately at current position.
Delegated from Musa::Sequencer::Sequencer::DSLContext#now.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 239
|
#offset ⇒ Rational?
Returns the sequencer's starting position offset.
Delegated from BaseSequencer#offset.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 112
|
#on(event_name) { ... } ⇒ void
This method returns an undefined value.
Registers handler for named event.
Delegated from Musa::Sequencer::Sequencer::DSLContext#on.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 349
|
#on_debug_at { ... } ⇒ Object
Registers debug handler for specific position.
Delegated from BaseSequencer#on_debug_at.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 133
|
#on_error {|Exception| ... } ⇒ Object
Registers error handler for sequencer errors.
Delegated from BaseSequencer#on_error.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 140
|
#on_fast_forward { ... } ⇒ Object
Registers handler called during fast-forward operations.
Delegated from BaseSequencer#on_fast_forward.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 147
|
#play(serie, decoder: nil, mode: nil, **options) {|element| ... } ⇒ PlayControl
Plays a series using the decoder.
Delegated from Musa::Sequencer::Sequencer::DSLContext#play.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 271
|
#play_timed(timed_serie, **options) {|element, duration| ... } ⇒ PlayControl
Plays a timed series with explicit timing.
Delegated from Musa::Sequencer::Sequencer::DSLContext#play_timed.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 283
|
#playing ⇒ PlayingControl
Returns control for active play operations.
Delegated from Musa::Sequencer::Sequencer::DSLContext#playing.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 325
|
#position ⇒ Rational
Returns current sequencer position in bars.
Delegated from Musa::Sequencer::Sequencer::DSLContext#position.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 208
|
#position=(value) ⇒ void
This method returns an undefined value.
Sets the current sequencer position.
Delegated from BaseSequencer#position=.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 183
|
#quantize_position(reference, step, offset: nil) ⇒ Rational
Quantizes a position to a grid.
Delegated from Musa::Sequencer::Sequencer::DSLContext#quantize_position.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 215
|
#raw_at(position) { ... } ⇒ Object
Schedules block at position without DSL context wrapping.
Delegated from BaseSequencer#raw_at.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 161
|
#reset ⇒ void
This method returns an undefined value.
Resets sequencer to initial state.
Delegated from BaseSequencer#reset.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 176
|
#run ⇒ void
This method returns an undefined value.
Runs the sequencer until all events complete.
Delegated from Musa::Sequencer::Sequencer::DSLContext#run.
364 |
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 364 def_delegators :@dsl, :position, :quantize_position, :logger, :debug |
#size ⇒ Integer
Returns number of scheduled events.
Delegated from BaseSequencer#size.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 119
|
#tick ⇒ void
This method returns an undefined value.
Advances sequencer by one tick and processes events.
Delegated from BaseSequencer#tick.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 169
|
#tick_duration ⇒ Rational?
Returns duration of a single tick.
Delegated from BaseSequencer#tick_duration.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 105
|
#ticks_per_bar ⇒ Integer?
Returns total ticks per bar.
Delegated from BaseSequencer#ticks_per_bar.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 98
|
#ticks_per_beat ⇒ Integer?
Returns ticks per beat (timing resolution).
Delegated from BaseSequencer#ticks_per_beat.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 91
|
#wait(duration, *value_parameters, **key_parameters) { ... } ⇒ EventHandler
Schedules block after waiting specified duration.
Delegated from Musa::Sequencer::Sequencer::DSLContext#wait.
|
|
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 260
|
#with(*value_parameters, **key_parameters, &block) ⇒ Object
490 491 492 |
# File 'lib/musa-dsl/sequencer/sequencer-dsl.rb', line 490 def with(*value_parameters, **key_parameters, &block) @dsl.with(*value_parameters, **key_parameters, &block) end |