Main Page       Index


fm-ensemble.lsp


 fm-ensemble.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

 String ensemble sound
 ISSUE: Docs need to be updated.


wrapper

fm-ensemble

 (fm-ensemble plst dur [:vel][:arpeg][:pos][:release][:vib][:vfrq][:vdelay][:r])
 String ensemble instrument 

 plst     - list or flonum. List of MIDI key numbers. Alternatively a single
            pitch may be specified.

 dur      - FLONUM. Duration in seconds.

 :vel     - FLONUM. Velocity  0 <= vel < 128

 :arpeg   - FLONUM. Time interval between notes in plst, default 0

 :pos     - FLONUM.  Normally the pos argument to an instrument wrapper 
            controls position. However for fm-ensemble the pan position 
            is fixed and pos has no effect.

 :release -  FLONUM. Release time, default 1.50 

 :vib     - FLONUM. Vibrato depth,  0<=vib<=127, default 0

 :vfrq    - FLONUM. Vibrato frequency, default 7.00

 :vdelay  - FLONUM. Vibrato delay time, default 0.533 seconds


 :r       - FLONUM. FM m/c frequency ratio, default 1.
            NOTE: non-sine waveforms are used, small integer values of r
            essentially produce the same sound.

 return   - Vector of 2 sounds.


View the Sourcecode :



;; fm-ensemble.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
;;
;; String ensemble sound
;; ISSUE: Docs need to be updated.
;; 

(require 'definst)
(require 'fmop)
;(require 'txwave)
(require 'txwav2)
(require 'txwav4)
(require 'dlfo)
(require 'map)

(provide 'fm-ensemble)
(current-file "fm-ensemble")


(defun fm-ensemble:voice (pitch dur &key  iscale release vib vfrq vdelay r)
  (let* ((iscale (or iscale 1.00))
	 (r (or r 1.001))
	                                ; Carrier op #1
	 (r1   1.000)
	 (att1 0.333)
	 (dcy1 1.000)
	 (rel1 (or release 1.50))
	 (tab1 *txwav2*)
	 (env1 (adsr att1 dcy1 0 rel1 0.70 dur))

	                                ; Mod op #2
	 (r2   r)
	 (i2   (* iscale 1.500))
	 (tab2 *txwav4*)
	 (env2 env1)
	 
					;Carrier op #3
	 (r3   (* 0.999 r2))
	 (att3 0.100)
	 (dcy3 0.333)
         (rel3 (or release 1.5))
         (tab3 *txwav4*)
	 (env3 (adsr att3 dcy3 0 rel3 0.80 dur))
	 
					;Modulator op #4
	 (r4   0.998)
	 (i4   (* iscale 1.000))
	 (tab4 *sine-table*)
	 (env4 env3)
	 
					;Vibrato
	 ;(vib (* (or vib 1.00) 0.003))
	 (vfrq (or vfrq 7.00))
	 (vdelay (or vdelay 0.533))
	 (vattack 0.533)
	 (vibsig (dlfo vfrq dur :delay vdelay :attack vattack :phase 'RND)))

    (sum (fm1 pitch dur :r1 r1 :t1 tab1 :env1 env1 :r2 r2 
	      :t2 tab2 :env2 env2 :i2 i2 :vib vib :vibsig vibsig)
	 (fm1 pitch dur :r1 r1 :t1 tab3 :env1 env3 :r2 r4 
	      :t2 tab4 :env2 env4 :i2 i4 :vib vib :vibsig vibsig)
	 )))


;; @doc wrapper fm-ensemble
;; (fm-ensemble plst dur [:vel][:arpeg][:pos][:release][:vib][:vfrq][:vdelay][:r])
;; String ensemble instrument 
;;
;; plst     - list or flonum. List of MIDI key numbers. Alternatively a single
;;            pitch may be specified.
;;
;; dur      - FLONUM. Duration in seconds.
;;
;; :vel     - FLONUM. Velocity  0 <= vel < 128
;;
;; :arpeg   - FLONUM. Time interval between notes in plst, default 0
;;
;; :pos     - FLONUM.  Normally the pos argument to an instrument wrapper 
;;            controls position. However for fm-ensemble the pan position 
;;            is fixed and pos has no effect.
;;
;; :release -  FLONUM. Release time, default 1.50 
;;
;; :vib     - FLONUM. Vibrato depth,  0<=vib<=127, default 0
;;
;; :vfrq    - FLONUM. Vibrato frequency, default 7.00
;;
;; :vdelay  - FLONUM. Vibrato delay time, default 0.533 seconds
;;
;;
;; :r       - FLONUM. FM m/c frequency ratio, default 1.
;;            NOTE: non-sine waveforms are used, small integer values of r
;;            essentially produce the same sound.
;;
;; return   - Vector of 2 sounds.
;;

(setq fm-ensemble:*v-mi-map* (map:linear 0.250 4.0))
(setq fm-ensemble:*v-lp-map* (map:linear 300 5000))

(defun fm-ensemble (plst dur &key vel release vib vfrq vdelay arpeg r)
  (setq plst (->list plst))
  (let* ((ncount (length plst))
	 (vel (or vel 64))
	 (iscale (send fm-ensemble:*v-mi-map* :get vel))
	 (lp (send fm-ensemble:*v-lp-map* :get vel))
	 (pos 0.333)
	 (db (definst:comp ncount))
	 (lst1 (every-odd plst))
	 (lst2 (every-even plst))
	 (pinc (/ (or arpeg 0.200)(float ncount))))
    (scale-db db
	       (sim 
		(pan (lowpass4
		      (simrep (n (length lst1))
			      (at (* n pinc)
				  (cue (fm-ensemble:voice (nth n lst1) dur
							  :r r
							  :iscale iscale 
							  :release release
							  :vib vib 
							  :vfrq vfrq 
							  :vdelay vdelay))))
		      lp) pos)
	       (pan (lowpass4
		     (simrep (n (length lst2))
			     (at (* n pinc)
				 (cue (fm-ensemble:voice (nth n lst2) dur
							 :r r
							 :iscale iscale
							 :release release
							 :vib vib
							 :vfrq vfrq
							 :vdelay vdelay))))
		     lp)(- 1 pos)))))) 


Main Page       Index