Class: HeadMusic::Rudiment::TonalContext
- Defined in:
- lib/head_music/rudiment/tonal_context.rb
Overview
Abstract base class representing a tonal context (system of pitches with a tonal center)
Direct Known Subclasses
Instance Attribute Summary collapse
-
#tonic_spelling ⇒ Object
readonly
Returns the value of attribute tonic_spelling.
Instance Method Summary collapse
-
#initialize(tonic_spelling) ⇒ TonalContext
constructor
A new instance of TonalContext.
- #key_signature ⇒ Object
- #pitch_classes ⇒ Object
- #pitches(octave = nil) ⇒ Object
- #scale ⇒ Object
- #spellings ⇒ Object
- #tonic_pitch(octave = 4) ⇒ Object
Constructor Details
#initialize(tonic_spelling) ⇒ TonalContext
Returns a new instance of TonalContext.
8 9 10 |
# File 'lib/head_music/rudiment/tonal_context.rb', line 8 def initialize(tonic_spelling) @tonic_spelling = HeadMusic::Rudiment::Spelling.get(tonic_spelling) end |
Instance Attribute Details
#tonic_spelling ⇒ Object (readonly)
Returns the value of attribute tonic_spelling.
6 7 8 |
# File 'lib/head_music/rudiment/tonal_context.rb', line 6 def tonic_spelling @tonic_spelling end |
Instance Method Details
#key_signature ⇒ Object
32 33 34 |
# File 'lib/head_music/rudiment/tonal_context.rb', line 32 def key_signature raise NotImplementedError, "Subclasses must implement #key_signature" end |
#pitch_classes ⇒ Object
24 25 26 |
# File 'lib/head_music/rudiment/tonal_context.rb', line 24 def pitch_classes scale.pitch_classes end |
#pitches(octave = nil) ⇒ Object
20 21 22 |
# File 'lib/head_music/rudiment/tonal_context.rb', line 20 def pitches(octave = nil) scale.pitches(direction: :ascending, octaves: 1) end |
#scale ⇒ Object
16 17 18 |
# File 'lib/head_music/rudiment/tonal_context.rb', line 16 def scale raise NotImplementedError, "Subclasses must implement #scale" end |
#spellings ⇒ Object
28 29 30 |
# File 'lib/head_music/rudiment/tonal_context.rb', line 28 def spellings scale.spellings end |