Main Page       Index


dirce.lsp


 dirce.lsp
 Version 1.00  31 October 2004
 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 instrument using 3 FM pairs with stretched envelopes and complex tremolo. 


wrapper

dirce

 (dirce plst dur [:vel][:arpeg][:pos][:comp] [:r1][:r2][:r3][:senv][:sf][:i][:env][:trem][:tfrq1][:tfrq2][:tdelay])
 An instrument composed of three FM carrier/modulator pairs with complex
 tremolo effect.

 plst    - Flonum | List. MIDI note(s) to produce.
 dur     - Flonum. Tones duration in seconds.
 :vel    - MIDI Vel. Velocity controls brightness and amplitude, default 64
 :arpeg  - Flonum. Arpeggio time, default 0 seconds.
 :pos    - Flonum | Sound. Pan position 0 <= pos <= 1, default 0.5
 :comp   - 
 :r1     - Flonum. Relative frequency if the primary FM pair. The c/r ratio 
           is fixed at 1:1, default 1.00
 :r2     - Flonum. Relative frequency of secondary FM pair. The c/r ratio
           is fixed at 1:4, default 2.000
 :r3     - Flonum. Relative frequency of tertiary FM pair. The c/r ratio
           is fixed at 1:5, default 2.000
 :senv   - Sound. The "stretched" envelope is applied to the output of each 
           individual oscillator (6 total, 2 each for each FM pair). The 
           signal is stretched to different degrees for each oscillator 
           providing additional harmonic movement. See :sf parameter below.
 :sf     - MIDI CTRL. Midi control over envelope stretch factor. Default 6
 :i      - MIDI CTRL. Midi control over modulation index, Default 64
 :env    - Sound. Overall amplitude envelope. Default ASD shape
 :trem   - MIDI CTRL. Midi control over tremolo depth, default 32
 :tfrq1  - Flonum. Approximate tremolo frequency for secondary F pair. The 
           actual frequency is randomly varied by 10%, default 3Hz
 :tfrq2  - Flonum. Approximate tremolo frequency for secondary F pair. The 
           actual frequency is randomly varied by 10%, default 6Hz
 :tdelay - Flonum. Tremolo delay time, default 0.33 seconds.
 return  - Sound.


View the Sourcecode :



;; dirce.lsp
;; Version 1.00  31 October 2004
;; 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 instrument using 3 FM pairs with stretched envelopes and complex tremolo. 
;;

(require 'definst)
(require 'tremolo)
(require 'map)
(require 'map-vel6)
(current-file "working")


;; An fmosc with integral envelope
;; chz  - carrier frequency in HZ
;; mhz  - modulator frequency in HZ
;; mi   - modulation index
;; dur  - tone duration in seconds
;; cenv - carrier amplitude envelope
;; menv - modulator amplitude envelope
;; return - sound
;;

(defun dirce:op (chz mhz mi dur cenv menv )
  (mult
   (fmosc (hz-to-step chz)
	  (mult (osc (hz-to-step mhz) dur)
		(scale (* mi chz) menv)))
   cenv))


(defun dirce:voice (step dur &key r1 r2 r3 senv sf i vel env trem tfrq1 tfrq2 tdelay)
  (let (hz chz1 chz2 chz3 mhz1 mhz2 mhz3 strch stfn i1 i2 i3 trem1 trem2 tfrq1 tfrq2)
    (setf r1 (or r1 1.000))
    (setf r2 (or r2 2.000))
    (setf r3 (or r3 2.000))
    (setf rm1 r1)
    (setf rm2 (* r2 4))
    (setf rm3 (* r3 5))
    (setf vel (or vel 64))   
    (setf i (* (map:ctrl 6 (or i 64) 0.5)(map:ctrl 2 vel 0.5)))

    (setf i1 (* i 0.333))
    (setf i2 i)
    (setf i3 i)
    (setf senv (or senv (asd 0.1 (max 0 (- dur .11)) .10)))
    (setf env (or env (asd 0.01 (max 0 (- dur .11)) .10)))
    (setf strch (float (map:ctrl  6 (or sf 12) 0.5)))

    (setf hz (step-to-hz step))
    (setf chz1 (* hz r1))
    (setf chz2 (* hz r2))
    (setf chz3 (* hz r3))
    (setf mhz1 (* hz rm1))
    (setf mhz2 (* hz rm2))
    (setf mhz3 (* hz rm3))

    (setf stfn #'(lambda (csig n)
		   (force-srate *control-srate* (stretch (expt strch n)(sound csig)))))


    (setf trem1 (map:ctrl 1 (or trem 32) 0))
    (setf trem2 trem1)
    (setf tfrq1 (or tfrq1 (about 3.00)))
    (setf tfrq2 (or tfrq2 (about 6.00)))
    (setf tdelay (or tdelay 0.33))
    
    (mult 
     (sum
      (dirce:op chz1 mhz1 i1 dur senv (sum (s-rest dur)(funcall stfn senv 2)))
      (tremolo 
       (scale-db  -9 (dirce:op chz2 mhz2 i2 dur 
			     (funcall stfn senv 4)
			     (funcall stfn senv 6)))
       dur :tfrq tfrq1 :trem trem1 :tdelay tdelay  :tattack 1.00 :tdecay 1.00)
      (tremolo
       (scale-db -18 (dirce:op chz3 mhz3 i3 dur 
			     (funcall stfn senv 5)
			     (funcall stfn senv 3)))
       dur :tfrq tfrq2 :trem trem2 :tdelay (* 1.1 tdelay) :tattack 0.75 :tdecay 0.75))
      (scale-db (send map:*vel6* :get vel) env))))


;; @doc wrapper dirce
;; (dirce plst dur [:vel][:arpeg][:pos][:comp] [:r1][:r2][:r3][:senv][:sf][:i][:env][:trem][:tfrq1][:tfrq2][:tdelay])
;; An instrument composed of three FM carrier/modulator pairs with complex
;; tremolo effect.
;;
;; plst    - Flonum | List. MIDI note(s) to produce.
;; dur     - Flonum. Tones duration in seconds.
;; :vel    - MIDI Vel. Velocity controls brightness and amplitude, default 64
;; :arpeg  - Flonum. Arpeggio time, default 0 seconds.
;; :pos    - Flonum | Sound. Pan position 0 <= pos <= 1, default 0.5
;; :comp   - 
;; :r1     - Flonum. Relative frequency if the primary FM pair. The c/r ratio 
;;           is fixed at 1:1, default 1.00
;; :r2     - Flonum. Relative frequency of secondary FM pair. The c/r ratio
;;           is fixed at 1:4, default 2.000
;; :r3     - Flonum. Relative frequency of tertiary FM pair. The c/r ratio
;;           is fixed at 1:5, default 2.000
;; :senv   - Sound. The "stretched" envelope is applied to the output of each 
;;           individual oscillator (6 total, 2 each for each FM pair). The 
;;           signal is stretched to different degrees for each oscillator 
;;           providing additional harmonic movement. See :sf parameter below.
;; :sf     - MIDI CTRL. Midi control over envelope stretch factor. Default 6
;; :i      - MIDI CTRL. Midi control over modulation index, Default 64
;; :env    - Sound. Overall amplitude envelope. Default ASD shape
;; :trem   - MIDI CTRL. Midi control over tremolo depth, default 32
;; :tfrq1  - Flonum. Approximate tremolo frequency for secondary F pair. The 
;;           actual frequency is randomly varied by 10%, default 3Hz
;; :tfrq2  - Flonum. Approximate tremolo frequency for secondary F pair. The 
;;           actual frequency is randomly varied by 10%, default 6Hz
;; :tdelay - Flonum. Tremolo delay time, default 0.33 seconds.
;; return  - Sound.
;;

(defwrapper dirce
  #'dirce:voice)


Main Page       Index