Class: HeadMusic::Rudiment::Tuning
- Defined in:
- lib/head_music/rudiment/tuning.rb
Overview
A tuning has a reference pitch and frequency and provides frequencies for all pitches The base class assumes equal temperament tuning. By default, A4 = 440.0 Hz
Direct Known Subclasses
Defined Under Namespace
Classes: JustIntonation, Meantone, Pythagorean
Instance Attribute Summary collapse
-
#reference_pitch ⇒ Object
Returns the value of attribute reference_pitch.
Class Method Summary collapse
Instance Method Summary collapse
- #frequency_for(pitch) ⇒ Object
-
#initialize(reference_pitch: :a440, tonal_center: nil) ⇒ Tuning
constructor
A new instance of Tuning.
Constructor Details
#initialize(reference_pitch: :a440, tonal_center: nil) ⇒ Tuning
Returns a new instance of Tuning.
26 27 28 29 |
# File 'lib/head_music/rudiment/tuning.rb', line 26 def initialize(reference_pitch: :a440, tonal_center: nil) @reference_pitch = HeadMusic::Rudiment::ReferencePitch.get(reference_pitch) @tonal_center = tonal_center end |
Instance Attribute Details
#reference_pitch ⇒ Object
Returns the value of attribute reference_pitch.
7 8 9 |
# File 'lib/head_music/rudiment/tuning.rb', line 7 def reference_pitch @reference_pitch end |
Class Method Details
.get(tuning_type = :equal_temperament, **options) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/head_music/rudiment/tuning.rb', line 11 def self.get(tuning_type = :equal_temperament, **) case tuning_type.to_s.downcase when "just_intonation", "just", "ji" HeadMusic::Rudiment::Tuning::JustIntonation.new(**) when "pythagorean", "pythag" HeadMusic::Rudiment::Tuning::Pythagorean.new(**) when "meantone", "quarter_comma_meantone", "1/4_comma" HeadMusic::Rudiment::Tuning::Meantone.new(**) when "equal_temperament", "equal", "et", "12tet" new(**) else new(**) end end |