;; my native message sender
;; NOTE osc-strings must be padded to 32bit multiples
(bind-func my_osc_send
(lambda (address a:float b:i32)
(let ((types ",fi")
(mod (modulo (+ (strlen address) 1) 4))
(addressl (+ (+ (strlen address) 1)
(if (= 0 mod) 0 (- 4 mod))))
(typesl 4)
(length (+ addressl typesl 4 4))
(data (malloc length))
(args (bitcast (pref-ptr data (+ addressl typesl)) i32*)))
(printf "addy length %d:%d:%d\n" (strlen address) addressl (- 4 (modulo (+ (strlen address) 1) 4)))
(strcpy (pref-ptr data 0) address)
(strcpy (pref-ptr data addressl) types)
(pset! args 0 (swap32f a))
(pset! args 1 (swap32i b))
(llvm_send_udp "localhost" 7020 data (i64toi32 length)))))