EqualTemperament


EqualTemperament is the base class for a set of tuning classes. It implements equal temperament with any number of steps per octave.


Currently two subclasses are implemented to support different tuning schemes: TuningOffset and TuningRatios. A third class, CompositeTuning, allows one of a set of tunings to be chosen per note (to support just intonation schemes that require different interval ratios depending on harmonic context).


*new(stepsPerOctave = 12, calibratefreq = 440, calibratenote = 69, args)


stepsPerOctave: How many notes per octave.

calibratefreq: What frequency to calibrate to.

calibratenote: What note number should match the calibratefreq.

args: Not used in this class. May be used in subclasses.


calibrate(freq, noteindex)


Set the base frequency such that this.cps(noteindex) == freq. By default, 12ET calibrates to a=440. As such, a default EqualTemperament object behaves just like midicps. However, you can retune the EqualTemperament object to any pitch.


t = EqualTemperament();

t.cps(69);

440


t.cps(60);

261.6255653006


60.midicps

261.6255653006


t.calibrate(415, 69); // retune to a=415


t.cps(60);

246.76047636306


cps(noteindex)


Compute frequency in Hz for the given note index. Fractional indices are allowed (and should be allowed for all subclasses).


value(noteindex)


Delegates to .cps(noteindex), so that you can use a tuning object in place of a function that calculates cps.


v = Voicer(10, \default);

k = VoicerMIDISocket(0, v);

k.midiToFreq = EqualTemperament(12, 415, 69);


Now you are playing your keyboard at a = 415.


v.free;