keynum freq &key :in :from :to [Function]

Returns the key number of freq, which can be a note, keynum, Hertz value or list of the same. If :in is specified it sets the scale for resolving a note or keynum freq. :in defaults to the global variable *scale*, which is initially set to the standard chromatic scale. If :from or :to is specified then keynum converts freq from or to its equivalent position in the specified scales. See the section Converting Notes and Keynums Between Scales for more information.

For equal tempered scales keynum may return a floating point number with a non-zero fractional part. This fractional value represents a "percentage" distance above the integer keynum. In the standard chromatic scale the fractional value multiplied by 100 is equivalent to cents above the Hertz value of the integer keynum.

The read macro #k provides a shorthand for converting notes to keynums.

Example:

? (keynum 'c4)
60

? (keynum 440 :hertz)
69.0

? (keynum 452.893 :hz)
69.5

? (keynum '(cs5 ds fs gs as cs6))
(73 75 78 80 82 85)

? #kc4
60

See Also:


Common Music Dictionary  |  © 2002 Heinrich Taube Last Modified: 20 Sep 2002