Main Page       Index


tremolo.lsp


 tremolo.lsp
 Version 1.01   29 March 05
 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

 An amplitude modulation effect.


function

tremolo

 (tremolo asig dur [:tfrq][:tdelay][:tattack][:tdecay][:trem][:ttab][:tphase])
 Tremolo effect

 asig     - Sound. Source signal.
 dur      - Flonum. Duration of asig in seconds.
 :tfrq    - Flonum. Tremolo frequency in HZ., default 3
 :tdelay  - Flonum. Effect delay time in seconds, default 0
 :tattack - Flonum. Effect attack time, default 0.25 X delay
 :tdecay  - Flonum. Effect decay time, default 0 sec
 :trem    - Flonum. Tremolo depth, 0 <= trem <= 1, default 0.5
 :ttab    - Tab. Tremolo wave table, default *sine-table*
 :tphase  - Flonum | symbol. Phase. See phase in utilities.lsp. 
            Default 90 Degrees
 return   - Sound or sound vector.


View the Sourcecode :



;; tremolo.lsp
;; Version 1.01   29 March 05
;; 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
;;
;; An amplitude modulation effect.
;;

(require 'dlfo)
(provide 'tremolo)
(current-file "tremolo")


;; Convert signed modulation signal for tremolo use.
;; csig   - Sound. The tremolo control signal, peak amplitude should be -+1
;; trem   - flonum. Tremolo depth 0 <= trem <= 1
;; return - Sound. Assuming peak amplitude of csig is -+1 the result is a 
;;          sound with amplitude in interval (0,1) with the same sample rate 
;;          of csig.
;;

(defun tremolo:ctrl (csig trem)
  (setf trem (clamp trem 0 1))
  (sum (scale (* 0.5 trem)(sum csig 1))(1- trem)))


;; Amplitude modulate asig by csig.
;; asig   - Sound. Carrier signal
;; csig   - Sound. Modulation signal  -1 <= csig <= 1
;; trem   - Flonum. Tremolo depth. 0 <= trem <= 1
;; return - Sound. 
;;

(defun tremolo:efx (asig csig trem)
  (mult asig (tremolo:ctrl csig trem)))


;; @doc function tremolo
;; (tremolo asig dur [:tfrq][:tdelay][:tattack][:tdecay][:trem][:ttab][:tphase])
;; Tremolo effect
;;
;; asig     - Sound. Source signal.
;; dur      - Flonum. Duration of asig in seconds.
;; :tfrq    - Flonum. Tremolo frequency in HZ., default 3
;; :tdelay  - Flonum. Effect delay time in seconds, default 0
;; :tattack - Flonum. Effect attack time, default 0.25 X delay
;; :tdecay  - Flonum. Effect decay time, default 0 sec
;; :trem    - Flonum. Tremolo depth, 0 <= trem <= 1, default 0.5
;; :ttab    - Tab. Tremolo wave table, default *sine-table*
;; :tphase  - Flonum | symbol. Phase. See phase in utilities.lsp. 
;;            Default 90 Degrees
;; return   - Sound or sound vector.
;;

(defun tremolo (asig dur &key (tfrq 3)(tdelay 0) tattack (tdecay 0)(trem 0.5)(ttab *sine-table*)(tphase 90))
  (setf tattack (or tattack (* 0.25 tdelay)))
  ;(display "tremolo" tfrq tdelay tattack tdecay trem tphase)
  (tremolo:efx asig (dlfo tfrq 
			  dur 
			  :tab ttab 
			  :phase tphase 
			  :delay tdelay 
			  :attack tattack
			  :decay tdecay)
	       trem))


Main Page       Index