Class: HeadMusic::Style::Guidelines::WeakBeatDissonanceTreatment

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

Overview

A counterpoint guideline

Constant Summary collapse

MESSAGE =
"Use only passing tones for dissonances on the weak beat."

Instance Method Summary collapse

Constructor Details

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

Instance Method Details

#cantus_firmus_positionsObject (private)



34
35
36
# File 'lib/head_music/style/guidelines/weak_beat_dissonance_treatment.rb', line 34

def cantus_firmus_positions
  @cantus_firmus_positions ||= Set.new(cantus_firmus.notes.map { |n| n.position.to_s })
end

#dissonant_weak_beat_notesObject (private)



22
23
24
# File 'lib/head_music/style/guidelines/weak_beat_dissonance_treatment.rb', line 22

def dissonant_weak_beat_notes
  weak_beat_notes.select { |note| dissonant_with_cantus?(note) }
end

#dissonant_with_cantus?(note) ⇒ Boolean (private)

Returns:

  • (Boolean)


38
39
40
41
# File 'lib/head_music/style/guidelines/weak_beat_dissonance_treatment.rb', line 38

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 (private)

Returns:

  • (Boolean)


30
31
32
# File 'lib/head_music/style/guidelines/weak_beat_dissonance_treatment.rb', line 30

def downbeat_position?(position)
  cantus_firmus_positions.include?(position.to_s)
end

#following_note(note) ⇒ Object (private)



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

def following_note(note)
  index = notes.index(note)
  notes[index + 1] if index && index < notes.length - 1
end

#marksObject



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| recognized_figure?(note) }.map do |note|
    HeadMusic::Style::Mark.for(note)
  end
end

#melodic_interval_between(note1, note2) ⇒ Object (private)



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

def melodic_interval_between(note1, note2)
  HeadMusic::Analysis::MelodicInterval.new(note1, note2)
end

#passing_tone?(note) ⇒ Boolean (private)

Returns:

  • (Boolean)


43
44
45
46
47
48
49
50
51
52
# File 'lib/head_music/style/guidelines/weak_beat_dissonance_treatment.rb', line 43

def passing_tone?(note)
  prev = preceding_note(note)
  foll = following_note(note)
  return false unless prev && foll

  approach = melodic_interval_between(prev, note)
  departure = melodic_interval_between(note, foll)

  approach.step? && departure.step? && approach.direction == departure.direction
end

#preceding_note(note) ⇒ Object (private)



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

def preceding_note(note)
  index = notes.index(note)
  notes[index - 1] if index && index > 0
end

#recognized_figure?(note) ⇒ Boolean (private)

Returns:

  • (Boolean)


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

def recognized_figure?(note)
  passing_tone?(note)
end

#weak_beat_notesObject (private)



26
27
28
# File 'lib/head_music/style/guidelines/weak_beat_dissonance_treatment.rb', line 26

def weak_beat_notes
  notes.reject { |note| downbeat_position?(note.position) }
end