@kairotic/net 0.1.0 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  // Generated by packages/build.mjs
2
2
  export default {
3
3
  "package": "@kairotic/net",
4
- "version": "0.1.0",
4
+ "version": "0.1.4",
5
5
  "api": 1,
6
6
  "author": "bonuoq",
7
7
  "license": "MPL-2.0",
@@ -10,7 +10,7 @@ export default {
10
10
  "class": "pulse",
11
11
  "license": "MPL-2.0",
12
12
  "doc": "The room's beat, while ▶ runs: the count of each pulse (0 at the start of the tempo) on the left, on the audio clock, divided (1, beats; 2, eighths; 0.25, bars of four); on the right, the bpm when the tempo starts or changes, and 0 when it stops. The tempo is one for the whole room — the same beat on every page, from the room's clock, whatever each computer's clock says —; start [bpm], stop and bpm n (which keeps the beat where it is) change it for everyone, as the Room tab does. Outside a room it is this page's tempo.",
13
- "source": ";; pulse · the room's beat: one tempo for everyone in the room, the same beat on every page\n;; Part of @kairotic/net. Written against the Kairotic API (api/…). Discussion #135.\n(let [room (fn [] (.-kairoticRoom js/window))]\n {;; ── about ──\n :class \"pulse\"\n :license \"MPL-2.0\"\n :doc \"The room's beat, while ▶ runs: the count of each pulse (0 at the start of the tempo) on the left, on the audio clock, divided (1, beats; 2, eighths; 0.25, bars of four); on the right, the bpm when the tempo starts or changes, and 0 when it stops. The tempo is one for the whole room — the same beat on every page, from the room's clock, whatever each computer's clock says —; start [bpm], stop and bpm n (which keeps the beat where it is) change it for everyone, as the Room tab does. Outside a room it is this page's tempo.\"\n :usage \"pulse [division]\"\n :io [1 2]\n :size [96 30]\n :args [[:division 1]]\n :help {:inlets [\"start [bpm] · stop · bpm n: the tempo of the whole room\"]\n :outlets [\"the count of each pulse, on its beat\" \"the bpm (0 when it stops)\"]\n :example \"(box :b1 \\\"msg start 100\\\" 40 30)\\n(box :b2 \\\"msg stop\\\" 140 30)\\n(box :b3 \\\"pulse\\\" 40 80)\\n(box :b4 \\\"print\\\" 40 130)\\n(connect :b1 0 :b3 0)\\n(connect :b2 0 :b3 0)\\n(connect :b3 0 :b4 0)\"\n :try \"Press ▶ and click start 100: a count every beat, a second later. In a shared room, every page with a pulse box counts the same beat.\"\n :see [\"share\" \"shared\" \"metro\" \"player\"]}\n\n ;; ── logic ──\n :receive (fn [{:keys [inlet value]}]\n (cond\n (and (= inlet :audio) (number? (:count value))) {:out [[0 (:count value)]] :show {:count (:count value)}}\n (and (= inlet :audio) (contains? value :bpm)) {:out [[1 (or (:bpm value) 0)]] :show {:bpm (:bpm value)}}\n (= inlet :task) {}\n (#{:stop \"stop\"} value) {:effects [[:tempo [:stop]]]}\n (#{:start \"start\"} value) {:effects [[:tempo [:start 120]]]}\n (and (sequential? value) (#{:start \"start\"} (first value))) {:effects [[:tempo [:start (or (api/num-of (rest value)) 120)]]]}\n (and (sequential? value) (#{:bpm \"bpm\"} (first value)) (api/num-of (rest value))) {:effects [[:tempo [:bpm (api/num-of (rest value))]]]}\n :else {}))\n :tasks {:tempo (fn [[op x] _]\n (if-let [r (room)]\n (do (case op :start ((.-start r) x) :bpm ((.-bpm r) x) :stop ((.-stop r))) (js/Promise.resolve true))\n (js/Promise.reject (js/Error. \"pulse: this page has no room layer\"))))}\n\n ;; ── view ──\n :derive (fn [{:keys [shown]}] {:label (cond (number? (:count shown)) (str \"pulse \" (:count shown))\n (:bpm shown) (str \"pulse · \" (api/nice (:bpm shown)) \" bpm\")\n :else \"pulse\")\n :dot (if (number? (:count shown)) :kairos :grid)})\n :view [[:rect {:x 1 :y 1 :w 94 :h 28 :r 3 :stroke :kairos :fill :bg}]\n [:circle {:cx 84 :cy 15 :r 5 :stroke :$dot :fill :$dot}]\n [:text {:x 8 :y 19 :size 11} :$label]]\n\n ;; ── outside: the room's tempo, read every 25 ms, each pulse reported 100 ms ahead on the audio clock ──\n :audio {:create (fn [ac b _]\n (let [div (let [n (js/parseFloat (second (.split (.trim (str (:text b))) #\"\\s+\")))] (if (and (js/isFinite n) (pos? n)) n 1))\n node {:alive (atom true) :until (atom nil) :tempo (atom :none) :inlets [] :outlets []}\n tick (fn []\n (when-let [r (room)]\n (let [t ((.-tempo r)) t (when t (js->clj t :keywordize-keys true)) n ((.-now r))]\n (when (not= t @(:tempo node))\n (reset! (:tempo node) t) (reset! (:until node) nil)\n (api/report! (:id b) {:bpm (:bpm t)} nil))\n (when-let [{:keys [t0 bpm]} t]\n (let [per (/ 60000 (* bpm div))\n from (max n (or @(:until node) n)) to (+ n 100)]\n (doseq [k (range (js/Math.ceil (/ (- from t0) per)) (inc (js/Math.floor (/ (- to t0) per))))\n :let [at (+ t0 (* k per))] :when (and (>= k 0) (>= at from) (< at to))]\n (api/report! (:id b) {:count k} (+ (.-currentTime ac) (/ (- at n) 1000))))\n (reset! (:until node) to))))))\n timer (js/setInterval (fn [] (when @(:alive node) (tick))) 25)]\n (assoc node :timer timer)))\n :dispose (fn [node] (reset! (:alive node) false) (js/clearInterval (:timer node)))}})\n"
13
+ "source": ";; pulse · the room's beat: one tempo for everyone in the room, the same beat on every page\n;; Part of @kairotic/net. Written against the Kairotic API (api/…). Discussion #135.\n(let [room (fn [] (.-kairoticRoom js/window))]\n {;; ── about ──\n :class \"pulse\"\n :license \"MPL-2.0\"\n :doc \"The room's beat, while ▶ runs: the count of each pulse (0 at the start of the tempo) on the left, on the audio clock, divided (1, beats; 2, eighths; 0.25, bars of four); on the right, the bpm when the tempo starts or changes, and 0 when it stops. The tempo is one for the whole room — the same beat on every page, from the room's clock, whatever each computer's clock says —; start [bpm], stop and bpm n (which keeps the beat where it is) change it for everyone, as the Room tab does. Outside a room it is this page's tempo.\"\n :usage \"pulse [division]\"\n :io [1 2]\n :size [96 30]\n :args [[:division 1]]\n :help {:inlets [\":start [bpm] · :stop · :bpm n: the tempo of the whole room\"]\n :outlets [\"the count of each pulse, on its beat\" \"the bpm (0 when it stops)\"]\n :example \"(box :b1 \\\"msg :start 100\\\" 40 30)\\n(box :b2 \\\"msg :stop\\\" 140 30)\\n(box :b3 \\\"pulse\\\" 40 80)\\n(box :b4 \\\"print\\\" 40 130)\\n(connect :b1 0 :b3 0)\\n(connect :b2 0 :b3 0)\\n(connect :b3 0 :b4 0)\"\n :try \"Press ▶ and click start 100: a count every beat, a second later. In a shared room, every page with a pulse box counts the same beat.\"\n :see [\"share\" \"shared\" \"metro\" \"player\"]}\n\n ;; ── logic ──\n :receive (fn [{:keys [inlet value]}]\n (cond\n (and (= inlet :audio) (number? (:count value))) {:out [[0 (:count value)]] :show {:count (:count value)}}\n (and (= inlet :audio) (contains? value :bpm)) {:out [[1 (or (:bpm value) 0)]] :show {:bpm (:bpm value)}}\n (= inlet :task) {}\n (#{:stop} value) {:effects [[:tempo [:stop]]]}\n (#{:start} value) {:effects [[:tempo [:start 120]]]}\n (and (sequential? value) (#{:start} (first value))) {:effects [[:tempo [:start (or (api/num-of (rest value)) 120)]]]}\n (and (sequential? value) (#{:bpm} (first value)) (api/num-of (rest value))) {:effects [[:tempo [:bpm (api/num-of (rest value))]]]}\n :else {}))\n :tasks {:tempo (fn [[op x] _]\n (if-let [r (room)]\n (do (case op :start ((.-start r) x) :bpm ((.-bpm r) x) :stop ((.-stop r))) (js/Promise.resolve true))\n (js/Promise.reject (js/Error. \"pulse: this page has no room layer\"))))}\n\n ;; ── view ──\n :derive (fn [{:keys [shown]}] {:label (cond (number? (:count shown)) (str \"pulse \" (:count shown))\n (:bpm shown) (str \"pulse · \" (api/nice (:bpm shown)) \" bpm\")\n :else \"pulse\")\n :dot (if (number? (:count shown)) :kairos :grid)})\n :view [[:rect {:x 1 :y 1 :w 94 :h 28 :r 3 :stroke :kairos :fill :bg}]\n [:circle {:cx 84 :cy 15 :r 5 :stroke :$dot :fill :$dot}]\n [:text {:x 8 :y 19 :size 11} :$label]]\n\n ;; ── outside: the room's tempo, read every 25 ms, each pulse reported 100 ms ahead on the audio clock ──\n :audio {:create (fn [ac b _]\n (let [div (let [n (js/parseFloat (second (.split (.trim (str (:text b))) #\"\\s+\")))] (if (and (js/isFinite n) (pos? n)) n 1))\n node {:alive (atom true) :until (atom nil) :tempo (atom :none) :inlets [] :outlets []}\n tick (fn []\n (when-let [r (room)]\n (let [t ((.-tempo r)) t (when t (js->clj t :keywordize-keys true)) n ((.-now r))]\n (when (not= t @(:tempo node))\n (reset! (:tempo node) t) (reset! (:until node) nil)\n (api/report! (:id b) {:bpm (:bpm t)} nil))\n (when-let [{:keys [t0 bpm]} t]\n (let [per (/ 60000 (* bpm div))\n from (max n (or @(:until node) n)) to (+ n 100)]\n (doseq [k (range (js/Math.ceil (/ (- from t0) per)) (inc (js/Math.floor (/ (- to t0) per))))\n :let [at (+ t0 (* k per))] :when (and (>= k 0) (>= at from) (< at to))]\n (api/report! (:id b) {:count k} (+ (.-currentTime ac) (/ (- at n) 1000))))\n (reset! (:until node) to))))))\n timer (js/setInterval (fn [] (when @(:alive node) (tick))) 25)]\n (assoc node :timer timer)))\n :dispose (fn [node] (reset! (:alive node) false) (js/clearInterval (:timer node)))}})\n"
14
14
  },
15
15
  {
16
16
  "class": "share",
package/dist/pulse.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  // Generated by packages/build.mjs from src/pulse.cljs
2
2
  export default {
3
3
  "class": "pulse",
4
- "version": "0.1.0",
4
+ "version": "0.1.4",
5
5
  "author": "bonuoq",
6
6
  "license": "MPL-2.0",
7
7
  "doc": "The room's beat, while ▶ runs: the count of each pulse (0 at the start of the tempo) on the left, on the audio clock, divided (1, beats; 2, eighths; 0.25, bars of four); on the right, the bpm when the tempo starts or changes, and 0 when it stops. The tempo is one for the whole room — the same beat on every page, from the room's clock, whatever each computer's clock says —; start [bpm], stop and bpm n (which keeps the beat where it is) change it for everyone, as the Room tab does. Outside a room it is this page's tempo.",
8
- "source": ";; pulse · the room's beat: one tempo for everyone in the room, the same beat on every page\n;; Part of @kairotic/net. Written against the Kairotic API (api/…). Discussion #135.\n(let [room (fn [] (.-kairoticRoom js/window))]\n {;; ── about ──\n :class \"pulse\"\n :license \"MPL-2.0\"\n :doc \"The room's beat, while ▶ runs: the count of each pulse (0 at the start of the tempo) on the left, on the audio clock, divided (1, beats; 2, eighths; 0.25, bars of four); on the right, the bpm when the tempo starts or changes, and 0 when it stops. The tempo is one for the whole room — the same beat on every page, from the room's clock, whatever each computer's clock says —; start [bpm], stop and bpm n (which keeps the beat where it is) change it for everyone, as the Room tab does. Outside a room it is this page's tempo.\"\n :usage \"pulse [division]\"\n :io [1 2]\n :size [96 30]\n :args [[:division 1]]\n :help {:inlets [\"start [bpm] · stop · bpm n: the tempo of the whole room\"]\n :outlets [\"the count of each pulse, on its beat\" \"the bpm (0 when it stops)\"]\n :example \"(box :b1 \\\"msg start 100\\\" 40 30)\\n(box :b2 \\\"msg stop\\\" 140 30)\\n(box :b3 \\\"pulse\\\" 40 80)\\n(box :b4 \\\"print\\\" 40 130)\\n(connect :b1 0 :b3 0)\\n(connect :b2 0 :b3 0)\\n(connect :b3 0 :b4 0)\"\n :try \"Press ▶ and click start 100: a count every beat, a second later. In a shared room, every page with a pulse box counts the same beat.\"\n :see [\"share\" \"shared\" \"metro\" \"player\"]}\n\n ;; ── logic ──\n :receive (fn [{:keys [inlet value]}]\n (cond\n (and (= inlet :audio) (number? (:count value))) {:out [[0 (:count value)]] :show {:count (:count value)}}\n (and (= inlet :audio) (contains? value :bpm)) {:out [[1 (or (:bpm value) 0)]] :show {:bpm (:bpm value)}}\n (= inlet :task) {}\n (#{:stop \"stop\"} value) {:effects [[:tempo [:stop]]]}\n (#{:start \"start\"} value) {:effects [[:tempo [:start 120]]]}\n (and (sequential? value) (#{:start \"start\"} (first value))) {:effects [[:tempo [:start (or (api/num-of (rest value)) 120)]]]}\n (and (sequential? value) (#{:bpm \"bpm\"} (first value)) (api/num-of (rest value))) {:effects [[:tempo [:bpm (api/num-of (rest value))]]]}\n :else {}))\n :tasks {:tempo (fn [[op x] _]\n (if-let [r (room)]\n (do (case op :start ((.-start r) x) :bpm ((.-bpm r) x) :stop ((.-stop r))) (js/Promise.resolve true))\n (js/Promise.reject (js/Error. \"pulse: this page has no room layer\"))))}\n\n ;; ── view ──\n :derive (fn [{:keys [shown]}] {:label (cond (number? (:count shown)) (str \"pulse \" (:count shown))\n (:bpm shown) (str \"pulse · \" (api/nice (:bpm shown)) \" bpm\")\n :else \"pulse\")\n :dot (if (number? (:count shown)) :kairos :grid)})\n :view [[:rect {:x 1 :y 1 :w 94 :h 28 :r 3 :stroke :kairos :fill :bg}]\n [:circle {:cx 84 :cy 15 :r 5 :stroke :$dot :fill :$dot}]\n [:text {:x 8 :y 19 :size 11} :$label]]\n\n ;; ── outside: the room's tempo, read every 25 ms, each pulse reported 100 ms ahead on the audio clock ──\n :audio {:create (fn [ac b _]\n (let [div (let [n (js/parseFloat (second (.split (.trim (str (:text b))) #\"\\s+\")))] (if (and (js/isFinite n) (pos? n)) n 1))\n node {:alive (atom true) :until (atom nil) :tempo (atom :none) :inlets [] :outlets []}\n tick (fn []\n (when-let [r (room)]\n (let [t ((.-tempo r)) t (when t (js->clj t :keywordize-keys true)) n ((.-now r))]\n (when (not= t @(:tempo node))\n (reset! (:tempo node) t) (reset! (:until node) nil)\n (api/report! (:id b) {:bpm (:bpm t)} nil))\n (when-let [{:keys [t0 bpm]} t]\n (let [per (/ 60000 (* bpm div))\n from (max n (or @(:until node) n)) to (+ n 100)]\n (doseq [k (range (js/Math.ceil (/ (- from t0) per)) (inc (js/Math.floor (/ (- to t0) per))))\n :let [at (+ t0 (* k per))] :when (and (>= k 0) (>= at from) (< at to))]\n (api/report! (:id b) {:count k} (+ (.-currentTime ac) (/ (- at n) 1000))))\n (reset! (:until node) to))))))\n timer (js/setInterval (fn [] (when @(:alive node) (tick))) 25)]\n (assoc node :timer timer)))\n :dispose (fn [node] (reset! (:alive node) false) (js/clearInterval (:timer node)))}})\n"
8
+ "source": ";; pulse · the room's beat: one tempo for everyone in the room, the same beat on every page\n;; Part of @kairotic/net. Written against the Kairotic API (api/…). Discussion #135.\n(let [room (fn [] (.-kairoticRoom js/window))]\n {;; ── about ──\n :class \"pulse\"\n :license \"MPL-2.0\"\n :doc \"The room's beat, while ▶ runs: the count of each pulse (0 at the start of the tempo) on the left, on the audio clock, divided (1, beats; 2, eighths; 0.25, bars of four); on the right, the bpm when the tempo starts or changes, and 0 when it stops. The tempo is one for the whole room — the same beat on every page, from the room's clock, whatever each computer's clock says —; start [bpm], stop and bpm n (which keeps the beat where it is) change it for everyone, as the Room tab does. Outside a room it is this page's tempo.\"\n :usage \"pulse [division]\"\n :io [1 2]\n :size [96 30]\n :args [[:division 1]]\n :help {:inlets [\":start [bpm] · :stop · :bpm n: the tempo of the whole room\"]\n :outlets [\"the count of each pulse, on its beat\" \"the bpm (0 when it stops)\"]\n :example \"(box :b1 \\\"msg :start 100\\\" 40 30)\\n(box :b2 \\\"msg :stop\\\" 140 30)\\n(box :b3 \\\"pulse\\\" 40 80)\\n(box :b4 \\\"print\\\" 40 130)\\n(connect :b1 0 :b3 0)\\n(connect :b2 0 :b3 0)\\n(connect :b3 0 :b4 0)\"\n :try \"Press ▶ and click start 100: a count every beat, a second later. In a shared room, every page with a pulse box counts the same beat.\"\n :see [\"share\" \"shared\" \"metro\" \"player\"]}\n\n ;; ── logic ──\n :receive (fn [{:keys [inlet value]}]\n (cond\n (and (= inlet :audio) (number? (:count value))) {:out [[0 (:count value)]] :show {:count (:count value)}}\n (and (= inlet :audio) (contains? value :bpm)) {:out [[1 (or (:bpm value) 0)]] :show {:bpm (:bpm value)}}\n (= inlet :task) {}\n (#{:stop} value) {:effects [[:tempo [:stop]]]}\n (#{:start} value) {:effects [[:tempo [:start 120]]]}\n (and (sequential? value) (#{:start} (first value))) {:effects [[:tempo [:start (or (api/num-of (rest value)) 120)]]]}\n (and (sequential? value) (#{:bpm} (first value)) (api/num-of (rest value))) {:effects [[:tempo [:bpm (api/num-of (rest value))]]]}\n :else {}))\n :tasks {:tempo (fn [[op x] _]\n (if-let [r (room)]\n (do (case op :start ((.-start r) x) :bpm ((.-bpm r) x) :stop ((.-stop r))) (js/Promise.resolve true))\n (js/Promise.reject (js/Error. \"pulse: this page has no room layer\"))))}\n\n ;; ── view ──\n :derive (fn [{:keys [shown]}] {:label (cond (number? (:count shown)) (str \"pulse \" (:count shown))\n (:bpm shown) (str \"pulse · \" (api/nice (:bpm shown)) \" bpm\")\n :else \"pulse\")\n :dot (if (number? (:count shown)) :kairos :grid)})\n :view [[:rect {:x 1 :y 1 :w 94 :h 28 :r 3 :stroke :kairos :fill :bg}]\n [:circle {:cx 84 :cy 15 :r 5 :stroke :$dot :fill :$dot}]\n [:text {:x 8 :y 19 :size 11} :$label]]\n\n ;; ── outside: the room's tempo, read every 25 ms, each pulse reported 100 ms ahead on the audio clock ──\n :audio {:create (fn [ac b _]\n (let [div (let [n (js/parseFloat (second (.split (.trim (str (:text b))) #\"\\s+\")))] (if (and (js/isFinite n) (pos? n)) n 1))\n node {:alive (atom true) :until (atom nil) :tempo (atom :none) :inlets [] :outlets []}\n tick (fn []\n (when-let [r (room)]\n (let [t ((.-tempo r)) t (when t (js->clj t :keywordize-keys true)) n ((.-now r))]\n (when (not= t @(:tempo node))\n (reset! (:tempo node) t) (reset! (:until node) nil)\n (api/report! (:id b) {:bpm (:bpm t)} nil))\n (when-let [{:keys [t0 bpm]} t]\n (let [per (/ 60000 (* bpm div))\n from (max n (or @(:until node) n)) to (+ n 100)]\n (doseq [k (range (js/Math.ceil (/ (- from t0) per)) (inc (js/Math.floor (/ (- to t0) per))))\n :let [at (+ t0 (* k per))] :when (and (>= k 0) (>= at from) (< at to))]\n (api/report! (:id b) {:count k} (+ (.-currentTime ac) (/ (- at n) 1000))))\n (reset! (:until node) to))))))\n timer (js/setInterval (fn [] (when @(:alive node) (tick))) 25)]\n (assoc node :timer timer)))\n :dispose (fn [node] (reset! (:alive node) false) (js/clearInterval (:timer node)))}})\n"
9
9
  };
package/dist/share.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  // Generated by packages/build.mjs from src/share.cljs
2
2
  export default {
3
3
  "class": "share",
4
- "version": "0.1.0",
4
+ "version": "0.1.4",
5
5
  "author": "bonuoq",
6
6
  "license": "MPL-2.0",
7
7
  "doc": "Shares what arrives with everyone in the room, on a channel (main if none): every shared box of the room listening to that channel sends it out — on every page, this one too. Any value: a number, a list, an event from midiin or motion, a map. It goes on the room's reliable channel, in order, with or without ▶. Outside a shared room it reaches the shared boxes of this page only. It is a message of the moment, not a gesture: the history does not keep it.",
package/dist/shared.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  // Generated by packages/build.mjs from src/shared.cljs
2
2
  export default {
3
3
  "class": "shared",
4
- "version": "0.1.0",
4
+ "version": "0.1.4",
5
5
  "author": "bonuoq",
6
6
  "license": "MPL-2.0",
7
7
  "doc": "What anyone in the room shares on a channel (main if none) with a share box — this page included —, while ▶ runs: the value on the left, the name of who shared it on the right. A midiin on one page and a shared box feeding synth~ on another is playing someone else's instrument; an event map from motion on a phone moves a knob on the computer.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kairotic/net",
3
- "version": "0.1.0",
3
+ "version": "0.1.4",
4
4
  "description": "Kairotic in a shared room: share values on channels with everyone in it, and one tempo for the whole room (the same beat on every page)",
5
5
  "author": "bonuoq",
6
6
  "license": "MPL-2.0",
package/src/pulse.cljs CHANGED
@@ -9,9 +9,9 @@
9
9
  :io [1 2]
10
10
  :size [96 30]
11
11
  :args [[:division 1]]
12
- :help {:inlets ["start [bpm] · stop · bpm n: the tempo of the whole room"]
12
+ :help {:inlets [":start [bpm] · :stop · :bpm n: the tempo of the whole room"]
13
13
  :outlets ["the count of each pulse, on its beat" "the bpm (0 when it stops)"]
14
- :example "(box :b1 \"msg start 100\" 40 30)\n(box :b2 \"msg stop\" 140 30)\n(box :b3 \"pulse\" 40 80)\n(box :b4 \"print\" 40 130)\n(connect :b1 0 :b3 0)\n(connect :b2 0 :b3 0)\n(connect :b3 0 :b4 0)"
14
+ :example "(box :b1 \"msg :start 100\" 40 30)\n(box :b2 \"msg :stop\" 140 30)\n(box :b3 \"pulse\" 40 80)\n(box :b4 \"print\" 40 130)\n(connect :b1 0 :b3 0)\n(connect :b2 0 :b3 0)\n(connect :b3 0 :b4 0)"
15
15
  :try "Press ▶ and click start 100: a count every beat, a second later. In a shared room, every page with a pulse box counts the same beat."
16
16
  :see ["share" "shared" "metro" "player"]}
17
17
 
@@ -21,10 +21,10 @@
21
21
  (and (= inlet :audio) (number? (:count value))) {:out [[0 (:count value)]] :show {:count (:count value)}}
22
22
  (and (= inlet :audio) (contains? value :bpm)) {:out [[1 (or (:bpm value) 0)]] :show {:bpm (:bpm value)}}
23
23
  (= inlet :task) {}
24
- (#{:stop "stop"} value) {:effects [[:tempo [:stop]]]}
25
- (#{:start "start"} value) {:effects [[:tempo [:start 120]]]}
26
- (and (sequential? value) (#{:start "start"} (first value))) {:effects [[:tempo [:start (or (api/num-of (rest value)) 120)]]]}
27
- (and (sequential? value) (#{:bpm "bpm"} (first value)) (api/num-of (rest value))) {:effects [[:tempo [:bpm (api/num-of (rest value))]]]}
24
+ (#{:stop} value) {:effects [[:tempo [:stop]]]}
25
+ (#{:start} value) {:effects [[:tempo [:start 120]]]}
26
+ (and (sequential? value) (#{:start} (first value))) {:effects [[:tempo [:start (or (api/num-of (rest value)) 120)]]]}
27
+ (and (sequential? value) (#{:bpm} (first value)) (api/num-of (rest value))) {:effects [[:tempo [:bpm (api/num-of (rest value))]]]}
28
28
  :else {}))
29
29
  :tasks {:tempo (fn [[op x] _]
30
30
  (if-let [r (room)]