Class: Music::Performance::ScoreCollator
- Inherits:
-
Object
- Object
- Music::Performance::ScoreCollator
- Defined in:
- lib/music-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_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.
9 10 11 12 13 14 |
# File 'lib/music-performance/conversion/score_collator.rb', line 9 def initialize score unless score.valid? raise ScoreNotValidError, "errors found in score: #{score.errors}" end @score = score end |
Instance Method Details
#collate_meter_changes ⇒ Object
36 37 38 39 |
# File 'lib/music-performance/conversion/score_collator.rb', line 36 def collate_meter_changes collate_changes(@score.start_meter, @score.meter_changes, @score.program.segments) end |
#collate_parts ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/music-performance/conversion/score_collator.rb', line 16 def collate_parts segments = @score.program.segments Hash[ @score.parts.map do |name, part| new_dcs = collate_changes(part.start_dynamic, part.dynamic_changes, segments) new_notes = collate_notes(part.notes, segments) new_part = Music::Transcription::Part.new(part.start_dynamic, dynamic_changes: new_dcs, notes: new_notes) [ name, new_part ] end ] end |
#collate_tempo_changes ⇒ Object
31 32 33 34 |
# File 'lib/music-performance/conversion/score_collator.rb', line 31 def collate_tempo_changes collate_changes(@score.start_tempo, @score.tempo_changes, @score.program.segments) end |