Permalink
Browse files

start working on rate inheritance

  • Loading branch information...
1 parent 1a29df4 commit 7da571eb466376e67adb412e3bf5d12fa439713e @samaaron samaaron committed Apr 2, 2011
Showing with 18 additions and 8 deletions.
  1. +11 −2 src/overtone/sc/ugen.clj
  2. +7 −6 src/overtone/sc/ugen/line.clj
@@ -112,14 +112,19 @@
The default rate is determined by the rate precedence:
[:ir :dr :ar :kr]
+ or a :default-rate attribute can override the default precedence order.
- or a :default-rate attribute can override the default precedence order."
+ In the case of functions that don't explicitly specify the rate and in the
+ presence of the key :inherit-rate, the rate is not pre-calculated but instead
+ dynamically obtained from the input parameter specified by the value. For
+ example, the ugen lin-lin inherits its rate from the rate of its first input"
[spec]
(let [rates (:rates spec)
rate-vec (vec rates)
base-name (overtone-ugen-name (:name spec))
base-rate (cond
- (contains? spec :default-rate) (:default-rate spec)
+ (contains? spec :default-rate) (:default-rate spec)
+ (contains? spec :inherit-rate) (as-str (:inherit-rate spec))
(= 1 (count rates)) (first rates)
:default (first (filter rates UGEN-RATE-PRECEDENCE)))
name-rates (zipmap (map #(str base-name %) rate-vec)
@@ -293,6 +298,10 @@
"Does sc style multichannel expansion.
* does not expand seqs flagged infinite
* note that this returns a list even in the case of a single expansion
+
+ Takes expand-flags, a seq of boolean values representing whether a given arg
+ should be expanded. Each nth expand-flag boolean corresponds to each nth arg
+ where arg is a seq of arguments passed into the ugen fn.
"
[expand-flags args]
(if (zero? (count args))
@@ -27,12 +27,13 @@
:doc "Convert from a linear range to an exponential range."}
{:name "LinLin",
- :args [{:name "in", :default 0.0}
- {:name "srclo", :default 0.0}
- {:name "srchi", :default 1.0}
- {:name "dstlo", :default 1.0}
- {:name "dsthi", :default 2.0}]
- :doc "map values from one linear range to another"}
+ :args [{:name "in", :default 0.0 :doc "Input to convert"}
+ {:name "srclo", :default 0.0 :doc "Lower limit of input range"}
+ {:name "srchi", :default 1.0 :doc "Upper limit of input range"}
+ {:name "dstlo", :default 1.0 :doc "Lower limit of output range"}
+ {:name "dsthi", :default 2.0 :doc "Upper limit of output range"}]
+ :doc "Map values from one linear range to another"
+ :inherit-rate "in"}
{:name "AmpComp",
:args [{:name "freq", :default 261.6256} ; default value of (midicps 60)

0 comments on commit 7da571e

Please sign in to comment.