Class: HeadMusic::Analysis::DiatonicInterval::Inversion
- Inherits:
-
Object
- Object
- HeadMusic::Analysis::DiatonicInterval::Inversion
- Defined in:
- lib/head_music/analysis/diatonic_interval/inversion.rb
Overview
Inverting an interval puts its lower pitch on top. The lower pitch keeps its spelling and climbs by whole octaves until it is no longer below the pitch it is being inverted over, and the interval is read from there. Climbing by octaves rather than computing the register outright is what keeps the spelling honest at the edges, where C♭5 sits below B♯4.
Instance Attribute Summary collapse
-
#higher_pitch ⇒ Object
readonly
Returns the value of attribute higher_pitch.
-
#lower_pitch ⇒ Object
readonly
Returns the value of attribute lower_pitch.
Instance Method Summary collapse
-
#initialize(lower_pitch, higher_pitch) ⇒ Inversion
constructor
A new instance of Inversion.
-
#interval ⇒ Object
-
#octave_above(pitch) ⇒ Object
private
-
#raised_lower_pitch ⇒ Object
private
Constructor Details
#initialize(lower_pitch, higher_pitch) ⇒ Inversion
Returns a new instance of Inversion.
10 11 12 13 |
# File 'lib/head_music/analysis/diatonic_interval/inversion.rb', line 10 def initialize(lower_pitch, higher_pitch) @lower_pitch = lower_pitch @higher_pitch = higher_pitch end |
Instance Attribute Details
#higher_pitch ⇒ Object (readonly)
Returns the value of attribute higher_pitch.
8 9 10 |
# File 'lib/head_music/analysis/diatonic_interval/inversion.rb', line 8 def higher_pitch @higher_pitch end |
#lower_pitch ⇒ Object (readonly)
Returns the value of attribute lower_pitch.
8 9 10 |
# File 'lib/head_music/analysis/diatonic_interval/inversion.rb', line 8 def lower_pitch @lower_pitch end |
Instance Method Details
#interval ⇒ Object
15 16 17 |
# File 'lib/head_music/analysis/diatonic_interval/inversion.rb', line 15 def interval HeadMusic::Analysis::DiatonicInterval.new(higher_pitch, raised_lower_pitch) end |
#octave_above(pitch) ⇒ Object (private)
27 28 29 |
# File 'lib/head_music/analysis/diatonic_interval/inversion.rb', line 27 def octave_above(pitch) HeadMusic::Rudiment::Pitch.fetch_or_create(lower_pitch.spelling, pitch.register + 1) end |
#raised_lower_pitch ⇒ Object (private)
21 22 23 24 25 |
# File 'lib/head_music/analysis/diatonic_interval/inversion.rb', line 21 def raised_lower_pitch pitch = lower_pitch pitch = octave_above(pitch) while pitch < higher_pitch pitch end |