Main Page       Index


fmbrass.lsp


 fmbrass.lsp
 Version 1.00 	29 April 2005
 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 FM French Horn instrument.


function

fmbrass:voice

 (fmbrass:voice  step dur [:vel][:i][:r][:pb][:pbdecay][:attack][:decay][:wha][:whattack][:mute])
 A brass like instrument.

 step      - MIDI step. The note to be played.
 dur       - Flonum. The tone's duration in seconds.
 :vel      - MIDI velocity. The velocity controls both brightness and 
             attack time, default 64
 :i        - MIDI CTRL. FM modulation index, default 64.
 :r        - Flonum. FM frequency ratio, default 1.0015
 :pb       - Flonum. Pitch bend amount. Default 0.300
 :pbdecay  - Flonum. Pitch bend duration, default 0.070 seconds.
 :attack   - Flonum. Attack time in seconds. Note the actual attack time
             is scaled by velocity. Default 0.160 seconds.
 :decay    - Flonum. Decay time, default 0.182 seconds.
 :wha      - MIDI CTRL. Filter modulation depth. If modulation index 
             value, :i, is low the filter modulation depth is less 
             noticable. Default 32
 :whattack - Flonum. Filter envelope attack time, default same as 
             amplitude attack 
 :mute     - MIDI CTRL. Controls static highpas filter cutoff, default 0
 return    - Sound.


wrapper

fmbrass

 (fmbrass  plist dur [:vel][:pos][:arpeg][:comp][:i][:r][:pb][:pbdecay][:attack][:decay][:wha][:whattack][:mute])
 A brass like instrument.

 plist     - List | MIDI step. The note(s) to be played.
 dur       - Flonum. The tone's duration in seconds.
 :vel      - MIDI velocity. The velocity controls both brightness and 
             attack time, default 64
 :pos      - Sound | flonum. Pan position, default 0.50
 :arpeg    - Flonum. Arpeggio interval, default 0 seconds.
 :comp     - Flonum | symbol. Amplitude compensation, see definst.lsp.
 :i        - MIDI CTRL. FM modulation index, default 64.
 :r        - Flonum. FM frequency ratio, default 1.0015
 :pb       - Flonum. Pitch bend amount. Default 0.300
 :pbdecay  - Flonum. Pitch bend duration, default 0.070 seconds.
 :attack   - Flonum. Attack time in seconds. Note the actual attack time
             is scaled by velocity. Default 0.160 seconds.
 :decay    - Flonum. Decay time, default 0.182 seconds.
 :wha      - MIDI CTRL. Filter modulation depth. If modulation index 
             value, :i, is low the filter modulation depth is less 
             noticable. Default 32
 :whattack - Flonum. Filter envelope attack time, default same as 
             amplitude attack 
 :mute     - MIDI CTRL. Controls static highpas filter cutoff, default 0
 return    - Sound vector.


View the Sourcecode :



;; fmbrass.lsp
;; Version 1.00 	29 April 2005
;; 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 FM French Horn instrument.
;;

(require 'map)
(require 'map-vibrato)
(require 'dlfo)
(require 'saw-16)
(require 'xenvelope)
(require 'map)
(require 'definst)
(provide 'fmbrass)
(current-file "fmbrass")


(setf fmbrass:*vel-mi-map* (map:linear 0.50 2.00))
(setf fmbrass:*vel-attack-map* (map:linear-knee 4.000 1.0 0.90 0 32 128))
(setf fmbrass:*wha-ctrl-map* (map:quad 0 32 0 128 2))


;; @doc function fmbrass:voice
;; (fmbrass:voice  step dur [:vel][:i][:r][:pb][:pbdecay][:attack][:decay][:wha][:whattack][:mute])
;; A brass like instrument.
;;
;; step      - MIDI step. The note to be played.
;; dur       - Flonum. The tone's duration in seconds.
;; :vel      - MIDI velocity. The velocity controls both brightness and 
;;             attack time, default 64
;; :i        - MIDI CTRL. FM modulation index, default 64.
;; :r        - Flonum. FM frequency ratio, default 1.0015
;; :pb       - Flonum. Pitch bend amount. Default 0.300
;; :pbdecay  - Flonum. Pitch bend duration, default 0.070 seconds.
;; :attack   - Flonum. Attack time in seconds. Note the actual attack time
;;             is scaled by velocity. Default 0.160 seconds.
;; :decay    - Flonum. Decay time, default 0.182 seconds.
;; :wha      - MIDI CTRL. Filter modulation depth. If modulation index 
;;             value, :i, is low the filter modulation depth is less 
;;             noticable. Default 32
;; :whattack - Flonum. Filter envelope attack time, default same as 
;;             amplitude attack 
;; :mute     - MIDI CTRL. Controls static highpas filter cutoff, default 0
;; return    - Sound.
;;

(defun fmbrass:voice (step dur &rest args)
  (let (hz1 r hz2 vel i attack decay pb pbdecay modsig env1 envwha wha whattack hp)
    (setf hz1 (step-to-hz step))
    (setf r (get-keyword-value ':r args 1.0015))
    (setf hz2 (* r hz1))
    (setf vel (get-keyword-value ':vel args 64))

    (setf i (* (map:keyword ':i args 4.50 0.01 64)
	       (send fmbrass:*vel-mi-map* :get vel)))
    
    (setf attack (* (get-keyword-value ':attack args 0.160)
		 (send fmbrass:*vel-attack-map* :get vel)))
    (setf decay (get-keyword-value ':decay args 0.182))
    (setf pb (get-keyword-value ':pb args 0.300))
    (setf pbdecay (get-keyword-value ':pbdecay args 0.070))

    (setf modsig (scale pb (iramp pbdecay)))

    (setf wha (send fmbrass:*wha-ctrl-map* :get
		    (get-keyword-value ':wha args 32)))

    (setf whattack (get-keyword-value ':whattack args attack))
    
    (setf hp (min 10000 (map:keyword ':mute args 16 1 0)))

    (setf env1 (xadsr attack 0.220 0.000 decay 0.80 dur))
    (setf envwha (xadsr whattack 0.300 0 decay 0.50 dur))


    (highpass4
     (mult (fmosc (hz-to-step hz1)
		  (scale (* hz1 i)
			 (sum modsig
			      (mult (lp (fmosc (hz-to-step hz2)
					       (sum (s-rest dur)
						    (scale hz2 modsig))
					       *saw-16*)
					(scale (* wha hz2) envwha))
				    envwha))))
	   env1)
     (* hz1 hp))
   ))


;; @doc wrapper fmbrass
;; (fmbrass  plist dur [:vel][:pos][:arpeg][:comp][:i][:r][:pb][:pbdecay][:attack][:decay][:wha][:whattack][:mute])
;; A brass like instrument.
;;
;; plist     - List | MIDI step. The note(s) to be played.
;; dur       - Flonum. The tone's duration in seconds.
;; :vel      - MIDI velocity. The velocity controls both brightness and 
;;             attack time, default 64
;; :pos      - Sound | flonum. Pan position, default 0.50
;; :arpeg    - Flonum. Arpeggio interval, default 0 seconds.
;; :comp     - Flonum | symbol. Amplitude compensation, see definst.lsp.
;; :i        - MIDI CTRL. FM modulation index, default 64.
;; :r        - Flonum. FM frequency ratio, default 1.0015
;; :pb       - Flonum. Pitch bend amount. Default 0.300
;; :pbdecay  - Flonum. Pitch bend duration, default 0.070 seconds.
;; :attack   - Flonum. Attack time in seconds. Note the actual attack time
;;             is scaled by velocity. Default 0.160 seconds.
;; :decay    - Flonum. Decay time, default 0.182 seconds.
;; :wha      - MIDI CTRL. Filter modulation depth. If modulation index 
;;             value, :i, is low the filter modulation depth is less 
;;             noticable. Default 32
;; :whattack - Flonum. Filter envelope attack time, default same as 
;;             amplitude attack 
;; :mute     - MIDI CTRL. Controls static highpas filter cutoff, default 0
;; return    - Sound vector.
;;

(defwrapper fmbrass #'fmbrass:voice)


Main Page       Index