Sha256: ee6a7f764603c7fc21359f7396cf49a7f3b4852f34362772534d0fc5ebdebb97
Contents?: true
Size: 1.16 KB
Versions: 2
Compression:
Stored size: 1.16 KB
Contents
module HeadMusic::Style::Annotations end class HeadMusic::Style::Annotations::AvoidOverlappingVoices < HeadMusic::Style::Annotation MESSAGE = "Avoid overlapping voices. Maintain the high-low relationship between voices even for adjacent notes." def marks overlappings end private def overlappings overlappings_of_lower_voices + overlappings_of_higher_voices end def overlappings_of_lower_voices overlappings_for_voices(lower_voices, :>) end def overlappings_of_higher_voices overlappings_for_voices(higher_voices, :<) end def overlappings_for_voices(voices, comparison_operator) [].tap do |marks| voices.each do |higher_voice| overlapped_notes = voice.notes.select do |note| preceding_note = higher_voice.note_preceding(note.position) following_note = higher_voice.note_following(note.position) (preceding_note && preceding_note.pitch.send(comparison_operator, note.pitch)) || (following_note && following_note.pitch.send(comparison_operator, note.pitch)) end marks << HeadMusic::Style::Mark.for_each(overlapped_notes) end end.flatten.compact end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
head_music-0.17.0 | lib/head_music/style/annotations/avoid_overlapping_voices.rb |
head_music-0.16.2 | lib/head_music/style/annotations/avoid_overlapping_voices.rb |