class HeadMusic::Style::Annotation
An Annotation
encapsulates an issue with or comment on a voice
Constants
- MESSAGE
Attributes
voice[R]
Public Class Methods
new(voice)
click to toggle source
# File lib/head_music/style/annotation.rb, line 27 def initialize(voice) @voice = voice end
Public Instance Methods
adherent?()
click to toggle source
# File lib/head_music/style/annotation.rb, line 35 def adherent? fitness == 1 end
end_position()
click to toggle source
# File lib/head_music/style/annotation.rb, line 47 def end_position [marks].flatten.compact.map(&:end_position).max end
fitness()
click to toggle source
# File lib/head_music/style/annotation.rb, line 31 def fitness [marks].flatten.compact.map(&:fitness).reduce(1, :*) end
message()
click to toggle source
# File lib/head_music/style/annotation.rb, line 51 def message self.class::MESSAGE end
notes?()
click to toggle source
# File lib/head_music/style/annotation.rb, line 39 def notes? first_note end
start_position()
click to toggle source
# File lib/head_music/style/annotation.rb, line 43 def start_position [marks].flatten.compact.map(&:start_position).min end
Protected Instance Methods
bass_voice?()
click to toggle source
# File lib/head_music/style/annotation.rb, line 91 def bass_voice? lower_voices.empty? end
cantus_firmus()
click to toggle source
# File lib/head_music/style/annotation.rb, line 73 def cantus_firmus @cantus_firmus ||= other_voices.detect(&:cantus_firmus?) || other_voices.first end
diatonic_interval_from_tonic(note)
click to toggle source
# File lib/head_music/style/annotation.rb, line 85 def diatonic_interval_from_tonic(note) tonic_to_use = tonic_pitch tonic_to_use -= HeadMusic::ChromaticInterval.get(:perfect_octave) while tonic_to_use > note.pitch HeadMusic::DiatonicInterval.new(tonic_to_use, note.pitch) end
downbeat_harmonic_intervals()
click to toggle source
# File lib/head_music/style/annotation.rb, line 105 def downbeat_harmonic_intervals @downbeat_harmonic_intervals ||= cantus_firmus.notes. map { |note| HeadMusic::HarmonicInterval.new(note.voice, voice, note.position) }. reject { |interval| interval.notes.length < 2 } end
first_note()
click to toggle source
# File lib/head_music/style/annotation.rb, line 57 def first_note notes&.first end
harmonic_intervals()
click to toggle source
# File lib/head_music/style/annotation.rb, line 112 def harmonic_intervals @harmonic_intervals ||= positions. map { |position| HeadMusic::HarmonicInterval.new(cantus_firmus, voice, position) }. reject { |harmonic_interval| harmonic_interval.notes.length < 2 } end
higher_voices()
click to toggle source
# File lib/head_music/style/annotation.rb, line 77 def higher_voices @higher_voices ||= unsorted_higher_voices.sort_by(&:highest_pitch).reverse end
last_note()
click to toggle source
# File lib/head_music/style/annotation.rb, line 61 def last_note notes&.last end
lower_voices()
click to toggle source
# File lib/head_music/style/annotation.rb, line 81 def lower_voices @lower_voices ||= unsorted_lower_voices.sort_by(&:lowest_pitch).reverse end
motions()
click to toggle source
# File lib/head_music/style/annotation.rb, line 99 def motions downbeat_harmonic_intervals.each_cons(2).map do |harmonic_interval_pair| HeadMusic::Motion.new(*harmonic_interval_pair) end end
other_voices()
click to toggle source
# File lib/head_music/style/annotation.rb, line 69 def other_voices @other_voices ||= voices.reject { |part| part == voice } end
positions()
click to toggle source
# File lib/head_music/style/annotation.rb, line 119 def positions @positions ||= voices.map(&:notes).flatten.map(&:position).sort.uniq(&:to_s) end
starts_on_tonic?()
click to toggle source
# File lib/head_music/style/annotation.rb, line 95 def starts_on_tonic? tonic_spelling == first_note.spelling end
tonic_pitch()
click to toggle source
# File lib/head_music/style/annotation.rb, line 132 def tonic_pitch @tonic_pitch ||= HeadMusic::Pitch.get(tonic_spelling) end
unsorted_higher_voices()
click to toggle source
# File lib/head_music/style/annotation.rb, line 124 def unsorted_higher_voices other_voices.select { |part| part.highest_pitch && highest_pitch && part.highest_pitch > highest_pitch } end
unsorted_lower_voices()
click to toggle source
# File lib/head_music/style/annotation.rb, line 128 def unsorted_lower_voices other_voices.select { |part| part.lowest_pitch && lowest_pitch && part.lowest_pitch < lowest_pitch } end
voices()
click to toggle source
# File lib/head_music/style/annotation.rb, line 65 def voices @voices ||= voice.composition.voices end