Class: Musa::Scales::ScaleKind
- Inherits:
-
Object
- Object
- Musa::Scales::ScaleKind
- Extended by:
- Forwardable
- Defined in:
- lib/musa-dsl/music/scales.rb
Direct Known Subclasses
ChromaticScaleKind, MajorScaleKind, MinorHarmonicScaleKind, MinorScaleKind
Instance Attribute Summary collapse
-
#tuning ⇒ Object
readonly
Returns the value of attribute tuning.
Class Method Summary collapse
-
.chromatic? ⇒ Boolean
abstract
Wether the scales is a full scale (with all the notes in the ScaleSystem), sorted and to be considered canonical.
- .grade_of_function(symbol) ⇒ Object
-
.grades ⇒ Integer
abstract
Number of grades inside of a octave of the scale.
- .grades_functions ⇒ Object
-
.id ⇒ Symbol
abstract
The id of the ScaleKind as a symbol.
-
.pitches ⇒ Array
abstract
The pitches array of the ScaleKind as [ { functions: [ <symbol>, …], pitch: <Number> }, … ].
Instance Method Summary collapse
- #==(other) ⇒ Object
- #[](root_pitch) ⇒ Object
- #absolut ⇒ Object
-
#chromatic? ⇒ Boolean
abstract
Wether the scales is a full scale (with all the notes in the ScaleSystem), sorted and to be considered canonical.
-
#grades ⇒ Integer
abstract
Number of grades inside of a octave of the scale.
-
#id ⇒ Symbol
abstract
The id of the ScaleKind as a symbol.
-
#initialize(tuning) ⇒ ScaleKind
constructor
A new instance of ScaleKind.
- #inspect ⇒ Object (also: #to_s)
-
#pitches ⇒ Array
abstract
The pitches array of the ScaleKind as [ { functions: [ <symbol>, …], pitch: <Number> }, … ].
Constructor Details
#initialize(tuning) ⇒ ScaleKind
Returns a new instance of ScaleKind.
185 186 187 188 |
# File 'lib/musa-dsl/music/scales.rb', line 185 def initialize(tuning) @tuning = tuning @scales = {} end |
Instance Attribute Details
#tuning ⇒ Object (readonly)
Returns the value of attribute tuning.
190 191 192 |
# File 'lib/musa-dsl/music/scales.rb', line 190 def tuning @tuning end |
Class Method Details
.chromatic? ⇒ Boolean
Subclass is expected to implement chromatic?. Only one of the subclasses should return true.
Returns wether the scales is a full scale (with all the notes in the ScaleSystem), sorted and to be considered canonical. I.e. a chromatic 12 semitones uprising serie in a 12 tone tempered ScaleSystem.
228 229 230 |
# File 'lib/musa-dsl/music/scales.rb', line 228 def self.chromatic? false end |
.grade_of_function(symbol) ⇒ Object
239 240 241 242 |
# File 'lib/musa-dsl/music/scales.rb', line 239 def self.grade_of_function(symbol) create_grade_functions_index unless @grade_names_index @grade_names_index[symbol] end |
.grades ⇒ Integer
Subclass is expected to implement grades when the ScaleKind is defining more pitches than notes by octave has the scale. This can happen when there are pitches defined on upper octaves (i.e., to define XII grade, as a octave + fifth)
Returns Number of grades inside of a octave of the scale.
235 236 237 |
# File 'lib/musa-dsl/music/scales.rb', line 235 def self.grades pitches.length end |
.grades_functions ⇒ Object
244 245 246 247 |
# File 'lib/musa-dsl/music/scales.rb', line 244 def self.grades_functions create_grade_functions_index unless @grade_names_index @grade_names_index.keys end |
.id ⇒ Symbol
Subclass is expected to implement id
Returns the id of the ScaleKind as a symbol.
214 215 216 |
# File 'lib/musa-dsl/music/scales.rb', line 214 def self.id raise 'Method not implemented. Should be implemented in subclass.' end |
.pitches ⇒ Array
Subclass is expected to implement pitches
Returns the pitches array of the ScaleKind as [ { functions: [ <symbol>, …], pitch: <Number> }, … ].
221 222 223 |
# File 'lib/musa-dsl/music/scales.rb', line 221 def self.pitches raise 'Method not implemented. Should be implemented in subclass.' end |
Instance Method Details
#==(other) ⇒ Object
201 202 203 |
# File 'lib/musa-dsl/music/scales.rb', line 201 def ==(other) self.class == other.class && @tuning == other.tuning end |
#[](root_pitch) ⇒ Object
192 193 194 195 |
# File 'lib/musa-dsl/music/scales.rb', line 192 def [](root_pitch) @scales[root_pitch] = Scale.new(self, root_pitch: root_pitch) unless @scales.key?(root_pitch) @scales[root_pitch] end |
#absolut ⇒ Object
197 198 199 |
# File 'lib/musa-dsl/music/scales.rb', line 197 def absolut self[0] end |
#chromatic? ⇒ Boolean
Subclass is expected to implement chromatic?. Only one of the subclasses should return true.
Returns wether the scales is a full scale (with all the notes in the ScaleSystem), sorted and to be considered canonical. I.e. a chromatic 12 semitones uprising serie in a 12 tone tempered ScaleSystem.
228 229 230 |
# File 'lib/musa-dsl/music/scales.rb', line 228 def self.chromatic? false end |
#grades ⇒ Integer
Subclass is expected to implement grades when the ScaleKind is defining more pitches than notes by octave has the scale. This can happen when there are pitches defined on upper octaves (i.e., to define XII grade, as a octave + fifth)
Returns Number of grades inside of a octave of the scale.
235 236 237 |
# File 'lib/musa-dsl/music/scales.rb', line 235 def self.grades pitches.length end |
#id ⇒ Symbol
Subclass is expected to implement id
Returns the id of the ScaleKind as a symbol.
214 215 216 |
# File 'lib/musa-dsl/music/scales.rb', line 214 def self.id raise 'Method not implemented. Should be implemented in subclass.' end |
#inspect ⇒ Object Also known as: to_s
205 206 207 |
# File 'lib/musa-dsl/music/scales.rb', line 205 def inspect "<#{self.class.name}: tuning = #{@tuning}>" end |
#pitches ⇒ Array
Subclass is expected to implement pitches
Returns the pitches array of the ScaleKind as [ { functions: [ <symbol>, …], pitch: <Number> }, … ].
221 222 223 |
# File 'lib/musa-dsl/music/scales.rb', line 221 def self.pitches raise 'Method not implemented. Should be implemented in subclass.' end |