send-fluid-row-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-row-osc
  (let ((buf:i8* (halloc 5000)))
    (lambda (addy:i8* cube:fluidcube* type:i32 first:i32)
      (let ((types ",ii")
      (address (if (= (i64toi32 1) first) "/row/f" "/row/l"))
      (addressl 8)
      (typesl 4)
      (xN (tref cube 0))
      (yN (tref cube 10))
      (ds (tref cube 5))
      (xs (tref cube 6))
      (ys (tref cube 7))
      (s (cond ((= type 5) ds)
             ((= type 6) xs)
             ((= type 7) ys)
             (else ds)))
      (i 0)
      (idx 0)
      (dat (if (= (i64toi32 1) first)
         (fluid-cube-get-first-row cube type)
         (fluid-cube-get-last-row cube type)))
      (length (+ addressl typesl 4 4 (* 4 xN))))
  (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 xN))
    (dotimes (i xN)
      (pset! args2 i (dtof (pref dat i)))))
  (llvm_send_udp addy 4444 buf (i64toi32 length))))))


Back to Index