keydict.lsp Version 0.01 25 May 2005 Author Steven Jones Contact jones57@swbell.net include the word "nyquist" in subject line The contents of this file are released under the terms of the GNU General Public License. See the file LICENSE.txt Provides functions to convert between string and numeric representation of MIDI step values.
function
(keydict:n->str n) Map integer to string representation of MIDI key number n - Integer. NOTE flonums are truncated return - String
function
(keydict:str->n str) Maps string representation of MIDI note to integer MIDI step value. str - String. The string representation of a MIDI note, the comparison test is NOT case sensitive. return - Integer. The MIDI step number associated with str. If str does not represent a valid MIDI step the result is NIL.
;; keydict.lsp ;; Version 0.01 25 May 2005 ;; Author Steven Jones ;; ;; Contact jones57@swbell.net include the word "nyquist" in subject line ;; ;; The contents of this file are released under the terms of the GNU General ;; Public License. See the file LICENSE.txt ;; ;; Provides functions to convert between string and numeric representation of ;; MIDI step values. (provide 'keydict) (current-file "keydict") ;; Array used to map integer to string representation. ;; (setf keydict:*n->str* (vector "CX" "CSX" "DX" "DSX" "EX" "FX" "FSX" "GX" "GSX" "AX" "ASX" "BX" "C0" "CS0" "D0" "DS0" "E0" "F0" "FS0" "G0" "GS0" "A0" "AS0" "B0" "C1" "CS1" "D1" "DS1" "E1" "F1" "FS1" "G1" "GS1" "A1" "AS1" "B1" "C2" "CS2" "D2" "DS2" "E2" "F2" "FS2" "G2" "GS2" "A2" "AS2" "B2" "C3" "CS3" "D3" "DS3" "E3" "F3" "FS3" "G3" "GS3" "A3" "AS3" "B3" "C4" "CS4" "D4" "DS4" "E4" "F4" "FS4" "G4" "GS4" "A4" "AS4" "B4" "C5" "CS5" "D5" "DS5" "E5" "F5" "FS5" "G5" "GS5" "A5" "AS5" "B5" "C6" "CS6" "D6" "DS6" "E6" "F6" "FS6" "G6" "GS6" "A6" "AS6" "B6" "C7" "CS7" "D7" "DS7" "E7" "F7" "FS7" "G7" "GS7" "A7" "AS7" "B7" ;"C8" "CS8" "D8" "DS8" "E8" "F8" "FS8" "G8" "GS8" "A8" "AS8" "B8" ;"C9" "CS9" "D9" "DS9" "E9" "F9" "FS9" "G9" )) ;; Assoc list used to map string representation to MIDI step number. ;; (setf keydict:*str->n* (list (list "CX" 000) (list "CSX" 001) (list "DX" 002) (list "DSX" 003) (list "EX" 004) (list "FX" 005) (list "FSX" 006) (list "GX" 007) (list "GSX" 008) (list "AX" 009) (list "ASX" 010) (list "BX" 011) (list "C0" C0) (list "CS0" CS0) (list "D0" D0) (list "DS0" DS0) (list "E0" E0) (list "F0" F0) (list "FS0" FS0) (list "G0" G0) (list "GS0" GS0) (list "A0" A0) (list "AS0" AS0) (list "B0" B0) (list "C1" C1) (list "CS1" CS1) (list "D1" D1) (list "DS1" DS1) (list "E1" E1) (list "F1" F1) (list "FS1" FS1) (list "G1" G1) (list "GS1" GS1) (list "A1" A1) (list "AS1" AS1) (list "B1" B1) (list "C2" C2) (list "CS2" CS2) (list "D2" D2) (list "DS2" DS2) (list "E2" E2) (list "F2" F2) (list "FS2" FS2) (list "G2" G2) (list "GS2" GS2) (list "A2" A2) (list "AS2" AS2) (list "B2" B2) (list "C3" C3) (list "CS3" CS3) (list "D3" D3) (list "DS3" DS3) (list "E3" E3) (list "F3" F3) (list "FS3" FS3) (list "G3" G3) (list "GS3" GS3) (list "A3" A3) (list "AS3" AS3) (list "B3" B3) (list "C4" C4) (list "CS4" CS4) (list "D4" D4) (list "DS4" DS4) (list "E4" E4) (list "F4" F4) (list "FS4" FS4) (list "G4" G4) (list "GS4" GS4) (list "A4" A4) (list "AS4" AS4) (list "B4" B4) (list "C5" C5) (list "CS5" CS5) (list "D5" D5) (list "DS5" DS5) (list "E5" E5) (list "F5" F5) (list "FS5" FS5) (list "G5" G5) (list "GS5" GS5) (list "A5" A5) (list "AS5" AS5) (list "B5" B5) (list "C6" C6) (list "CS6" CS6) (list "D6" D6) (list "DS6" DS6) (list "E6" E6) (list "F6" F6) (list "FS6" FS6) (list "G6" G6) (list "GS6" GS6) (list "A6" A6) (list "AS6" AS6) (list "B6" B6) (list "C7" C7) (list "CS7" CS7) (list "D7" D7) (list "DS7" DS7) (list "E7" E7) (list "F7" F7) (list "FS7" FS7) (list "G7" G7) (list "GS7" GS7) (list "A7" A7) (list "AS7" AS7) (list "B7" B7) ;(list "C8" C8) (list "CS8" CS8) (list "D8" D8) (list "DS8" DS8) (list "E8" E8) (list "F8" F8) ;(list "FS8" FS8) (list "G8" G8) (list "GS8" GS8) (list "A8" A8) (list "AS8" AS8) (list "B8" B8) ;(list "C9" C9) (list "CS9" CS9) (list "D9" D9) (list "DS9" DS9) (list "E9" E9) (list "F9" F9) ;(list "FS9" FS9) (list "G9" G9) (list "DFX" 001)(list "EFX" 003)(list "GFX" 006)(list "AFX" 008)(list "BFX" 010) (list "DF0" CS0)(list "EF0" DS0)(list "GF0" FS0)(list "AF0" GS0)(list "BF0" AS0) (list "DF1" CS1)(list "EF1" DS1)(list "GF1" FS1)(list "AF1" GS1)(list "BF1" AS1) (list "DF2" CS2)(list "EF2" DS2)(list "GF2" FS2)(list "AF2" GS2)(list "BF2" AS2) (list "DF3" CS3)(list "EF3" DS3)(list "GF3" FS3)(list "AF3" GS3)(list "BF3" AS3) (list "DF4" CS4)(list "EF4" DS4)(list "GF4" FS4)(list "AF4" GS4)(list "BF4" AS4) (list "DF5" CS5)(list "EF5" DS5)(list "GF5" FS5)(list "AF5" GS5)(list "BF5" AS5) (list "DF6" CS6)(list "EF6" DS6)(list "GF6" FS6)(list "AF6" GS6)(list "BF6" AS6) (list "DF7" CS7)(list "EF7" DS7)(list "GF7" FS7)(list "AF7" GS7)(list "BF7" AS7) )) ;; @doc function keydict:n->str ;; (keydict:n->str n) ;; Map integer to string representation of MIDI key number ;; ;; n - Integer. NOTE flonums are truncated ;; return - String ;; (defun keydict:n->str (n) (aref keydict:*n->str* (truncate n))) ;; @doc function keydict:str->n ;; (keydict:str->n str) ;; Maps string representation of MIDI note to integer MIDI step value. ;; ;; str - String. The string representation of a MIDI note, the ;; comparison test is NOT case sensitive. ;; return - Integer. The MIDI step number associated with str. If str ;; does not represent a valid MIDI step the result is NIL. ;; (defun keydict:str->n (str) (let (pair) (setf pair (assoc (string-upcase str) keydict:*str->n* :test #'string=)) (second pair)))