tuning

[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 cent values in list start with 0 and are in increasing order they specify the cent difference 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 list does not begin with 0 then the cents values describe the distances between adjacent steps. 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.
`: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 :cents (loop repeat 24 collect 50))
    ⇒ #<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:

- `mode``` [Class]