byulparan / cl-collider

A SuperCollider client for CommonLisp
Other
218 stars 23 forks source link

Feature Request: make osc-device local port customizable #103

Closed TatriX closed 3 years ago

TatriX commented 3 years ago

Hi! I'm using Touch OSC as a controller. I need to set both IP address and port in Touch OSC settings so I can receive messages in lisp. Right now local port of the osc-device is set to 0:

(defmethod bootup-server-process ((rt-server external-server))
 ... snip ...
  (setf osc-device (sc-osc:osc-device (host rt-server) (port rt-server) :local-port 0))

That means that port is different every time socket is created. Locally I solved that by setting a custom port number in my checkout of cl-collider.

I think it would be nice if one could pass it as an argument to (server-boot).

byulparan commented 3 years ago

I want sc:rt-server object only work with scsynth.

How about make your own osc-device for communication with TouchOSC(or Max, Processing...). You can make sc-osc:osc-device object as how many you want.

;; create osc peer(local-port=64000) and listening incomming messages
(defvar *touch-osc* (sc-osc:osc-device nil nil :local-port 64000))

;; add handle for message "/control0"
(sc-osc:add-osc-responder
 *touch-osc*
 "/control0"
 (lambda (&rest param)
   (uiop:println param)))

;; add handle for message "/control1"
(sc-osc:add-osc-responder
 *touch-osc*
 "/control1"
 (lambda (&rest param)
   (uiop:println param)))

;; close peer
(sc-osc:close-device *touch-osc*)
TatriX commented 3 years ago

Ah, this is even better, thank you!