Class: HeadMusic::Style::Guidelines::ConsonantClimax

Inherits:
Annotation
  • Object
show all
Defined in:
lib/head_music/style/guidelines/consonant_climax.rb

Overview

A counterpoint guideline

Constant Summary collapse

MESSAGE =
"Peak on a consonant high or low note one time or twice with a step between."

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from HeadMusic::Style::Annotation

Instance Method Details

#adherent_climax?Boolean (private)



14
15
16
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 14

def adherent_climax?
  descending_melody? ? adherent_low_pitch? : adherent_high_pitch?
end

#adherent_high_pitch?Boolean (private)



18
19
20
21
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 18

def adherent_high_pitch?
  has_notes? && highest_pitch_consonant_with_tonic? &&
    (highest_pitch_appears_once? || highest_pitch_appears_twice_with_step_between?)
end

#adherent_low_pitch?Boolean (private)



23
24
25
26
27
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 23

def adherent_low_pitch?
  has_notes? &&
    lowest_pitch_consonant_with_tonic? &&
    (lowest_pitch_appears_once? || lowest_pitch_appears_twice_with_step_between?)
end

#descending_melody?Boolean (private)



104
105
106
107
108
109
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 104

def descending_melody?
  # account for the possibility of opening with an octave leap
  notes.length > 1 &&
    [first_note.pitch, second_note.pitch].include?(highest_pitch) &&
    highest_pitch.spelling == tonic_spelling
end

#diatonic_interval_to_highest_pitchObject (private)



37
38
39
40
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 37

def diatonic_interval_to_highest_pitch
  @diatonic_interval_to_highest_pitch ||=
    HeadMusic::Analysis::DiatonicInterval.new(tonic_pitch, highest_pitch)
end

#diatonic_interval_to_lowest_pitchObject (private)



42
43
44
45
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 42

def diatonic_interval_to_lowest_pitch
  @diatonic_interval_to_lowest_pitch ||=
    HeadMusic::Analysis::DiatonicInterval.new(tonic_pitch, lowest_pitch)
end

#highest_pitch_appears_once?Boolean (private)



47
48
49
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 47

def highest_pitch_appears_once?
  highest_notes.length == 1
end

#highest_pitch_appears_twice?Boolean (private)



67
68
69
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 67

def highest_pitch_appears_twice?
  highest_notes.length == 2
end

#highest_pitch_appears_twice_with_step_between?Boolean (private)



55
56
57
58
59
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 55

def highest_pitch_appears_twice_with_step_between?
  highest_pitch_appears_twice? &&
    single_note_between_highest_notes? &&
    step_between_highest_notes?
end

#highest_pitch_consonant_with_tonic?Boolean (private)



29
30
31
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 29

def highest_pitch_consonant_with_tonic?
  diatonic_interval_to_highest_pitch.consonance?(:melodic)
end

#lowest_pitch_appears_once?Boolean (private)



51
52
53
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 51

def lowest_pitch_appears_once?
  lowest_notes.length == 1
end

#lowest_pitch_appears_twice?Boolean (private)



71
72
73
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 71

def lowest_pitch_appears_twice?
  lowest_notes.length == 2
end

#lowest_pitch_appears_twice_with_step_between?Boolean (private)



61
62
63
64
65
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 61

def lowest_pitch_appears_twice_with_step_between?
  lowest_pitch_appears_twice? &&
    single_note_between_lowest_notes? &&
    step_between_lowest_notes?
end

#lowest_pitch_consonant_with_tonic?Boolean (private)



33
34
35
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 33

def lowest_pitch_consonant_with_tonic?
  diatonic_interval_to_lowest_pitch.consonance?(:melodic)
end

#marksObject



8
9
10
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 8

def marks
  HeadMusic::Style::Mark.for_each(highest_notes) unless adherent_climax?
end

#notes_between(edge_notes) ⇒ Object (private)



99
100
101
102
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 99

def notes_between(edge_notes)
  indexes = edge_notes.map { |note| notes.index(note) }
  notes[(indexes.first + 1)..(indexes.last - 1)] || []
end

#notes_between_highest_notesObject (private)



91
92
93
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 91

def notes_between_highest_notes
  notes_between(highest_notes)
end

#notes_between_lowest_notesObject (private)



95
96
97
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 95

def notes_between_lowest_notes
  notes_between(lowest_notes)
end

#second_noteObject (private)



111
112
113
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 111

def second_note
  notes && notes[1]
end

#single_note_between_highest_notes?Boolean (private)



83
84
85
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 83

def single_note_between_highest_notes?
  notes_between_highest_notes.length == 1
end

#single_note_between_lowest_notes?Boolean (private)



87
88
89
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 87

def single_note_between_lowest_notes?
  notes_between_lowest_notes.length == 1
end

#step_between_highest_notes?Boolean (private)



75
76
77
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 75

def step_between_highest_notes?
  HeadMusic::Analysis::MelodicInterval.new(highest_notes.first, notes_between_highest_notes.first).step?
end

#step_between_lowest_notes?Boolean (private)



79
80
81
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 79

def step_between_lowest_notes?
  HeadMusic::Analysis::MelodicInterval.new(lowest_notes.first, notes_between_lowest_notes.first).step?
end