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

Inherits:
HeadMusic::Style::Guideline show all
Defined in:
lib/head_music/style/guidelines/consonant_climax.rb

Overview

A counterpoint guideline

Constant Summary collapse

DISSONANT_VIOLATION_KEY =
"guidelines.consonant_climax.violations.dissonant"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Class Method Details

.violation_keys(config = {}) ⇒ Object



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

def self.violation_keys(config = {})
  super + [DISSONANT_VIOLATION_KEY]
end

Instance Method Details

#adherent_climax?Boolean (private)

Returns:

  • (Boolean)


27
28
29
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 27

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

#adherent_high_pitch?Boolean (private)

Returns:

  • (Boolean)


39
40
41
42
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 39

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)

Returns:

  • (Boolean)


44
45
46
47
48
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 44

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

#consonant_climax_pitch?Boolean (private)

Consonance is asked of whichever extreme the melody peaks on, so the two failures can be told apart.

Returns:

  • (Boolean)


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

def consonant_climax_pitch?
  return false unless has_notes?

  descending_melody? ? lowest_pitch_consonant_with_tonic? : highest_pitch_consonant_with_tonic?
end

#descending_melody?Boolean (private)

Returns:

  • (Boolean)


125
126
127
128
129
130
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 125

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)



58
59
60
61
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 58

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)



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

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)

Returns:

  • (Boolean)


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

def highest_pitch_appears_once?
  highest_notes.length == 1
end

#highest_pitch_appears_twice?Boolean (private)

Returns:

  • (Boolean)


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

def highest_pitch_appears_twice?
  highest_notes.length == 2
end

#highest_pitch_appears_twice_with_step_between?Boolean (private)

Returns:

  • (Boolean)


76
77
78
79
80
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 76

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)

Returns:

  • (Boolean)


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

def highest_pitch_consonant_with_tonic?
  !diatonic_interval_to_highest_pitch.dissonant?(:melodic)
end

#lowest_pitch_appears_once?Boolean (private)

Returns:

  • (Boolean)


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

def lowest_pitch_appears_once?
  lowest_notes.length == 1
end

#lowest_pitch_appears_twice?Boolean (private)

Returns:

  • (Boolean)


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

def lowest_pitch_appears_twice?
  lowest_notes.length == 2
end

#lowest_pitch_appears_twice_with_step_between?Boolean (private)

Returns:

  • (Boolean)


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

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)

Returns:

  • (Boolean)


54
55
56
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 54

def lowest_pitch_consonant_with_tonic?
  !diatonic_interval_to_lowest_pitch.dissonant?(:melodic)
end

#marksObject



21
22
23
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 21

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

#notes_between(edge_notes) ⇒ Object (private)



120
121
122
123
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 120

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)



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

def notes_between_highest_notes
  notes_between(highest_notes)
end

#notes_between_lowest_notesObject (private)



116
117
118
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 116

def notes_between_lowest_notes
  notes_between(lowest_notes)
end

#second_noteObject (private)



132
133
134
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 132

def second_note
  notes && notes[1]
end

#single_note_between_highest_notes?Boolean (private)

Returns:

  • (Boolean)


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

def single_note_between_highest_notes?
  notes_between_highest_notes.length == 1
end

#single_note_between_lowest_notes?Boolean (private)

Returns:

  • (Boolean)


108
109
110
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 108

def single_note_between_lowest_notes?
  notes_between_lowest_notes.length == 1
end

#step_between_highest_notes?Boolean (private)

Returns:

  • (Boolean)


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

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)

Returns:

  • (Boolean)


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

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

#violation_keyObject

Two ways to fail, and a student is owed the one that happened: a climax dissonant with the tonic is a different mistake from a climax that keeps coming back. The guideline already decided which, so it says so.



15
16
17
18
19
# File 'lib/head_music/style/guidelines/consonant_climax.rb', line 15

def violation_key
  return self.class.violation_key if consonant_climax_pitch?

  DISSONANT_VIOLATION_KEY
end