Class: Musa::Scales::ScaleSystemTuning

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

Overview

Scale system with specific A frequency tuning.

ScaleSystemTuning combines a ScaleSystem with a specific reference A frequency, providing access to scale kinds (major, minor, chromatic, etc.) tuned to that frequency.

Usage

Tunings are created via Musa::Scales::ScaleSystem.[]:

tuning = Scales[:et12][440.0]     # Standard pitch
baroque = Scales[:et12][415.0]    # Baroque pitch

Accessing Scales

By symbol:

tuning[:major][60]     # C major scale

By method name:

tuning.major[60]       # C major scale
tuning.minor[69]       # A minor scale

Chromatic scale:

tuning.chromatic[60]   # C chromatic scale

Examples:

Standard usage

tuning = Scales::Scales.default_system.default_tuning
c_major = tuning.major[60]
a_minor = tuning.minor[69]

Historical pitch

baroque = Scales[:et12][415.0]
scale = baroque.major[60]  # C major at A=415Hz

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scale_system, a_frequency) ⇒ ScaleSystemTuning

Returns a new instance of ScaleSystemTuning.



430
431
432
433
434
435
436
437
438
439
440
441
442
# File 'lib/musa-dsl/music/scales.rb', line 430

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.



448
449
450
# File 'lib/musa-dsl/music/scales.rb', line 448

def a_frequency
  @a_frequency
end

#scale_systemObject (readonly)

Returns the value of attribute scale_system.



448
449
450
# File 'lib/musa-dsl/music/scales.rb', line 448

def scale_system
  @scale_system
end

Instance Method Details

#==(other) ⇒ Object



462
463
464
465
466
# File 'lib/musa-dsl/music/scales.rb', line 462

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

#[](scale_kind_class_id) ⇒ Object



450
451
452
# File 'lib/musa-dsl/music/scales.rb', line 450

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

#chromaticObject



454
455
456
# File 'lib/musa-dsl/music/scales.rb', line 454

def chromatic
  @chromatic_scale_kind
end

#frequency_of_pitch(pitch, root) ⇒ Object



458
459
460
# File 'lib/musa-dsl/music/scales.rb', line 458

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

#inspectObject Also known as: to_s



468
469
470
# File 'lib/musa-dsl/music/scales.rb', line 468

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