Skip to content
This repository
Browse code

Add dynamic var to switch off auto namespacing of synthdef name

  • Loading branch information...
commit e200075da27375727db1f5ce342e2e1c22ea1dbd 1 parent b6fcef2
Sam Aaron samaaron authored

Showing 2 changed files with 20 additions and 3 deletions. Show diff stats Hide diff stats

  1. +14 0 src/overtone/sc/dyn_vars.clj
  2. +6 3 src/overtone/sc/synth.clj
14 src/overtone/sc/dyn_vars.clj
@@ -2,6 +2,7 @@
2 2
3 3 (defonce ^{:dynamic true :private true} *inactive-node-modification-error* :exception)
4 4 (defonce ^{:dynamic true :private true} *inactive-buffer-modification-error* :exception)
  5 +(defonce ^{:dynamic true :private true} *add-current-namespace-to-synth-name* true)
5 6 (defonce ^{:dynamic true :private true} *block-node-until-ready?* true)
6 7
7 8 (defn inactive-node-modification-error
@@ -53,3 +54,16 @@
53 54 [& body]
54 55 `(binding [*block-node-until-ready?* false]
55 56 ~@body))
  57 +
  58 +(defn add-current-namespace-to-synth-name?
  59 + "Returns the current value for the dynamic var
  60 + *add-current-namespace-to-synth-name*"
  61 + []
  62 + *add-current-namespace-to-synth-name*)
  63 +
  64 +(defmacro without-namespace-in-synthdef
  65 + "Does not add the current namespace to the synthdef or shorten name to
  66 + within 31 chars."
  67 + [& body]
  68 + `(binding [*add-current-namespace-to-synth-name* false]
  69 + ~@body))
9 src/overtone/sc/synth.clj
@@ -10,7 +10,7 @@
10 10 [overtone.music time]
11 11 [overtone.sc.machinery.ugen fn-gen defaults common specs sc-ugen]
12 12 [overtone.sc.machinery synthdef]
13   - [overtone.sc bindings ugens server node foundation-groups]
  13 + [overtone.sc bindings ugens server node foundation-groups dyn-vars]
14 14 [overtone.helpers seq]
15 15 [clojure.pprint]
16 16 [overtone.helpers.string :only [hash-shorten]])
@@ -322,8 +322,11 @@
322 322 (let [grouped-params (group-params params)
323 323 [params pnames] (make-params grouped-params)
324 324 with-ctl-ugens (concat (make-control-ugens grouped-params) ugens)
325   - detailed (detail-ugens with-ctl-ugens constants grouped-params)]
326   - (with-meta {:name (hash-shorten 31 (ns-name *ns*) (str "/" sname))
  325 + detailed (detail-ugens with-ctl-ugens constants grouped-params)
  326 + full-name (if (add-current-namespace-to-synth-name?)
  327 + (hash-shorten 31 (ns-name *ns*) (str "/" sname))
  328 + sname)]
  329 + (with-meta {:name full-name
327 330 :constants constants
328 331 :params params
329 332 :pnames pnames

0 comments on commit e200075

Please sign in to comment.
Something went wrong with that request. Please try again.