Skip to content

Commit

Permalink
Add par-group function
Browse files Browse the repository at this point in the history
  • Loading branch information
bion committed Nov 20, 2014
1 parent c40c89c commit f46fbc6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/overtone/sc/machinery/server/osc_validator.clj
Expand Up @@ -162,6 +162,7 @@

;;Group Commands
"/g_new" [:group-id :zero-to-four :node-id]
"/p_new" [:group-id :zero-to-four :node-id]
"/g_head" [:group-id :node-id]
"/g_tail" [:group-id :node-id]
"/g_freeAll" [:group-id]
Expand Down
10 changes: 9 additions & 1 deletion src/overtone/sc/node.clj
Expand Up @@ -400,6 +400,8 @@
(defn- synth-group? [obj]
(= overtone.sc.node.SynthGroup (type obj)))

(def ^:dynamic par-group-switch false)

(defn group
"Create a new synth group as a child of the target group. By default
creates a new group at the tail of the root group.
Expand Down Expand Up @@ -439,11 +441,17 @@
(let [pos (if (keyword? position) (get NODE-POSITION position) position)
target (to-sc-id target)
pos (or pos 1)
create-command (if par-group-switch "/p_new" "/g_new")
name (if par-group-switch (str "Par-" name) name)
snode (SynthGroup. name id target position (atom :loading) (promise))]
(swap! active-synth-nodes* assoc id snode)
(snd "/g_new" id pos target)
(snd create-command id pos target)
snode)))

(defn par-group [& args]
(binding [par-group-switch true]
(apply group args)))

(defn- group-free*
"Free synth groups, releasing their resources."
[group-id]
Expand Down

0 comments on commit f46fbc6

Please sign in to comment.