Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add in-unested-osc-bundle to allow for the creation of bundles which …

…are sent immediately and aren't nested in any outer bundles.
  • Loading branch information...
commit ddf01ca089049eead51dff8848be3a1460057277 1 parent 5909860
@samaaron samaaron authored
Showing with 19 additions and 4 deletions.
  1. +19 −4 src/overtone/osc.clj
View
23 src/overtone/osc.clj
@@ -146,10 +146,25 @@
`(let [[bundle# body-res#] (binding [*osc-msg-bundle* (atom [])]
(let [res# (do ~@body)]
[(mk-osc-bundle ~timestamp @*osc-msg-bundle*) res#]))]
- (if *osc-msg-bundle*
- (swap! *osc-msg-bundle* conj bundle#)
- (osc-send-bundle ~client bundle#))
- body-res#))
+ (if *osc-msg-bundle*
+ (swap! *osc-msg-bundle* conj bundle#)
+ (osc-send-bundle ~client bundle#))
+ body-res#))
+
+(defmacro in-unested-osc-bundle
+ "Runs body and intercepts any inner calls to osc-send-msg and instead
+ of sending the OSC message, aggregates them and wraps them in an OSC
+ bundle. When the body has finished, the bundle is then sent with the
+ associated timestamp to the client.
+
+ Does not nest OSC bundles, it sends all completed OSC bundles
+ immediately."
+ [client timestamp & body]
+ `(let [[bundle# body-res#] (binding [*osc-msg-bundle* (atom [])]
+ (let [res# (do ~@body)]
+ [(mk-osc-bundle ~timestamp @*osc-msg-bundle*) res#]))]
+ (osc-send-bundle ~client bundle#)
+ body-res#))
(defmacro without-osc-bundle
"Runs body and ensures that any inner calls to osc-send-msg are sent
Please sign in to comment.
Something went wrong with that request. Please try again.