An example:
(defparameter *volume* 0.05)(defun single-tone (frequency) "Sounds a tone of the specified frequency, indefinitely." (with-open-stream (stream (sb-simple-audio:open-audio :sample-rate 44100 :direction :output)) (let ((phase 0.0d0) (phase-increment (* 2 pi (/ frequency (sb-simple-audio:sample-rate stream)))) (amplitude (coerce (* *volume* (sb-simple-audio:max-amplitude stream)) 'double-float)) (offset (sb-simple-audio:offset stream))) (loop (setf phase (mod (+ phase phase-increment) (* 2 pi))) (write-byte (+ offset (round (* amplitude (sin phase)))) stream))))) (single-tone 600)
It could for instance be used for playing and recording music or in any other kind of audio signal processing.
Download ASDF package from http://v16.org/lisp/sb-simple-audio_latest.tar.gz
CLiki pages can be edited by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively