Module: Musa::Datasets::Score::Render
- Included in:
- Musa::Datasets::Score
- Defined in:
- lib/musa-dsl/datasets/score/render.rb
Overview
Real-time rendering of scores on sequencers.
Render provides the #render method for playing back scores on a Sequencer::Sequencer. Events are scheduled at their score times relative to the sequencer's current position.
Time Calculation
Score times are 1-based (first beat is 1), but sequencer waits are 0-based. The conversion is:
effective_wait = score_time - 1
So score time 1 becomes wait 0 (immediate), time 2 becomes wait 1, etc.
Nested Scores
Scores can contain other scores. When a nested score is encountered, it's rendered recursively at the appropriate time.
Instance Method Summary collapse
-
#render(on:) {|event| ... } ⇒ nil
Renders score on sequencer.
Instance Method Details
#render(on:) {|event| ... } ⇒ nil
Renders score on sequencer.
Schedules all events in the score on the sequencer, calling the block for each event at its scheduled time. Score times are converted to sequencer wait times (score_time - 1).
Supports nested scores recursively.
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/musa-dsl/datasets/score/render.rb', line 112 def render(on:, &block) @score.keys.each do |score_at| effective_wait = score_at - 1r @score[score_at].each do |element| case element when Score on.wait effective_wait do element.render(on: on, &block) end when Abs on.wait effective_wait do block.call(element) end else raise ArgumentError, "Can't sequence #{element} because it's not an Abs dataset" end end end nil end |