Sha256: f6b8c179bf8eb9c41131bce3e3f9923653b0428b0332c7750ef4c17aa8ea09d8
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
# frozen_string_literal: true # 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 class HeadMusic::Tuning REFERENCE_PITCH_NAME = 'A4' REFERENCE_FREQUENCY = 440.0 attr_reader :reference_pitch, :reference_frequency def initialize(reference_pitch: nil, reference_frequency: nil) @reference_pitch = reference_pitch || HeadMusic::Pitch.get(REFERENCE_PITCH_NAME) @reference_frequency = reference_frequency || REFERENCE_FREQUENCY end def frequency_for(pitch) pitch = HeadMusic::Pitch.get(pitch) unless pitch.is_a?(HeadMusic::Pitch) reference_frequency * (2**(1.0 / 12))**(pitch - reference_pitch).semitones end end # TODO: other tunings # Create website that hosts videos on theory and history, handy charts, etc. # one of those charts can be a frequency table in various tunings # maybe show pythagorean commas and such. or cents sharp or flat relative to either equal temperment or just intonation
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
head_music-0.22.0 | lib/head_music/tuning.rb |