# HG changeset patch # User Zachary Kanfer # Date 1606810512 18000 # Tue Dec 01 03:15:12 2020 -0500 # Node ID 7c7280ba3a0330d019ab65aee611ed3dd23d1002 # Parent 01c492eb45103948ef4b7971f450345556fbd6e1 add a variable for the root frequency. diff --git a/zmusic.el b/zmusic.el --- a/zmusic.el +++ b/zmusic.el @@ -335,10 +335,11 @@ :sample-size sample-size :big-endian nil)) -(defun frequency (semitones-up) - "Return the frequency of a note SEMITONES-UP from concert A (440hz)." - (* 440 (expt (expt 2 (/ 12.0)) - semitones-up))) +(cl-defun frequency (semitones-up &optional (root-frequency *zmusic//root-frequency*)) + "Return the frequency of a note SEMITONES-UP from ROOT-FREQUENCY." + (* root-frequency + (expt (expt 2 (/ 12.0)) + semitones-up))) (defun bytes-to-number (&rest bytes) "Convert a sequence of BYTES to a single number." @@ -368,6 +369,7 @@ (define-key zmusic-mode-map (kbd "X") #'zmusic/export)) (defvar *zmusic//bpm* 240 "The beats per minute.") +(defvar *zmusic//root-frequency* 440 "The frequency of the root note of the scale.") (defvar *zmusic//empty-note* ?- "The character printed when there is no note for a cell.") (defvar *zmusic//note* ?* "The character printed when there is a note for a cell.")