[Class]
tuning

A scale definition with Hertz frequencies, key numbers and (optionally) note names assigned to each scale degree.

tuning supports the following slot initializations:

:name {string | symbol}
An optional name for the tuning.
:lowest number
The lowest Hertz value defined in the scale. Defaults to 8.175, which is C-1 in the standard chromatic scale.
:cents list
One octave of the tuning specified as a list of cent values. Fewer or more than 12 degrees may be specified and an "octave" does not have to equal 1200 cents. If the first value in list is 0 then the list is assumed to be specifing degrees, i.e. the cent distance from the lowest degree to each degree above it. In this case the last value in list determines the octave width of the scale. If the first value is not 0 then list is assumed to specify steps, i.e. the cent distances between adjacent degrees. In this case the octave width is set to the sum of the cent steps.

To define a tuning with note names specify each step as a list: (cent {note}*) where cent is the cent value followed by one or more note declarations. Each note declaration may consist of symbol note or a list (note [:accidental s]) where the value of :accidental is the "subsymbol" of note that represents the accidental. For example, the 8th step in the definition of the standard chromatic scale is:

(100 (af :accidental f) (gs :accidental s))

:ratios list
Exactly like cents except that the tuning values are specified as ratios (direct frequency scalers) rather than as cent values. A list whose first ratio is 1 defines degrees, otherwise the list is taken to be ratio step differences between degrees.
:steps integer
Short-hand method for specifying an equal-division tuning with integer divisions per octave.
:octave number
The width of the equal-division octave if :steps are specified, otherwise ignored. Defaults to 2.
:octaves {number | list}
The number of octaves defined in the scale. Defaults to 10. The value can be a number or a list of two values (start end) where start is the first octave number and end is the last octave number. Specify false if the tuning has no octaves.
:keynum-offset integer
A integer offset to add to all keynums values returned by keynum. Defaults to 0.
:default-octave integer
The default octave for notes without octave numbers. Defaults to the 4th octave.

Examples:

Example 1. A quarter-tone scale with no note names.

(new tuning :name 'qt :steps 24)
 #<tuning: "qt">
(hertz 138 :in #&qt)
 440.0

Example 1. A Slendro with note names and no octaves.

(new tuning :name 'slendro 
     :lowest 220.0
     :octaves #f
     :cents '((0    nem0)
              (218  barang0)
              (473  gulu0)
              (721  dada0)
              (954  lima0)
              (1213 nem1)
              (1458 barang1)
              (1695 gulu1)
              (1929 dada1)
              (2174 lima1)
              (2441 nem2)))

See the file scales.cm for examples of tuning and mode definitions.

See Also: