Class: HeadMusic::Content::Voice::MelodicLine
- Inherits:
-
Object
- Object
- HeadMusic::Content::Voice::MelodicLine
- Defined in:
- lib/head_music/content/voice/melodic_line.rb
Overview
The melodic view of a voice: its notes read as the sequence of consecutive pairs, the interval spanned by each pair, and the leaps among them. Built from an ordered list of notes and memoizes the pairs, so callers sharing a MelodicLine see the same pair objects.
Instance Attribute Summary collapse
-
#notes ⇒ Object
readonly
Returns the value of attribute notes.
Instance Method Summary collapse
-
#initialize(notes) ⇒ MelodicLine
constructor
A new instance of MelodicLine.
-
#large_leaps ⇒ Object
-
#leaps ⇒ Object
-
#melodic_intervals ⇒ Object
-
#melodic_note_pairs ⇒ Object
Constructor Details
#initialize(notes) ⇒ MelodicLine
Returns a new instance of MelodicLine.
9 10 11 |
# File 'lib/head_music/content/voice/melodic_line.rb', line 9 def initialize(notes) @notes = notes end |
Instance Attribute Details
#notes ⇒ Object (readonly)
Returns the value of attribute notes.
7 8 9 |
# File 'lib/head_music/content/voice/melodic_line.rb', line 7 def notes @notes end |
Instance Method Details
#large_leaps ⇒ Object
28 29 30 |
# File 'lib/head_music/content/voice/melodic_line.rb', line 28 def large_leaps melodic_note_pairs.select(&:large_leap?) end |
#leaps ⇒ Object
24 25 26 |
# File 'lib/head_music/content/voice/melodic_line.rb', line 24 def leaps melodic_note_pairs.select(&:leap?) end |
#melodic_intervals ⇒ Object
19 20 21 22 |
# File 'lib/head_music/content/voice/melodic_line.rb', line 19 def melodic_intervals @melodic_intervals ||= melodic_note_pairs.map { |note_pair| HeadMusic::Analysis::MelodicInterval.new(*note_pair.notes) } end |
#melodic_note_pairs ⇒ Object
13 14 15 16 17 |
# File 'lib/head_music/content/voice/melodic_line.rb', line 13 def melodic_note_pairs @melodic_note_pairs ||= notes.each_cons(2).map do |first_note, second_note| MelodicNotePair.new(first_note, second_note) end end |