# HG changeset patch # User Zachary Kanfer # Date 1597209247 14400 # Wed Aug 12 01:14:07 2020 -0400 # Node ID dd0d92b2fc4ccd72f512435fa30b7aab6bae8459 # Parent 5e63c016cb811edf558ca711620c7ae6e9c6202b make make-tone able to be big- or little-endian. diff --git a/zmusic.el b/zmusic.el --- a/zmusic.el +++ b/zmusic.el @@ -384,7 +384,7 @@ (write-bytes-to-file wave-data temp-file-name) (start-process-shell-command "zmusic" nil (format "%s %s" *zmusic/wave-playing-executable* temp-file-name)))) -(cl-defun make-tone (hz duration sample-rate &key (sample-size 2)) +(cl-defun make-tone (hz duration sample-rate &key (sample-size 2) (big-endian t)) "Make samples for a note at frequency HZ. The note should last DURATION seconds, sampled at SAMPLE-RATE. @@ -392,7 +392,7 @@ This returns a list of raw samples, as bytes. Each SAMPLE-SIZE bytes represent a single sample, reversed to be little-endian." (seq-mapcat - (lambda (val) (value-to-bytes val sample-size nil)) + (lambda (val) (value-to-bytes val sample-size big-endian)) (cl-loop for sample-number below (* duration sample-rate) collect (rescale (sin (rescale sample-number 0 sample-rate @@ -419,7 +419,8 @@ (make-tone (frequency semitones-up) duration sample-rate - :sample-size sample-size)) + :sample-size sample-size + :big-endian nil)) (defun frequency (semitones-up) "Return the frequency of a note SEMITONES-UP from concert A (440hz)."