Class: HeadMusic::Content::Voice::MelodicNotePair
- Inherits:
-
Object
- Object
- HeadMusic::Content::Voice::MelodicNotePair
- Defined in:
- lib/head_music/content/voice/melodic_note_pair.rb
Overview
A pair of consecutive notes in a melodic line, used to analyze intervals and leaps.
Instance Attribute Summary collapse
-
#first_note ⇒ Object
readonly
Returns the value of attribute first_note.
-
#second_note ⇒ Object
readonly
Returns the value of attribute second_note.
Instance Method Summary collapse
-
#initialize(first_note, second_note) ⇒ MelodicNotePair
constructor
A new instance of MelodicNotePair.
-
#melodic_interval ⇒ Object
-
#notes ⇒ Object
-
#pitches ⇒ Object
Constructor Details
#initialize(first_note, second_note) ⇒ MelodicNotePair
Returns a new instance of MelodicNotePair.
16 17 18 19 |
# File 'lib/head_music/content/voice/melodic_note_pair.rb', line 16 def initialize(first_note, second_note) @first_note = first_note @second_note = second_note end |
Instance Attribute Details
#first_note ⇒ Object (readonly)
Returns the value of attribute first_note.
4 5 6 |
# File 'lib/head_music/content/voice/melodic_note_pair.rb', line 4 def first_note @first_note end |
#second_note ⇒ Object (readonly)
Returns the value of attribute second_note.
4 5 6 |
# File 'lib/head_music/content/voice/melodic_note_pair.rb', line 4 def second_note @second_note end |
Instance Method Details
#melodic_interval ⇒ Object
29 30 31 |
# File 'lib/head_music/content/voice/melodic_note_pair.rb', line 29 def melodic_interval @melodic_interval ||= HeadMusic::Analysis::MelodicInterval.new(*notes) end |
#notes ⇒ Object
21 22 23 |
# File 'lib/head_music/content/voice/melodic_note_pair.rb', line 21 def notes @notes ||= [first_note, second_note] end |
#pitches ⇒ Object
25 26 27 |
# File 'lib/head_music/content/voice/melodic_note_pair.rb', line 25 def pitches @pitches ||= notes.map(&:pitch) end |