Class: HeadMusic::Content::Voice::MelodicNotePair

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_noteObject (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_noteObject (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_intervalObject



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

#notesObject



21
22
23
# File 'lib/head_music/content/voice/melodic_note_pair.rb', line 21

def notes
  @notes ||= [first_note, second_note]
end

#pitchesObject



25
26
27
# File 'lib/head_music/content/voice/melodic_note_pair.rb', line 25

def pitches
  @pitches ||= notes.map(&:pitch)
end