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.



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

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.



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

def a_frequency
  @a_frequency
end

#scale_systemObject (readonly)

Returns the value of attribute scale_system.



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

def scale_system
  @scale_system
end

Instance Method Details

#==(other) ⇒ Object



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

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

#[](scale_kind_class_id) ⇒ Object



159
160
161
# File 'lib/musa-dsl/music/scales.rb', line 159

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

#chromaticObject



163
164
165
# File 'lib/musa-dsl/music/scales.rb', line 163

def chromatic
  @chromatic_scale_kind
end

#frequency_of_pitch(pitch, root) ⇒ Object



167
168
169
# File 'lib/musa-dsl/music/scales.rb', line 167

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

#inspectObject Also known as: to_s



177
178
179
# File 'lib/musa-dsl/music/scales.rb', line 177

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