Class: HeadMusic::Style::Guidelines::AvoidOverlappingVoices
Overview
Instance Method Summary
collapse
Instance Method Details
#marks ⇒ Object
6
7
8
|
# File 'lib/head_music/style/guidelines/avoid_overlapping_voices.rb', line 6
def marks
overlappings
end
|
#overlappings ⇒ Object
12
13
14
|
# File 'lib/head_music/style/guidelines/avoid_overlapping_voices.rb', line 12
def overlappings
overlappings_of_lower_voices + overlappings_of_higher_voices
end
|
#overlappings_for_voices(voices, comparison_operator) ⇒ Object
24
25
26
27
28
29
30
31
|
# File 'lib/head_music/style/guidelines/avoid_overlapping_voices.rb', line 24
def overlappings_for_voices(voices, comparison_operator)
[].tap do |marks|
voices.each do |a_voice|
overlapped_notes = overlappings_with_voice(a_voice, comparison_operator)
marks << HeadMusic::Style::Mark.for_each(overlapped_notes)
end
end.flatten.compact
end
|
#overlappings_of_higher_voices ⇒ Object
20
21
22
|
# File 'lib/head_music/style/guidelines/avoid_overlapping_voices.rb', line 20
def overlappings_of_higher_voices
overlappings_for_voices(higher_voices, :<)
end
|
#overlappings_of_lower_voices ⇒ Object
16
17
18
|
# File 'lib/head_music/style/guidelines/avoid_overlapping_voices.rb', line 16
def overlappings_of_lower_voices
overlappings_for_voices(lower_voices, :>)
end
|
#overlappings_with_voice(other_voice, comparison_operator) ⇒ Object
33
34
35
36
37
38
39
40
|
# File 'lib/head_music/style/guidelines/avoid_overlapping_voices.rb', line 33
def overlappings_with_voice(other_voice, comparison_operator)
voice.notes.drop(1).select do |note|
preceding_note = other_voice.note_preceding(note.position)
following_note = other_voice.note_following(note.position)
preceding_note&.pitch&.send(comparison_operator, note.pitch) ||
following_note&.pitch&.send(comparison_operator, note.pitch)
end
end
|