Clamps Dictionary
make-poly-handler
Function
(make-poly-handler &key amp-handler)
Return a lambda closure which stores (keynum ampdb node-id) lists on
(:note-on keynum node-id) command (returning the list of all held
(keynum ampdb node-id) triplets, deleting the (keynum ampdb
node-id) on (:note-off keynum) command, returning the
node-id. (:list) returns all currently held (keynum ampdb note-id)
triplets in a list, (:keynum node-id) returns the keynum of a
node-id without removing the item from the (keynum ampdb node-id)
list, (:node-id keynum) returns the node-id of a keynum without
removing the item from the (keynum ampdb node-id) list and
(:all-notes-off) removes all held notes and returns a list of all
node-ids of the removed/held notes. (:amp ampdb) will call the
:amp-handler function with nodeid master-amp and ampdb of all
held notes as arguments.
Arguments
:amp-handler |
Handler function to call on all held notes when an :amp command is received. |
Note
The closure doesn't check for duplicate keynums!
Example
;;; init (creation) function: (defparameter *my-poly-handler* (make-poly-handler)) ;;; add some keynums and their node ids: (funcall *my-poly-handler* :note-on 60 1) ; => ((60 1)) (funcall *my-poly-handler* :note-on 62 2) ; => ((62 2) (60 1)) (funcall *my-poly-handler* :note-on 64 3) ; => ((64 3) (62 2) (60 1)) ;;; show all current keynums (held notes) and their node ids: (funcall *my-poly-handler* :list) ; => ((64 3) (62 2) (60 1)) ;;; remove a keynum returning its node-id: (funcall *my-poly-handler* :note-off 62) ; => 2 (funcall *my-poly-handler* :list) ; => ((64 3) (60 1)) ;;; add another keynum: (funcall *my-poly-handler* :note-on 65 5) ; => ((65 5) (64 3) (60 1)) ;;; return the keynum of node-id 1: (funcall *my-poly-handler* :keynum 1) ; => 60 ;;; return the node-id of keynum 64: (funcall *my-poly-handler* :node-id 64) ; => 3 (funcall *my-poly-handler* :list) ; => ((65 5) (64 3) (60 1)) ;;; remove all held notes, returning their node ids in a list: (funcall *my-poly-handler* :all-notes-off) ; => (5 3 1) (funcall *my-poly-handler* :list) ; => nil