Jump to content

midi-cc-function // lisp coding problems


AM

Recommended Posts

dear all

 

i want to code a simple function for sending midi-cc in an "all-in-one"-function (to external devices like filterbank or microcosm)

it works more or less.... but there are two bugs i can't fix.

 

the function:

 

(defun filterbank (&key cc value-range (time-range '(1 127)) (port 7) (channel 16))
  (let ((values (loop 
               for i in (rnd-sample 100 (gen-integer (first value-range) (second value-range)))
               for j in (gen-length (gen-integer (first time-range) (second time-range)) 1/128)
               collect (list i j))))

    (live-coding-midi 
     (compile-score 
      (def-score cc-seq
          (:title "cc-seq"
           :key-signature 'chromatic
           :time-signature '(4 4)
           :tempo 60) 
        (seq
         :length '(3)
         :pitch '(c4)
         :velocity '(ff)
         :port port
         :channel channel
         :controllers (1 values)))))))

(filterbank :cc 1 :value-range '(40 99) :port 1)

 

problem 1: when i evaluate the function and run it ONCE - everything okay. when i like to RUN it a second time there is an error, i don't know why. then i have to evaluate the FUNCTION again... why?

 

problem 2: i would like to "replace"  :controllers (1 values)  by  :controllers (cc values)

-> so that i can choose the cc-number by a variable "cc". but it don't work - any hints? 

 

thanx for some help

andré

 

 

Link to comment
Share on other sites

I think for this kind of tasks it could help to have functions like this:

 

(send-midi-note :note 60 :velocity 20 :chan 0 :dest 0 :dur 'q)

(send-controller :num 1 :val 60 :chan 0 :dest 0 :dur 'q :endval 10)

 

Bypassing score, notation, midi-player, live-coding. 

Just instant MIDI-output on cmd-e or inside of code.

Then you could write functions ,loops or just for testing or setting up your devices. 

 

What do you think?

 

I assume live-coding-midi is not made to run inside of a functions.

 

 

 

Link to comment
Share on other sites

it's not a problem with live-coding - cc-messages are sended perfectly, but...

 

Bildschirmfoto2023-02-10um09_35_17.thumb.png.20f4ad9ee58332b55f47356f4d937744.png

 

 

but, when i try to evaluate a few times, the error comes up - it seems to me to be a problem with "controllers" inside a new function => when i evaluate for the second time it's always:

Error: Controllers must be alternating names/numbers and values.

 

i have no idea, why this is a problem when doing more the 1 eval...

 

Link to comment
Share on other sites

that's the code

 

(defun filterbank (&key cc value-range (time-range '(1 127)) (port 7) (channel 16))
  (let ((values (loop 
               for i in (rnd-sample 100 (gen-integer (first value-range) (second value-range)))
               for j in (gen-length (gen-integer (first time-range) (second time-range)) 1/128)
               collect (list i j))))

    (live-coding-midi 
     (compile-score 
      (def-score cc-seq
          (:title "cc-seq"
           :key-signature 'chromatic
           :time-signature '(4 4)
           :tempo 60) 
        (seq
         :length '(3)
         :pitch '(c4)
         :velocity '(ff)
         :port port
         :channel channel
         :controllers (1 values)))))))

(filterbank :cc 1 :value-range '(40 99) :port 1)

 

Link to comment
Share on other sites

You need to eval the function again:

 

(progn
  (defun filterbank (&key cc value-range (time-range '(1 127)) (port 7) (channel 16))
    (let ((values (loop 
                     for i in (rnd-sample 100 (gen-integer (first value-range) (second value-range)))
                     for j in (gen-length (gen-integer (first time-range) (second time-range)) 1/128)
                     collect (list i j))))
      
      (live-coding-midi 
       (compile-score 
        (def-score cc-seq
            (:title "cc-seq"
             :key-signature 'chromatic
             :time-signature '(4 4)
             :tempo 60) 
          (seq
           :length '(3)
           :pitch '(c4)
           :velocity '(ff)
           :port 1
           :channel channel
           :controllers (1 values)))))))

  (filterbank :cc 1 :value-range '(40 99) :port 1)


  )

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

Terms of Use Privacy Policy