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...
1 parent 5909860 commit ddf01ca089049eead51dff8848be3a1460057277 @samaaron samaaron committed Jan 15, 2013
Showing with 19 additions and 4 deletions.
  1. +19 −4 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

0 comments on commit ddf01ca

Please sign in to comment.