Class: HeadMusic::Rudiment::Mode
- Inherits:
-
QualifiedDiatonicContext
- Object
- Base
- TonalContext
- DiatonicContext
- QualifiedDiatonicContext
- HeadMusic::Rudiment::Mode
- Defined in:
- lib/head_music/rudiment/mode.rb
Overview
Represents a musical mode (church modes)
Constant Summary collapse
- MODES =
%i[ionian dorian phrygian lydian mixolydian aeolian locrian].freeze
- RELATIVE_MAJOR_SEMITONES_BELOW_TONIC =
Semitones from a mode’s tonic down to its relative major tonic. Ionian is omitted because its own tonic spelling is the relative major.
{ dorian: -2, phrygian: -4, lydian: -5, mixolydian: -7, aeolian: -9, locrian: -11 }.freeze
- PARALLEL_QUALITIES =
The major or minor quality of each mode’s parallel key.
{ ionian: :major, dorian: :minor, phrygian: :minor, lydian: :major, mixolydian: :major, aeolian: :minor, locrian: :minor }.freeze
Instance Attribute Summary collapse
-
#alias_name_keys ⇒ Object
included
from Named
readonly
Returns the value of attribute alias_name_keys.
-
#name_key ⇒ Object
included
from Named
readonly
Returns the value of attribute name_key.
Class Method Summary collapse
Instance Method Summary collapse
-
#parallel ⇒ Object
-
#relative ⇒ Object
-
#relative_major ⇒ Object
-
#relative_major_tonic_spelling ⇒ Object
private
Constructor Details
This class inherits a constructor from HeadMusic::Rudiment::QualifiedDiatonicContext
Instance Attribute Details
#alias_name_keys ⇒ Object (readonly) Originally defined in module Named
Returns the value of attribute alias_name_keys.
#name_key ⇒ Object (readonly) Originally defined in module Named
Returns the value of attribute name_key.
Class Method Details
.default_qualifier ⇒ Object
8 9 10 |
# File 'lib/head_music/rudiment/mode.rb', line 8 def self.default_qualifier :ionian end |
.invalid_qualifier_message ⇒ Object
16 17 18 |
# File 'lib/head_music/rudiment/mode.rb', line 16 def self. "Mode must be one of: #{MODES.join(", ")}" end |
.valid_qualifiers ⇒ Object
12 13 14 |
# File 'lib/head_music/rudiment/mode.rb', line 12 def self.valid_qualifiers MODES end |
Instance Method Details
#parallel ⇒ Object
43 44 45 46 47 48 |
# File 'lib/head_music/rudiment/mode.rb', line 43 def parallel quality = PARALLEL_QUALITIES[mode_name] return unless quality HeadMusic::Rudiment::Key.get("#{tonic_spelling} #{quality}") end |
#relative ⇒ Object
39 40 41 |
# File 'lib/head_music/rudiment/mode.rb', line 39 def relative relative_major end |
#relative_major ⇒ Object
35 36 37 |
# File 'lib/head_music/rudiment/mode.rb', line 35 def relative_major HeadMusic::Rudiment::Key.get("#{relative_major_tonic_spelling} major") end |
#relative_major_tonic_spelling ⇒ Object (private)
52 53 54 55 56 57 58 59 |
# File 'lib/head_music/rudiment/mode.rb', line 52 def relative_major_tonic_spelling return tonic_spelling if mode_name == :ionian offset = RELATIVE_MAJOR_SEMITONES_BELOW_TONIC[mode_name] relative_pitch = tonic_pitch + offset if offset # An unrecognized mode leaves relative_pitch nil, raising NoMethodError (preserved behavior). relative_pitch.spelling end |