;;; ;;; steady-sound.lisp ;;; :generate a new sound-data which contains a constant spectrum of the ;;; specified frame. ;;; ;;; This is a common-lisp-music source code ;;; ;;; by Takuya Fujishima, fujishim@ccrma ;;; on Feb 26, 1998 --- bug remains, somewhere, wrong # of subscript to array ;;; solve it! ;;; ;;; ;;; USAGE ;;; ;;; (steady-sound sound-obj [:new-name new-sound-name-string] [:frame-index ;;; #frame] ) ;;; ;;; frame-index = 0 (default) the first frame is referred to. ;;; otherwise refer to the frame specified. (defun steady-sound (sound &key (new-name nil) (frame-index 0)) " steady-sound &key [:new-name new-sound-name-string] [:frame-index frame-to-use ] " (let ((name (if new-name (string new-name) (concatenate 'string (ats-sound-name sound) "-steady")))) (pushnew name *sounds* :test #'equal) (set (read-from-string name) (make-ats-sound :name name :type (ats-sound-type sound) :frame-rate (ats-sound-frame-rate sound) :frame-size (ats-sound-frame-size sound) :partials (ats-sound-partials sound) :frames (ats-sound-frames sound) :stoc-type (ats-sound-stoc-type sound) :ncoefs (ats-sound-ncoefs sound) :optimized (ats-sound-optimized sound) :ampmax (ats-sound-ampmax sound) :frqmax (ats-sound-frqmax sound) :beg (ats-sound-beg sound) :dur (ats-sound-dur sound) :time (copy-ats-data-array (ats-sound-time sound)) :frq-av (copy-seq (ats-sound-frq-av sound)) :amp-av (copy-seq (ats-sound-amp-av sound)) :frq (steady-sound-make-matrix (ats-sound-frq sound) frame-index) :amp (steady-sound-make-matrix (ats-sound-amp sound) frame-index) :pha nil :coeff (if (ats-sound-coeff sound)(copy-ats-data-array (ats-sound-coeff sound)) nil) :gain (if (ats-sound-gain sound)(copy-seq (ats-sound-gain sound)) nil))) nil)) ;;; Supporting function : ;;; Note frq-matrix and amp-matrix are like ;;; #( // partial-0 #( frame-0 frame-1 ... frame-N-1) ;;; // partial-1 #( frame-0 frame-1 ... frame-N-1) ;;; : ;;; // partial-M-1 #( frame-0 frame-1 ... frame-N-1) ;;; ) ;;; (ats-sound-partial sound) may sometimes be wrong. (defun steady-sound-make-matrix (matrix frame-index) (let* ((num-partial (array-dimension matrix 0)) (new-matrix (make-array num-partial :element-type 'array))) (loop for partial-idx from 0 below num-partial do (setf (aref new-matrix partial-idx) (make-array (array-dimension (aref matrix partial-idx) 0) ;; same # of frame :element-type 'float :initial-element (aref (aref matrix partial-idx) frame-index)))) new-matrix)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;