Class: Musa::Scales::ScaleSystemTuning

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/musa-dsl/music/scales.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scale_system, a_frequency) ⇒ ScaleSystemTuning

Returns a new instance of ScaleSystemTuning.



137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/musa-dsl/music/scales.rb', line 137

def initialize(scale_system, a_frequency)
  @scale_system = scale_system
  @a_frequency = a_frequency
  @scale_kinds = {}

  @chromatic_scale_kind = self[@scale_system.chromatic_class.id]

  @scale_system.scale_kind_classes.each_key do |name|
    define_singleton_method name do
      self[name]
    end
  end
end

Instance Attribute Details

#a_frequencyObject (readonly)

Returns the value of attribute a_frequency.



155
156
157
# File 'lib/musa-dsl/music/scales.rb', line 155

def a_frequency
  @a_frequency
end

#scale_systemObject (readonly)

Returns the value of attribute scale_system.



155
156
157
# File 'lib/musa-dsl/music/scales.rb', line 155

def scale_system
  @scale_system
end

Instance Method Details

#==(other) ⇒ Object



169
170
171
172
173
# File 'lib/musa-dsl/music/scales.rb', line 169

def ==(other)
  self.class == other.class &&
      @scale_system == other.scale_system &&
      @a_frequency == other.a_frequency
end

#[](scale_kind_class_id) ⇒ Object



157
158
159
# File 'lib/musa-dsl/music/scales.rb', line 157

def [](scale_kind_class_id)
  @scale_kinds[scale_kind_class_id] ||= @scale_system.scale_kind_class(scale_kind_class_id).new self
end

#chromaticObject



161
162
163
# File 'lib/musa-dsl/music/scales.rb', line 161

def chromatic
  @chromatic_scale_kind
end

#frequency_of_pitch(pitch, root) ⇒ Object



165
166
167
# File 'lib/musa-dsl/music/scales.rb', line 165

def frequency_of_pitch(pitch, root)
  @scale_system.frequency_of_pitch(pitch, root, @a_frequency)
end

#inspectObject Also known as: to_s



175
176
177
# File 'lib/musa-dsl/music/scales.rb', line 175

def inspect
  "<ScaleSystemTuning: scale_system = #{@scale_system} a_frequency = #{@a_frequency}>"
end