class HeadMusic::ScaleType
A ScaleType
represents a particular scale pattern, such as major, lydian, or minor pentatonic.
Constants
- CHROMATIC
- H
- HARMONIC_MINOR
Tonal
- I
Modal
- II
- III
- IV
- MELODIC_MINOR_ASCENDING
- MINOR_PENTATONIC
- MODE_NAMES
- SCALE_TYPES
- V
- VI
- VII
- W
Attributes
ascending_intervals[R]
descending_intervals[R]
intervals[R]
name[R]
parent_name[R]
Public Class Methods
_chromatic_scales()
click to toggle source
# File lib/head_music/scale_type.rb, line 52 def self._chromatic_scales { chromatic: { ascending: CHROMATIC } } end
_exotic_scales()
click to toggle source
# File lib/head_music/scale_type.rb, line 66 def self._exotic_scales # 'octatonic' is also called the 'whole-half diminished scale' { octatonic: { ascending: [W, H, W, H, W, H, W, H] }, whole_tone: { ascending: [W, W, W, W, W, W] }, } end
_minor_scales()
click to toggle source
# File lib/head_music/scale_type.rb, line 45 def self._minor_scales { harmonic_minor: { ascending: HARMONIC_MINOR }, melodic_minor: { ascending: MELODIC_MINOR_ASCENDING, descending: VI.reverse }, } end
_modes()
click to toggle source
# File lib/head_music/scale_type.rb, line 35 def self._modes {}.tap do |modes| MODE_NAMES.each do |roman_numeral, aliases| intervals = { ascending: const_get(roman_numeral.upcase) } modes[roman_numeral] = intervals aliases.each { |name| modes[name] = intervals } end end end
_pentatonic_scales()
click to toggle source
# File lib/head_music/scale_type.rb, line 56 def self._pentatonic_scales { minor_pentatonic: { ascending: MINOR_PENTATONIC, parent_name: :minor }, major_pentatonic: { ascending: MINOR_PENTATONIC.rotate, parent_name: :major }, egyptian_pentatonic: { ascending: MINOR_PENTATONIC.rotate(2), parent_name: :minor }, blues_minor_pentatonic: { ascending: MINOR_PENTATONIC.rotate(3), parent_name: :minor }, blues_major_pentatonic: { ascending: MINOR_PENTATONIC.rotate(4), parent_name: :major }, } end
default()
click to toggle source
# File lib/head_music/scale_type.rb, line 97 def self.default get(:major) end
get(name)
click to toggle source
# File lib/head_music/scale_type.rb, line 90 def self.get(name) @scale_types ||= {} identifier = HeadMusic::Utilities::HashKey.for(name) attributes = SCALE_TYPES[identifier] @scale_types[identifier] ||= new(identifier, attributes) end
new(name, attributes)
click to toggle source
# File lib/head_music/scale_type.rb, line 106 def initialize(name, attributes) @name = name @ascending_intervals = attributes[:ascending] @descending_intervals = attributes[:descending] || ascending_intervals.reverse @parent_name = attributes[:parent_name] end
Public Instance Methods
==(other)
click to toggle source
# File lib/head_music/scale_type.rb, line 113 def ==(other) state == other.state end
chromatic?()
click to toggle source
# File lib/head_music/scale_type.rb, line 137 def chromatic? intervals.length == 12 end
diatonic?()
click to toggle source
# File lib/head_music/scale_type.rb, line 125 def diatonic? intervals.length == 7 end
parent()
click to toggle source
# File lib/head_music/scale_type.rb, line 121 def parent @parent ||= self.class.get(parent_name) if parent_name end
pentatonic?()
click to toggle source
# File lib/head_music/scale_type.rb, line 133 def pentatonic? intervals.length == 5 end
state()
click to toggle source
# File lib/head_music/scale_type.rb, line 117 def state [ascending_intervals, descending_intervals] end
whole_tone?()
click to toggle source
# File lib/head_music/scale_type.rb, line 129 def whole_tone? intervals.length == 6 && intervals.uniq == [2] end