Overview Clamps Packages CM Dictionary Clamps Dictionary Fomus
Next: make-quantlist , Previous: make-oasr , Up: M , Home: Overview

Clamps Dictionary

make-poly-handler

Function

(make-poly-handler)

Return a lambda closure which stores (keynum node-id) lists on (:note-on keynum node-id) command (returning the list of all held (keynum node.id) pairs, deletes the (keynum node-id) on (:note-off keynum) command, returning the node-id. (:list) returns all currently held (key note-id) pairs in a list, (:keynum node-id) returns the keynum of a node-id without removing the item from the (keynum node-id) list, (:node-id keynum) returns the node-id of a keynum without removing the item from the (keynum node-id) list and (:all-notes-off) removes all held notes and returns a list of all node-ids of the removed/held notes.

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

Author: Orm Finnendahl

Created: 2025-12-06 Sa 20:15

Validate