mode

[Class]
  `mode`

Defines a transposable subset of a tuning in which the sequential keynums in the mode map to non-sequential keynums, notes or hertz values in the tuning. Every mode maps to exactly one tuning; if no tuning is specified when the mode is created then it defaults to the standard chromatic scale. The number of steps per octave as well as the mode's octave size are determined from its interval specification when the mode is created. A mode can be placed on any degree in the mode's tuning using the `transpose` function. Modes can be used in place of tunings when generating frequency information using the `note`, `keynum` and `hertz` functions.

`mode` supports the following slot initializations:

`:name` {string | symbol}
  An optional name for the mode.
`:steps` intervals
  One octave of the mode specified as a list of intervals steps between mode degrees. Each entry in the list is an interval measurement (in integer semitones or in typed intervals) of the distance between ajacent mode degrees in the mode's tuning. The size of the mode's octave is set to the sum of all the steps.
`:degrees` {notes | keynums}
  One octave of the mode specified as a list of notes, note classes (note names without octaves) or keynums. Intervals between note entries are always interpreted in ascending order. The last entry in the list determines the octave note of the mode, this note does not have to be the same as the first note in he list. The first note in the list defines the initial transposition offset (tonic) of the mode
`:notes` notes
  Forces the mode to use typed intervals to preserve scale spelling in the standard chromatic scale when the mode is transposed. Typed intervals are slightly less efficient than regular (semitonal) intervals.
`:lowest` note
  Sets the lowest note of the mode. Defaults to the first note in the a :degree specification, or to the lowest note in the mode's tuning if :steps are provided. If note is a note class (a note name without an octave) then the mode is based on the lowest octave in the mode's tuning. Otherwise, the octave information of the note is preserved and that note becomes keynum 0 in the mode.
`:tuning` tuning
  Specifies the tuning system of the mode. Defaults to the standard chromatic scale.

#### Examples:

Example 1. Defining and transposing a mode.

    (define major (new mode :degrees '(d e fs g a b c d)))

    (note 35 :in major)
    ⇒ d4
    (note 36 :in major)
    ⇒ e4
    (transpose major 'af)
    ⇒ #<mode: (on af)>
    (note 35 :in major)
    ⇒ af4

Example 2. Modes smaller and larger than one octave.

    ;; a five note mode whose "octave" is a perfect 5th
    (define mini (new mode :steps '(2 1 2 1 1)))

    (loop for k from 35 repeat 14 collect (note k :in mini))
    ⇒ (cs3 ef3 e3 fs3 g3 af3 bf3 b3 cs4 d4 ef4 f4 fs4 af4)
    ;; a 12 note mode that spans two octaves
    (define maxi (new mode :steps '(2 1 2 3 2 3 3 2 1 2 2 1)))

    (loop for k from 24 repeat 12 collect (note k :in maxi))
    ⇒ (c3 d3 ef3 f3 af3 bf3 cs4 e4 fs4 g4 a4 b4)

#### See also:

- `tuning` [Class]
- `note` [Function]
- `keynum` [Function]
- `hertz` [Function]
- `transpose` [Function]