Sha256: 02c84d493cdc16e85b57a2d044c0595df97d35f77b04d75fc76915561503acc4
Contents?: true
Size: 1.35 KB
Versions: 5
Compression:
Stored size: 1.35 KB
Contents
module HeadMusic::Style::Annotations end class HeadMusic::Style::Annotations::AvoidOverlappingVoices < HeadMusic::Style::Annotation MESSAGE = "Avoid overlapping voices." def marks overlappings end private def overlappings overlappings_of_lower_voices + overlappings_of_higher_voices end def overlappings_of_lower_voices [].tap do |marks| lower_voices.each do |lower_voice| overlapped_notes = voice.notes.select do |note| preceding_note = lower_voice.note_preceding(note.position) following_note = lower_voice.note_following(note.position) (preceding_note && preceding_note.pitch > note.pitch) || (following_note && following_note.pitch > note.pitch) end marks << HeadMusic::Style::Mark.for_each(overlapped_notes) end end.flatten.compact end def overlappings_of_higher_voices [].tap do |marks| higher_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 < note.pitch) || (following_note && following_note.pitch < note.pitch) end marks << HeadMusic::Style::Mark.for_each(overlapped_notes) end end.flatten.compact end end
Version data entries
5 entries across 5 versions & 1 rubygems