Class: Musicality::ScoreCollator
- Inherits:
-
Object
- Object
- Musicality::ScoreCollator
- Defined in:
- lib/musicality/performance/conversion/score_collator.rb
Overview
Combine multiple program segments to one, using tempo/note/dynamic replication and truncation where necessary.
Instance Method Summary collapse
- #collate_key_changes ⇒ Object
- #collate_meter_changes ⇒ Object
- #collate_parts ⇒ Object
- #collate_tempo_changes ⇒ Object
-
#initialize(score) ⇒ ScoreCollator
constructor
A new instance of ScoreCollator.
Constructor Details
#initialize(score) ⇒ ScoreCollator
Returns a new instance of ScoreCollator.
8 9 10 11 12 13 14 |
# File 'lib/musicality/performance/conversion/score_collator.rb', line 8 def initialize score unless score.valid? raise ScoreNotValidError, "errors found in score: #{score.errors}" end @score = score @program = score.program.any? ? score.program : [0...score.duration] end |
Instance Method Details
#collate_key_changes ⇒ Object
39 40 41 |
# File 'lib/musicality/performance/conversion/score_collator.rb', line 39 def collate_key_changes collate_changes(@score.start_key, @score.key_changes, @program) end |
#collate_meter_changes ⇒ Object
35 36 37 |
# File 'lib/musicality/performance/conversion/score_collator.rb', line 35 def collate_meter_changes collate_changes(@score.start_meter, @score.meter_changes, @program) end |
#collate_parts ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/musicality/performance/conversion/score_collator.rb', line 16 def collate_parts Hash[ @score.parts.map do |name, part| dyn_comp = ValueComputer.new(part.start_dynamic,part.dynamic_changes) new_part = part.clone new_part.notes = collate_notes(part.notes, @program) new_part.start_dynamic, new_part.dynamic_changes = collate_changes( part.start_dynamic, part.dynamic_changes, @program ) [ name, new_part ] end ] end |
#collate_tempo_changes ⇒ Object
31 32 33 |
# File 'lib/musicality/performance/conversion/score_collator.rb', line 31 def collate_tempo_changes collate_changes(@score.start_tempo, @score.tempo_changes, @program) end |