Main Page       Index


marimba.lsp


 marimba.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

 A marimba like instrument


wrapper

marimba

 (marimba plist dur [:vel][:arpeg][:pos][:r][:mix])
 A marimba simulation composed of two percussive elements; a quickly
 decaying transient and a longer "body" tone.

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

 dur      - flonum. Duration in seconds.

 :vel     - integer. MIDI velocity controls lowpass filter,  default 64

 :arpeg   - flonum. Arpeggio interval, default 0

 :pos     - flonum or sound. Pan position as either a fixed number in
            interval (0,5) or a control signal over the same interval. 
            Default 0.5

 :r       - flonum. Relative frequency of the two components. Default 1.00

 :mix     - flonum. Relative mix of the two components, default 0.5

 return   - sound vector.


View the Sourcecode :



;; marimba.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
;;
;; A marimba like instrument
;;

(require 'envelope)
(require 'wtab)
(require 'map)
(require 'definst)
(provide 'marimba)
(current-file "marimba")


(setq marimba:*tab1* (wtab:make '((1 1.000)
				  (2 0.010)
				  (3 0.010)
				  (4 0.080)
				  (5 0.024)
				  (9 0.012))))


(setq marimba:*tab2* (wtab:make '(( 1 1.000)
				  ( 4 0.500)
				  ( 5 0.030)
				  ( 9 0.750)
				  (10 0.050))))


(definst marimba:voice (r mix)
  (let* ((amp1 (clamp 0 1 (or mix 0.5)))
	 (amp2 (- 1 amp1))
	 (decay2 0.2000)
	 (r (or r 1.00)))
    (sum (mult (osc pitch dur marimba:*tab1*)
	       (scale amp1 (percussion dur)))
	 (mult (osc (hz-to-step (* r (step-to-hz pitch))) dur marimba:*tab2*)
	       (scale amp2 (percussion decay2))))))


;; Lowpass filter cutoff as function of vbelocity.
;; curve becomes steeper above velocity = 64
;;

;(setf marimba:*vmap* (map:midi-three-point 100 64 500 15000))
(setf marimba:*vmap* (map:quad 100 15000))


;; @doc wrapper marimba
;; (marimba plist dur [:vel][:arpeg][:pos][:r][:mix])
;; A marimba simulation composed of two percussive elements; a quickly
;; decaying transient and a longer "body" tone.
;;
;; plist    - list or flonum. List of MIDI key numbers. Alternatively a single 
;;            key number may be specified.
;;
;; dur      - flonum. Duration in seconds.
;;
;; :vel     - integer. MIDI velocity controls lowpass filter,  default 64
;;
;; :arpeg   - flonum. Arpeggio interval, default 0
;;
;; :pos     - flonum or sound. Pan position as either a fixed number in
;;            interval (0,5) or a control signal over the same interval. 
;;            Default 0.5
;;
;; :r       - flonum. Relative frequency of the two components. Default 1.00
;;
;; :mix     - flonum. Relative mix of the two components, default 0.5
;;
;; return   - sound vector.
;;

(defwrapper marimba #'marimba:voice
  #'(lambda (sig args)
      (lp sig
       (send marimba:*vmap* :get (get-keyword-value ':VEL args 64)))))


Main Page       Index