Overview Clamps Packages CM Dictionary Clamps Dictionary Fomus
Next: Example using *​midi-cc-state​* , Previous: MIDI Input , Up: MIDI Input , Home: General

Clamps Packages

Example using *​midi-cc-fns​*

Let's show this in action. We want to attach behaviour when controller 1 of MIDI channel 1 is moved. One way is to use the *​midi-cc-fns​* variable like this:

;; add a function to the slot of *midi-cc-fns* corresponding to
;; the desired CC number and MIDI channel

(push
 (lambda (cc-val)
   (msg :warn "Received CC Value ~a on Midi Channel 1 and CC Number 1" cc-val))
 (aref (aref *midi-cc-fns* 0) 0))

;; => (#<function (lambda (cc-val)) {557AF50B}>)

When a MIDI controller outputting to MIDI channel 1 is connected to the JACK input of Incudine, moving controller 1 will print something like the following in the REPL:

warn: Received CC Value 46 on Midi Channel 1 and CC Number 1
warn: Received CC Value 47 on Midi Channel 1 and CC Number 1
warn: Received CC Value 48 on Midi Channel 1 and CC Number 1
warn: Received CC Value 49 on Midi Channel 1 and CC Number 1

In order to avoid the nested aref calls and the push, a couple of convenience functions have been added to cl-midictl. Rather than using zero-based numbers for the MIDI channel and CC number in the array references, those numbers start counting from 1 as common in most programs and hardware controllers.

The following call is equivalent to the call above:

(add-midi-cc-fn
 (lambda (ccval)
   (msg :warn
         "Received CC Value ~a on Midi Channel 1 and CC Number 1"
         ccval))
 1 1)

;; => (#<function (lambda (cc-val)) {564DA61B}>)

In a similar fashion the following functions are defined for convenience:

Check their documentation how they are used.