Class: HeadMusic::Style::Guidelines::WeakBeatDissonanceTreatment
- Inherits:
-
Annotation
- Object
- Annotation
- HeadMusic::Style::Guidelines::WeakBeatDissonanceTreatment
show all
- Defined in:
- lib/head_music/style/guidelines/weak_beat_dissonance_treatment.rb
Overview
Constant Summary
collapse
- MESSAGE =
"Use only passing tones for dissonances on the weak beat."
Instance Method Summary
collapse
Instance Method Details
#cantus_firmus_positions ⇒ Object
30
31
32
|
# File 'lib/head_music/style/guidelines/weak_beat_dissonance_treatment.rb', line 30
def cantus_firmus_positions
@cantus_firmus_positions ||= Set.new(cantus_firmus.notes.map { |n| n.position.to_s })
end
|
#dissonant_weak_beat_notes ⇒ Object
18
19
20
|
# File 'lib/head_music/style/guidelines/weak_beat_dissonance_treatment.rb', line 18
def dissonant_weak_beat_notes
weak_beat_notes.select { |note| dissonant_with_cantus?(note) }
end
|
#dissonant_with_cantus?(note) ⇒ Boolean
34
35
36
37
|
# File 'lib/head_music/style/guidelines/weak_beat_dissonance_treatment.rb', line 34
def dissonant_with_cantus?(note)
interval = HeadMusic::Analysis::HarmonicInterval.new(cantus_firmus, voice, note.position)
interval.notes.length == 2 && interval.dissonance?(:two_part_harmony)
end
|
#downbeat_position?(position) ⇒ Boolean
26
27
28
|
# File 'lib/head_music/style/guidelines/weak_beat_dissonance_treatment.rb', line 26
def downbeat_position?(position)
cantus_firmus_positions.include?(position.to_s)
end
|
#following_note(note) ⇒ Object
55
56
57
58
|
# File 'lib/head_music/style/guidelines/weak_beat_dissonance_treatment.rb', line 55
def following_note(note)
index = notes.index(note)
notes[index + 1] if index && index < notes.length - 1
end
|
#marks ⇒ Object
8
9
10
11
12
13
14
|
# File 'lib/head_music/style/guidelines/weak_beat_dissonance_treatment.rb', line 8
def marks
return [] unless cantus_firmus&.notes&.any?
dissonant_weak_beat_notes.reject { |note| passing_tone?(note) }.map do |note|
HeadMusic::Style::Mark.for(note)
end
end
|
#passing_tone?(note) ⇒ Boolean
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/head_music/style/guidelines/weak_beat_dissonance_treatment.rb', line 39
def passing_tone?(note)
prev = preceding_note(note)
foll = following_note(note)
return false unless prev && foll
approach = HeadMusic::Analysis::MelodicInterval.new(prev, note)
departure = HeadMusic::Analysis::MelodicInterval.new(note, foll)
approach.step? && departure.step? && approach.direction == departure.direction
end
|
#preceding_note(note) ⇒ Object
50
51
52
53
|
# File 'lib/head_music/style/guidelines/weak_beat_dissonance_treatment.rb', line 50
def preceding_note(note)
index = notes.index(note)
notes[index - 1] if index && index > 0
end
|
#weak_beat_notes ⇒ Object
22
23
24
|
# File 'lib/head_music/style/guidelines/weak_beat_dissonance_treatment.rb', line 22
def weak_beat_notes
notes.reject { |note| downbeat_position?(note.position) }
end
|