send-fluid-column-osc   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/libs/external/fluid2d.xtm

Implementation

;; where type is the cube index
;; 5 = density
;; 6 = x velocity
;; 7 = y velocity
;; where first (if true is first row else last)
(bind-func send-fluid-column-osc
  (let ((buf:i8* (halloc 5000)))
    (lambda (addy:i8* cube:fluidcube* type:i32 first:i32)
      (let ((types ",ii")
      (address (if (= (i64toi32 1) first) "/col/f" "/col/l"))
      (addressl 8)
      (typesl 4)
      (xN (tref cube 0))
      (yN (tref cube 10))
      (s (cond ((= type 5) (tref cube 5))
         ((= type 6) (tref cube 6))
         ((= type 7) (tref cube 7))
         (else (tref cube 5))))
      (i 0)
      (idx 0)
      (dat (if (= (i64toi32 1) first)
         (fluid-cube-get-first-column cube type)
         (fluid-cube-get-last-column cube type)))
      (length (+ addressl typesl 4 4 (* 4 yN))))
  (memset buf 0 length)
  (strcpy (pref-ptr buf 0) address)
  (strcpy (pref-ptr buf addressl) types)
  (let ((args1 (bitcast (pref-ptr buf (+ addressl typesl)) i32*))
        (args2 (bitcast (pref-ptr buf (+ addressl typesl 8)) float*)))
    (pset! args1 0 type)
    (pset! args1 1 (i64toi32 yN))
    (dotimes (i yN)
      (pset! args2 i (dtof (pref dat i)))))
  (llvm_send_udp addy 4444 buf (i64toi32 length))))))


Back to Index