great-scott / osc-ei

Open Sound Control library for Chicken Scheme

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

osc-ei

Open Sound Control library for Chicken Scheme

Building

csc -s ./osc.setup
chicken-install

api

This is a work in progress, so it's possible the api will change.

; returns socket object that's necessary for other procedure calls
[procedure] (osc-connect port)

; send osc formatted message (message-body) to the specified socket
; message-body can be a list or alist of messages
[procedure] (osc-send socket message-body)

; spawns a thread to listen to messages sent to socket's internal port
; the socket's port is not the port used in (osc-connect port)
[procedure] (osc-listen socket)

; similar to the bare osc-listen procedure, but always calls the
; input procedure
[procedure] (osc-listen-and-call socket procedure)

; registers an osc-address-pattern with a callback procedure
; the procedure can be a reference to a procedure or a quoted
; procedure
[procedure] (register-listener osc-address-pattern procedure)

; closes socket
[procedure] (osc-close socket)

example

(use osc)

(define client-socket (osc-connect 8000))
(define server-socket (osc-server 8000))

(osc-listen-and-call server-socket (lambda (msg) (print msg))

;; send single message
(osc-send client-socket '("/freq" 440))

;; send list of messages one after another
(osc-send client-socket '(("/freq" 640) ("/freq" 220)))

; output
> (/freq 440)
> (/freq 640)
> (/freq 220)

listener example

(use osc)

(define client-socket (osc-connect 8005))
(define server-socket (osc-server 8005))
(osc-listen server-socket)

(define (freq-callback freq) (print "wooo " freq))

; uses quoted version of the procedure, but passing in just
; freq-callback also works
(register-listener "/freq" 'freq-callback)

(osc-send client-socket '("/freq" 440))

; output
wooo (440)

About

Open Sound Control library for Chicken Scheme

License:MIT License


Languages

Language:Scheme 100.0%