Main Page       Index


pfw.lsp


 pfw.lsp
 Version 1.01  18 May 2005, added :r keyword argument.
 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

 pfw ~ "Percussion Frame Work"
 
 pfw provides a single instrument which acts as a unified drum kit. In
 essence a pfw instrument is an array of functions, one for each MIDI key
 number. By itself pfw does not provide a useful instrument, instead it
 provides a framework for defining drum kits.

 See the file pfw-syn.lsp for an example pfw based drum kit using
 synthesized sounds. A more realistic approach would use sound samples.


var

pfw:*path*





var

*pfw*

 Holds a reference to the most recently created instance of the pfw:back
 class. Several generic global functions, such as (snare) and (bell), use
 *pfw*. It is possible to use multiple instances of pfw:back simultaneously
 but only the most recently created may be referenced by *pfw*


class

pfw:back

 Provides means for grouping related sound generating functions into a
 single instrument. The specific function used is determined by MIDI key
 number. An instance of pfw:back maintains two parallel arrays; one a list
 of functions, the other a list of default arguments to the function.


method

pfw:back :new

 (send pfw:back :new)

 return - object. A new instance of pfw:back


method

pfw:back :render

 (send /pfw:back/ :render index args)
 Generate sound by calling the indexed function with given list of
 arguments. The actual arguments passed to the function is a combination of
 the contents of args and the default arguments provided during the
 definition of the pfw kit (via the add and addsam methods).

 index   - integer. Index in the form of MIDI key number of the function 
           to use.

 args    - list. List of optional arguments in the form of key/value pairs
           which are passed to the indexed function. If args contains an
           identical key to a default argument the value supplied in args
           takes precedence. Additionally some keywords, listed below, have
           significance to the render method directly.

 :VEL    - integer. MIDI velocity value. Amplitude is scaled between -/+6db
           as a function of velocity. For vel=64 amp scale is 0db.
           Default 0db

 :DB     - flonum. Relative amplitude scale in db, default 0.

 :MIXDB  - flonum. Absolute amplitude scale in db. This parameter is
           generally used to set the relative mix of instruments while the
           kit is being defined. Although render recognizes MIXDB it should
           only be used as the default amplitude. Use :DB keyword above to
           scale amplitude at rendering time.

 :ENVFN -  closure. The envelope function used to "gate" the sound.
           default #'rgate

 :ENV   -  list. Argument list to ENVFN, default '()

 :GATE  -  flonum. The envelope "gate" time, default 1 second.

 return - sound.


method

pfw:back :addsam

 (send /pfw:back/ :addsam index filename [a1 [a2 [a3...]]])
 Set indexed function to play a sample file. 
 See pfw:sam function
 
 index    - integer. The index (as MIDI key number) which plays the given
            sample

 filename - string. The sample filename relative to pfw:*path*

 a1 a2 a3 ... - any. An arbitrary number of default parameters in the form  
                key/value pairs. Keys used by the render method are 
                :VEL :DB :MIXDB :ENVFN  ENV and :GATE.  
                Use :MIXDB to set the default amplitude of the sample 
                :DB  should only be used at render time. 
                See :render method.

                Keys which are recognized by pfw:sam function include:
                :FILE   - used internally, DON'T USE.
                :START  - set location in sample file to start playback from, 
                          default 0 second
                :TUNE   - set a detune ratio, default 1.0


method

pfw:back :add

 (send /pfw:back/ :add  index fn [a1 [a2 [a3 ...]]])
 Store reference to sound generating function fn at index.

 index - integer. The index (as MIDI key number) used to access the function.

 fn    - closure. The sound generating function which is executed when 
         render is called with index.  The function should have the form
         (lambda (&rest args) ...) and return a sound. 

 a1 a2 a3 ... - any. List of default parameters in the form of key/value
         pairs which are passed to fn at rendering time. The rendering 
         method makes use of the following keys; 
         :VEL :DB :MIXDB :ENVFN :ENV and :GATE. These
         key/values are also visible to fn. Use :MIXDB to set the fixed 
         relative amplitude of this sound. 
         The :DB key should only be used while actually rendering the sound. 
         Additional keys which may be recognized are fully dependent on fn.


function

pfw:dummy

 (pfw:dummy [args...])
 Place holder function. Accepts an arbitrary number of arguments, does
 absolutely nothing with them and returns silence.

 return - sound


function

pfw:sam

 (pfw:sam :FILE /file/ [:START][:TUNE][:a1][:a2]...[:an])
 Play sample file.

 :FILE  -  string. The fully qualified sample file name to be played. 

 :START -  flonum. The position (in seconds) where to start sample
           playback.

 :TUNE  -  flonum. A tuning ratio applied to sample frequency, default 1

 :R     - flonum. Additional tuning parameter. The actual tuning ratio is 
          the product of tune and r. The addition of the redundant r 
          parameter was to make pfw consistent with the procussion package. 

 :a1 :a2 :a3 ... - any. pfw:sam accepts an arbitrary number of arguments. 
                   All of them, with exception of those listed above, 
                   are ignored.

 return sound.


function

pfw

 (pfw index [args])
 Generate sound by calling the render method of the global instrument *pfw*

 index  - integer. Select the sound generating function to be
          used. Typically index is considered as a MIDI key number.

 args   - list. A list of optional arguments in the form of key/value
          pairs. The keys :VEL :DB :ENVFN :ENV and :GATE are always
          recognized. Additional keys may be recognized depending on the 
          specific sound generating function. For the pfw:sam function 
          these are :START and :TUNE

 return - sound.


con

KICK-0

 pfw instrument index = 0


con

KICK-1

 pfw instrument index = 1


con

KICK-2

 pfw instrument index = 2


con

KICK-3

 pfw instrument index = 3


con

KICK-4

 pfw instrument index = 4


con

KICK-5

 pfw instrument index = 5


con

SNR-0

 pfw instrument index = 6


con

SNR-1

 pfw instrument index = 7


con

SNR-2

 pfw instrument index = 8


con

SNR-3

 pfw instrument index = 9


con

SNR-4

 pfw instrument index = 10


con

SNR-5

 pfw instrument index = 11


con

HAT-0

 pfw instrument index = 12


con

HAT-1

 pfw instrument index = 13


con

HAT-2

 pfw instrument index = 14


con

HAT-3

 pfw instrument index = 15


con

HAT-4

 pfw instrument index = 16


con

HAT-5

 pfw instrument index = 17


con

HAT-6

 pfw instrument index = 18


con

HAT-7

 pfw instrument index = 19


con

TOM-0

 pfw instrument index = 20


con

TOM-1

 pfw instrument index = 21


con

TOM-2

 pfw instrument index = 22


con

TOM-3

 pfw instrument index = 23


con

TOM-4

 pfw instrument index = 24


con

TOM-5

 pfw instrument index = 25


con

TOM-6

 pfw instrument index = 26


con

TOM-7

 pfw instrument index = 27


con

CYM-0

 pfw instrument index = 28


con

CYM-1

 pfw instrument index = 29


con

CYM-2

 pfw instrument index = 30


con

CYM-3

 pfw instrument index = 31


con

CYM-4

 pfw instrument index = 32


con

CYM-5

 pfw instrument index = 33


con

CYM-6

 pfw instrument index = 34


con

CYM-7

 pfw instrument index = 35


con

TAM-0

 pfw instrument index = 36


con

TAM-1

 pfw instrument index = 37


con

BELL-0

 pfw instrument index = 38


con

BELL-1

 pfw instrument index = 39


con

BELL-2

 pfw instrument index = 40


con

BELL-3

 pfw instrument index = 41


con

BELL-4

 pfw instrument index = 42


con

BELL-5

 pfw instrument index = 43


con

BELL-6

 pfw instrument index = 44


con

BELL-7

 pfw instrument index = 45


con

DRUM-0

 pfw instrument index = 46


con

DRUM-1

 pfw instrument index = 47


con

DRUM-2

 pfw instrument index = 48


con

DRUM-3

 pfw instrument index = 49


con

DRUM-4

 pfw instrument index = 50


con

DRUM-5

 pfw instrument index = 51


con

DRUM-6

 pfw instrument index = 52


con

DRUM-7

 pfw instrument index = 53


con

SHAKER-0

 pfw instrument index = 54


con

SHAKER-1

 pfw instrument index = 55


con

SHAKER-2

 pfw instrument index = 56


con

SHAKER-3

 pfw instrument index = 57


con

SHAKER-4

 pfw instrument index = 58


con

SHAKER-5

 pfw instrument index = 59


con

SHAKER-6

 pfw instrument index = 60


con

SHAKER-7

 pfw instrument index = 61


con

PERC-0

 pfw instrument index = 62


con

PERC-1

 pfw instrument index = 63


con

PERC-2

 pfw instrument index = 64


con

PERC-3

 pfw instrument index = 65


con

PERC-4

 pfw instrument index = 66


con

PERC-5

 pfw instrument index = 67


con

PERC-6

 pfw instrument index = 68


con

PERC-7

 pfw instrument index = 69


con

PERC-8

 pfw instrument index = 70


con

PERC-9

 pfw instrument index = 71


con

PERC-10

 pfw instrument index = 72


con

PERC-11

 pfw instrument index = 73


con

PERC-12

 pfw instrument index = 74


con

PERC-13

 pfw instrument index = 75


con

PERC-14

 pfw instrument index = 76


con

PERC-15

 pfw instrument index = 77


function

/pfw/ kick

 (kick [var [:VEL][:DB][:ENVFN][:ENV][:GATE][args...])
 Generate pfw kick sound
 var     - integer. Variation index on basic sound.
 :DB     - flonum. Amplitude scale in DB, default 0
 :ENVFN  - closure. The gate envelope function. Default #'rgate
 :ENV    - list. Arguments to ENVFN, default '()
 :GATE   - flonum. The envelope gate time
 args .. - any. Additional arguments dependent on specific function
 return  - sound.


function

/pfw/ snare

 (snare [var [:VEL][:DB][:ENVFN][:ENV][:GATE][args...])
 Generate pfw snare sound
 var     - integer. Variation index on basic sound.
 :DB     - flonum. Amplitude scale in DB, default 0
 :ENVFN  - closure. The gate envelope function. Default #'rgate
 :ENV    - list. Arguments to ENVFN, default '()
 :GATE   - flonum. The envelope gate time
 args .. - any. Additional arguments dependent on specific function
 return  - sound.


function

/pfw/ hat

 (hat [var [:VEL][:DB][:ENVFN][:ENV][:GATE][args...])
 Generate pfw hat sound
 var     - integer. Variation index on basic sound.
 :DB     - flonum. Amplitude scale in DB, default 0
 :ENVFN  - closure. The gate envelope function. Default #'rgate
 :ENV    - list. Arguments to ENVFN, default '()
 :GATE   - flonum. The envelope gate time
 args .. - any. Additional arguments dependent on specific function
 return  - sound.


function

/pfw/ tom

 (tom [var [:VEL][:DB][:ENVFN][:ENV][:GATE][args...])
 Generate pfw tom sound
 var     - integer. Variation index on basic sound.
 :DB     - flonum. Amplitude scale in DB, default 0
 :ENVFN  - closure. The gate envelope function. Default #'rgate
 :ENV    - list. Arguments to ENVFN, default '()
 :GATE   - flonum. The envelope gate time
 args .. - any. Additional arguments dependent on specific function
 return  - sound.


function

/pfw/ cym

 (cym [var [:VEL][:DB][:ENVFN][:ENV][:GATE][args...])
 Generate pfw cym sound
 var     - integer. Variation index on basic sound.
 :DB     - flonum. Amplitude scale in DB, default 0
 :ENVFN  - closure. The gate envelope function. Default #'rgate
 :ENV    - list. Arguments to ENVFN, default '()
 :GATE   - flonum. The envelope gate time
 args .. - any. Additional arguments dependent on specific function
 return  - sound.


function

/pfw/ tam

 (tam [var [:VEL][:DB][:ENVFN][:ENV][:GATE][args...])
 Generate pfw tam sound
 var     - integer. Variation index on basic sound.
 :DB     - flonum. Amplitude scale in DB, default 0
 :ENVFN  - closure. The gate envelope function. Default #'rgate
 :ENV    - list. Arguments to ENVFN, default '()
 :GATE   - flonum. The envelope gate time
 args .. - any. Additional arguments dependent on specific function
 return  - sound.


function

/pfw/ bell

 (bell [var [:VEL][:DB][:ENVFN][:ENV][:GATE][args...])
 Generate pfw bell sound
 var     - integer. Variation index on basic sound.
 :DB     - flonum. Amplitude scale in DB, default 0
 :ENVFN  - closure. The gate envelope function. Default #'rgate
 :ENV    - list. Arguments to ENVFN, default '()
 :GATE   - flonum. The envelope gate time
 args .. - any. Additional arguments dependent on specific function
 return  - sound.


function

/pfw/ drum

 (drum [var [:VEL][:DB][:ENVFN][:ENV][:GATE][args...])
 Generate pfw drum sound
 var     - integer. Variation index on basic sound.
 :DB     - flonum. Amplitude scale in DB, default 0
 :ENVFN  - closure. The gate envelope function. Default #'rgate
 :ENV    - list. Arguments to ENVFN, default '()
 :GATE   - flonum. The envelope gate time
 args .. - any. Additional arguments dependent on specific function
 return  - sound.


function

/pfw/ shake

 (shake [var [:VEL][:DB][:ENVFN][:ENV][:GATE][args...])
 Generate pfw shake sound
 var     - integer. Variation index on basic sound.
 :DB     - flonum. Amplitude scale in DB, default 0
 :ENVFN  - closure. The gate envelope function. Default #'rgate
 :ENV    - list. Arguments to ENVFN, default '()
 :GATE   - flonum. The envelope gate time
 args .. - any. Additional arguments dependent on specific function
 return  - sound.


function

/pfw/ perc

 (perc [var [:VEL][:DB][:ENVFN][:ENV][:GATE][args...])
 Generate pfw perc sound
 var     - integer. Variation index on basic sound.
 :DB     - flonum. Amplitude scale in DB, default 0
 :ENVFN  - closure. The gate envelope function. Default #'rgate
 :ENV    - list. Arguments to ENVFN, default '()
 :GATE   - flonum. The envelope gate time
 args .. - any. Additional arguments dependent on specific function
 return  - sound.


View the Sourcecode :



;; pfw.lsp
;; Version 1.01  18 May 2005, added :r keyword argument.
;; 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
;;
;; pfw ~ "Percussion Frame Work"
;; 
;; pfw provides a single instrument which acts as a unified drum kit. In
;; essence a pfw instrument is an array of functions, one for each MIDI key
;; number. By itself pfw does not provide a useful instrument, instead it
;; provides a framework for defining drum kits.
;;
;; See the file pfw-syn.lsp for an example pfw based drum kit using
;; synthesized sounds. A more realistic approach would use sound samples.
;;

(require 'map)
(require 'map-vel6)
(require 'os)
(require 'sam)
(require 'option)
(provide 'pfw)
(current-file "pfw")


(setq pfw:+size+  128)			; Array length
(setq pfw:+vmap+  map:*vel6*)		; Amplitude as function of velocity map


;; @doc var pfw:*path*

;; Holds the default directory for sampled sounds used to make the definition
;; of new drum kits cleaner. The value of pfw:*path* is only used while a drum
;; kit is being defined. See os:join function in os.lsp
;;

(setq pfw:*path* "")                    


;; @doc var *pfw*
;; Holds a reference to the most recently created instance of the pfw:back
;; class. Several generic global functions, such as (snare) and (bell), use
;; *pfw*. It is possible to use multiple instances of pfw:back simultaneously
;; but only the most recently created may be referenced by *pfw*
;;

(setq *pfw* nil)


;; Some percussion instrument constants
;;

(setf
 KICK-0 	0
 KICK-1 	1
 KICK-2 	2
 KICK-3 	3
 KICK-4 	4
 KICK-5 	5
 
 SNR-0  	6
 SNR-1  	7
 SNR-2  	8
 SNR-3  	9
 SNR-4  	10
 SNR-5  	11
 
 HAT-0  	12
 HAT-1  	13
 HAT-2  	14
 HAT-3  	15
 HAT-4  	16
 HAT-5  	17
 HAT-6  	18
 HAT-7  	19
 
 TOM-0  	20
 TOM-1  	21
 TOM-2  	22
 TOM-3  	23
 TOM-4  	24
 TOM-5  	25
 TOM-6  	26
 TOM-7  	27
 
 CYM-0  	28
 CYM-1  	29
 CYM-2  	30
 CYM-3  	31
 CYM-4  	32
 CYM-5  	33
 CYM-6  	34
 CYM-7  	35
 
 TAM-0  	36
 TAM-1  	37
 
 BELL-0  	38
 BELL-1  	39
 BELL-2 	40
 BELL-3 	41
 BELL-4 	42
 BELL-5 	43
 BELL-6 	44
 BELL-7 	45
 
 DRUM-0 	46
 DRUM-1 	47
 DRUM-2 	48
 DRUM-3 	49
 DRUM-4 	50
 DRUM-5 	51
 DRUM-6 	52
 DRUM-7 	53
 
 SHAKER-0 	54
 SHAKER-1 	55
 SHAKER-2 	56
 SHAKER-3 	57
 SHAKER-4 	58
 SHAKER-5 	59
 SHAKER-6 	60
 SHAKER-7 	61
 
 PERC-0 	62
 PERC-1 	63
 PERC-2 	64
 PERC-3 	65
 PERC-4 	66
 PERC-5 	67
 PERC-6 	68
 PERC-7 	69
 PERC-8 	70
 PERC-9  	71
 PERC-10 	72
 PERC-11 	73
 PERC-12 	74
 PERC-13 	75
 PERC-14 	76
 PERC-15 	77
 )


; ***************************************************************************  
;				  pfw:back class
; ***************************************************************************  

;; @doc class pfw:back
;; Provides means for grouping related sound generating functions into a
;; single instrument. The specific function used is determined by MIDI key
;; number. An instance of pfw:back maintains two parallel arrays; one a list
;; of functions, the other a list of default arguments to the function.
;;

(setf pfw:back  (send class :new '(.fn .auxargs)))


;; @doc method pfw:back :new
;; (send pfw:back :new)
;;
;; return - object. A new instance of pfw:back
;;

(send pfw:back :answer :isnew '()
      '((setf .fn (make-array pfw:+size+)
	      .auxargs (make-array pfw:+size+))
	(dotimes (index pfw:+size+)
	  (setf (aref .fn index) #'pfw:dummy
		(aref .auxargs index) '()))
	(setf *pfw* self)))


(send pfw:back :answer :size '() '((length .fn)))


;; @doc method pfw:back :render
;; (send /pfw:back/ :render index args)
;; Generate sound by calling the indexed function with given list of
;; arguments. The actual arguments passed to the function is a combination of
;; the contents of args and the default arguments provided during the
;; definition of the pfw kit (via the add and addsam methods).
;;
;; index   - integer. Index in the form of MIDI key number of the function 
;;           to use.
;;
;; args    - list. List of optional arguments in the form of key/value pairs
;;           which are passed to the indexed function. If args contains an
;;           identical key to a default argument the value supplied in args
;;           takes precedence. Additionally some keywords, listed below, have
;;           significance to the render method directly.
;;
;; :VEL    - integer. MIDI velocity value. Amplitude is scaled between -/+6db
;;           as a function of velocity. For vel=64 amp scale is 0db.
;;           Default 0db
;;
;; :DB     - flonum. Relative amplitude scale in db, default 0.
;;
;; :MIXDB  - flonum. Absolute amplitude scale in db. This parameter is
;;           generally used to set the relative mix of instruments while the
;;           kit is being defined. Although render recognizes MIXDB it should
;;           only be used as the default amplitude. Use :DB keyword above to
;;           scale amplitude at rendering time.
;;
;; :ENVFN -  closure. The envelope function used to "gate" the sound.
;;           default #'rgate
;;
;; :ENV   -  list. Argument list to ENVFN, default '()
;;
;; :GATE  -  flonum. The envelope "gate" time, default 1 second.
;;
;; return - sound.
;;

(send pfw:back :answer :render '(index args)
      '(;(here "pfw:back :render"  index args)
	(setf args (append args (nflatten (aref .auxargs index) 1)))
	(let ((vel (get-keyword-value ':VEL args 64))
	      (db  (+ (get-keyword-value ':MIXDB args 0)
		      (get-keyword-value ':DB args 0))))
	  (scale-db (+ db (send pfw:+vmap+ :get vel))
		    (mult 
		     (apply (aref .fn index) args)
		     (funcall (get-keyword-value ':ENVFN args #'rgate)
			      (get-keyword-value ':GATE args 1)
			      (get-keyword-value ':ENV args '())))))))


;; @doc method pfw:back :addsam
;; (send /pfw:back/ :addsam index filename [a1 [a2 [a3...]]])
;; Set indexed function to play a sample file. 
;; See pfw:sam function
;; 
;; index    - integer. The index (as MIDI key number) which plays the given
;;            sample
;;
;; filename - string. The sample filename relative to pfw:*path*
;;
;; a1 a2 a3 ... - any. An arbitrary number of default parameters in the form  
;;                key/value pairs. Keys used by the render method are 
;;                :VEL :DB :MIXDB :ENVFN  ENV and :GATE.  
;;                Use :MIXDB to set the default amplitude of the sample 
;;                :DB  should only be used at render time. 
;;                See :render method.
;;
;;                Keys which are recognized by pfw:sam function include:
;;                :FILE   - used internally, DON'T USE.
;;                :START  - set location in sample file to start playback from, 
;;                          default 0 second
;;                :TUNE   - set a detune ratio, default 1.0
;;

(send pfw:back :answer :addsam '(index filename &rest auxargs)
      '((setf (aref .fn index) #'pfw:sam
	      (aref .auxargs index)
	      (append (list ':FILE (os:join pfw:*path* filename) auxargs)))))


;; @doc method pfw:back :add
;; (send /pfw:back/ :add  index fn [a1 [a2 [a3 ...]]])
;; Store reference to sound generating function fn at index.
;;
;; index - integer. The index (as MIDI key number) used to access the function.
;;
;; fn    - closure. The sound generating function which is executed when 
;;         render is called with index.  The function should have the form
;;         (lambda (&rest args) ...) and return a sound. 
;;
;; a1 a2 a3 ... - any. List of default parameters in the form of key/value
;;         pairs which are passed to fn at rendering time. The rendering 
;;         method makes use of the following keys; 
;;         :VEL :DB :MIXDB :ENVFN :ENV and :GATE. These
;;         key/values are also visible to fn. Use :MIXDB to set the fixed 
;;         relative amplitude of this sound. 
;;         The :DB key should only be used while actually rendering the sound. 
;;         Additional keys which may be recognized are fully dependent on fn.
;;

(send pfw:back :answer :add '(index fn &rest auxargs)
      '((setf (aref .fn index) fn
	      (aref .auxargs index) auxargs)))



; ***************************************************************************  
;		       Default pfw instrument functions
; ***************************************************************************  

;; @doc function pfw:dummy
;; (pfw:dummy [args...])
;; Place holder function. Accepts an arbitrary number of arguments, does
;; absolutely nothing with them and returns silence.
;;
;; return - sound
;;

(defun pfw:dummy (&rest args)(s-rest))


;; @doc function pfw:sam
;; (pfw:sam :FILE /file/ [:START][:TUNE][:a1][:a2]...[:an])
;; Play sample file.
;;
;; :FILE  -  string. The fully qualified sample file name to be played. 
;;
;; :START -  flonum. The position (in seconds) where to start sample
;;           playback.
;;
;; :TUNE  -  flonum. A tuning ratio applied to sample frequency, default 1
;;
;;
;; :R     - flonum. Additional tuning parameter. The actual tuning ratio is 
;;          the product of tune and r. The addition of the redundant r 
;;          parameter was to make pfw consistent with the procussion package. 
;;
;; :a1 :a2 :a3 ... - any. pfw:sam accepts an arbitrary number of arguments. 
;;                   All of them, with exception of those listed above, 
;;                   are ignored.
;;
;; return sound.
;;

(defun pfw:sam (&rest args)
  ;(display "pfw:sam" args) ;;; DEBUG 
  (let ((file (require-keyword ':FILE args "Sample file not specified"))
	(start (get-keyword-value ':START args 0))
	(tune (* (get-keyword-value ':TUNE args  1.00)
		 (get-keyword-value ':r args 1.00))))
    ;(display "pfw:sam" tune) ;;; DEBUG
    (sam:read file :time-offset start :r tune)))


; ***************************************************************************  
;			Global Percussion instruments
; ***************************************************************************  

;; @doc function pfw
;; (pfw index [args])
;; Generate sound by calling the render method of the global instrument *pfw*
;;
;; index  - integer. Select the sound generating function to be
;;          used. Typically index is considered as a MIDI key number.
;;
;; args   - list. A list of optional arguments in the form of key/value
;;          pairs. The keys :VEL :DB :ENVFN :ENV and :GATE are always
;;          recognized. Additional keys may be recognized depending on the 
;;          specific sound generating function. For the pfw:sam function 
;;          these are :START and :TUNE
;;
;; return - sound.
;;

(defun pfw (index &optional args)
  (send *pfw* :render index args))


;; Create a new simplified instrument which uses the pfw function
;; The form is (lambda [n [args ...]])
;; Where n is an integer which selects a variation on the basic instrument (default 0)
;; and args are a list of optional arguments passed to the sound rendering function.
;;

(defmacro pfw:defglob (name offset)
  `(defun ,name (&optional (n 0) &rest args)
     (pfw (+ ,offset n) args)))


;; Create simplified percussion instruments
;;
(pfw:defglob kick 0)
(pfw:defglob snare 6)
(pfw:defglob hat 12)
(pfw:defglob tom 20)
(pfw:defglob cym 28)
(pfw:defglob tam 36)
(pfw:defglob bell 38)
(pfw:defglob drum 46)
(pfw:defglob shake 54)
(pfw:defglob perc 62)


; ***************************************************************************
;				DOCUMENTATION
;  **************************************************************************  

;; @doc con  KICK-0 	
;; pfw instrument index = 0

;; @doc con  KICK-1 	
;; pfw instrument index = 1

;; @doc con  KICK-2 	
;; pfw instrument index = 2

;; @doc con  KICK-3 	
;; pfw instrument index = 3

;; @doc con  KICK-4 	
;; pfw instrument index = 4

;; @doc con  KICK-5 	
;; pfw instrument index = 5

;; @doc con  SNR-0  	
;; pfw instrument index = 6

;; @doc con  SNR-1  	
;; pfw instrument index = 7

;; @doc con  SNR-2  	
;; pfw instrument index = 8

;; @doc con  SNR-3  	
;; pfw instrument index = 9

;; @doc con  SNR-4  	
;; pfw instrument index = 10

;; @doc con  SNR-5  	
;; pfw instrument index = 11

;; @doc con  HAT-0  	
;; pfw instrument index = 12

;; @doc con  HAT-1  	
;; pfw instrument index = 13

;; @doc con  HAT-2  	
;; pfw instrument index = 14

;; @doc con  HAT-3  	
;; pfw instrument index = 15

;; @doc con  HAT-4  	
;; pfw instrument index = 16

;; @doc con  HAT-5  	
;; pfw instrument index = 17

;; @doc con  HAT-6  	
;; pfw instrument index = 18

;; @doc con  HAT-7  	
;; pfw instrument index = 19

;; @doc con  TOM-0  	
;; pfw instrument index = 20

;; @doc con  TOM-1  	
;; pfw instrument index = 21

;; @doc con  TOM-2  	
;; pfw instrument index = 22

;; @doc con  TOM-3  	
;; pfw instrument index = 23

;; @doc con  TOM-4  	
;; pfw instrument index = 24

;; @doc con  TOM-5  	
;; pfw instrument index = 25

;; @doc con  TOM-6  	
;; pfw instrument index = 26

;; @doc con  TOM-7  	
;; pfw instrument index = 27

;; @doc con  CYM-0  	
;; pfw instrument index = 28

;; @doc con  CYM-1  	
;; pfw instrument index = 29

;; @doc con  CYM-2  	
;; pfw instrument index = 30

;; @doc con  CYM-3  	
;; pfw instrument index = 31

;; @doc con  CYM-4  	
;; pfw instrument index = 32

;; @doc con  CYM-5  	
;; pfw instrument index = 33

;; @doc con  CYM-6  	
;; pfw instrument index = 34

;; @doc con  CYM-7  	
;; pfw instrument index = 35

;; @doc con  TAM-0  	
;; pfw instrument index = 36

;; @doc con  TAM-1  	
;; pfw instrument index = 37

;; @doc con  BELL-0  	
;; pfw instrument index = 38

;; @doc con  BELL-1  	
;; pfw instrument index = 39

;; @doc con  BELL-2 	
;; pfw instrument index = 40

;; @doc con  BELL-3 	
;; pfw instrument index = 41

;; @doc con  BELL-4 	
;; pfw instrument index = 42

;; @doc con  BELL-5 	
;; pfw instrument index = 43

;; @doc con  BELL-6 	
;; pfw instrument index = 44

;; @doc con  BELL-7 	
;; pfw instrument index = 45

;; @doc con  DRUM-0 	
;; pfw instrument index = 46

;; @doc con  DRUM-1 	
;; pfw instrument index = 47

;; @doc con  DRUM-2 	
;; pfw instrument index = 48

;; @doc con  DRUM-3 	
;; pfw instrument index = 49

;; @doc con  DRUM-4 	
;; pfw instrument index = 50

;; @doc con  DRUM-5 	
;; pfw instrument index = 51

;; @doc con  DRUM-6 	
;; pfw instrument index = 52

;; @doc con  DRUM-7 	
;; pfw instrument index = 53

;; @doc con  SHAKER-0 	
;; pfw instrument index = 54

;; @doc con  SHAKER-1 	
;; pfw instrument index = 55

;; @doc con  SHAKER-2 	
;; pfw instrument index = 56

;; @doc con  SHAKER-3 	
;; pfw instrument index = 57

;; @doc con  SHAKER-4 	
;; pfw instrument index = 58

;; @doc con  SHAKER-5 	
;; pfw instrument index = 59

;; @doc con  SHAKER-6 	
;; pfw instrument index = 60

;; @doc con  SHAKER-7 	
;; pfw instrument index = 61

;; @doc con  PERC-0 	
;; pfw instrument index = 62

;; @doc con  PERC-1 	
;; pfw instrument index = 63

;; @doc con  PERC-2 	
;; pfw instrument index = 64

;; @doc con  PERC-3 	
;; pfw instrument index = 65

;; @doc con  PERC-4 	
;; pfw instrument index = 66

;; @doc con  PERC-5 	
;; pfw instrument index = 67

;; @doc con  PERC-6 	
;; pfw instrument index = 68

;; @doc con  PERC-7 	
;; pfw instrument index = 69

;; @doc con  PERC-8 	
;; pfw instrument index = 70

;; @doc con  PERC-9  	
;; pfw instrument index = 71

;; @doc con  PERC-10 	
;; pfw instrument index = 72

;; @doc con  PERC-11 	
;; pfw instrument index = 73

;; @doc con  PERC-12 	
;; pfw instrument index = 74

;; @doc con  PERC-13 	
;; pfw instrument index = 75

;; @doc con  PERC-14 	
;; pfw instrument index = 76

;; @doc con  PERC-15 	
;; pfw instrument index = 77

;; @doc function /pfw/ kick
;; (kick [var [:VEL][:DB][:ENVFN][:ENV][:GATE][args...])
;; Generate pfw kick sound
;; var     - integer. Variation index on basic sound.
;; :DB     - flonum. Amplitude scale in DB, default 0
;; :ENVFN  - closure. The gate envelope function. Default #'rgate
;; :ENV    - list. Arguments to ENVFN, default '()
;; :GATE   - flonum. The envelope gate time
;; args .. - any. Additional arguments dependent on specific function
;; return  - sound.

;; @doc function /pfw/ snare
;; (snare [var [:VEL][:DB][:ENVFN][:ENV][:GATE][args...])
;; Generate pfw snare sound
;; var     - integer. Variation index on basic sound.
;; :DB     - flonum. Amplitude scale in DB, default 0
;; :ENVFN  - closure. The gate envelope function. Default #'rgate
;; :ENV    - list. Arguments to ENVFN, default '()
;; :GATE   - flonum. The envelope gate time
;; args .. - any. Additional arguments dependent on specific function
;; return  - sound.

;; @doc function /pfw/ hat
;; (hat [var [:VEL][:DB][:ENVFN][:ENV][:GATE][args...])
;; Generate pfw hat sound
;; var     - integer. Variation index on basic sound.
;; :DB     - flonum. Amplitude scale in DB, default 0
;; :ENVFN  - closure. The gate envelope function. Default #'rgate
;; :ENV    - list. Arguments to ENVFN, default '()
;; :GATE   - flonum. The envelope gate time
;; args .. - any. Additional arguments dependent on specific function
;; return  - sound.

;; @doc function /pfw/ tom
;; (tom [var [:VEL][:DB][:ENVFN][:ENV][:GATE][args...])
;; Generate pfw tom sound
;; var     - integer. Variation index on basic sound.
;; :DB     - flonum. Amplitude scale in DB, default 0
;; :ENVFN  - closure. The gate envelope function. Default #'rgate
;; :ENV    - list. Arguments to ENVFN, default '()
;; :GATE   - flonum. The envelope gate time
;; args .. - any. Additional arguments dependent on specific function
;; return  - sound.

;; @doc function /pfw/ cym
;; (cym [var [:VEL][:DB][:ENVFN][:ENV][:GATE][args...])
;; Generate pfw cym sound
;; var     - integer. Variation index on basic sound.
;; :DB     - flonum. Amplitude scale in DB, default 0
;; :ENVFN  - closure. The gate envelope function. Default #'rgate
;; :ENV    - list. Arguments to ENVFN, default '()
;; :GATE   - flonum. The envelope gate time
;; args .. - any. Additional arguments dependent on specific function
;; return  - sound.

;; @doc function /pfw/ tam
;; (tam [var [:VEL][:DB][:ENVFN][:ENV][:GATE][args...])
;; Generate pfw tam sound
;; var     - integer. Variation index on basic sound.
;; :DB     - flonum. Amplitude scale in DB, default 0
;; :ENVFN  - closure. The gate envelope function. Default #'rgate
;; :ENV    - list. Arguments to ENVFN, default '()
;; :GATE   - flonum. The envelope gate time
;; args .. - any. Additional arguments dependent on specific function
;; return  - sound.

;; @doc function /pfw/ bell
;; (bell [var [:VEL][:DB][:ENVFN][:ENV][:GATE][args...])
;; Generate pfw bell sound
;; var     - integer. Variation index on basic sound.
;; :DB     - flonum. Amplitude scale in DB, default 0
;; :ENVFN  - closure. The gate envelope function. Default #'rgate
;; :ENV    - list. Arguments to ENVFN, default '()
;; :GATE   - flonum. The envelope gate time
;; args .. - any. Additional arguments dependent on specific function
;; return  - sound.

;; @doc function /pfw/ drum
;; (drum [var [:VEL][:DB][:ENVFN][:ENV][:GATE][args...])
;; Generate pfw drum sound
;; var     - integer. Variation index on basic sound.
;; :DB     - flonum. Amplitude scale in DB, default 0
;; :ENVFN  - closure. The gate envelope function. Default #'rgate
;; :ENV    - list. Arguments to ENVFN, default '()
;; :GATE   - flonum. The envelope gate time
;; args .. - any. Additional arguments dependent on specific function
;; return  - sound.

;; @doc function /pfw/ shake
;; (shake [var [:VEL][:DB][:ENVFN][:ENV][:GATE][args...])
;; Generate pfw shake sound
;; var     - integer. Variation index on basic sound.
;; :DB     - flonum. Amplitude scale in DB, default 0
;; :ENVFN  - closure. The gate envelope function. Default #'rgate
;; :ENV    - list. Arguments to ENVFN, default '()
;; :GATE   - flonum. The envelope gate time
;; args .. - any. Additional arguments dependent on specific function
;; return  - sound.

;; @doc function /pfw/ perc
;; (perc [var [:VEL][:DB][:ENVFN][:ENV][:GATE][args...])
;; Generate pfw perc sound
;; var     - integer. Variation index on basic sound.
;; :DB     - flonum. Amplitude scale in DB, default 0
;; :ENVFN  - closure. The gate envelope function. Default #'rgate
;; :ENV    - list. Arguments to ENVFN, default '()
;; :GATE   - flonum. The envelope gate time
;; args .. - any. Additional arguments dependent on specific function
;; return  - sound.


Main Page       Index