-
Notifications
You must be signed in to change notification settings - Fork 5
13장
HyungSuk Ryu edited this page Mar 7, 2017
·
4 revisions
;; ClojureScript r1835 src/cljs/cljs/core.cljs line 492
(extend-type nil
ICounted
(-count [_] 0))
(extend-type goog.structs.LinkedMap
cljs.core/ICounted
(-count [m] (.getCount m)))
(defproject joy/music "1.0.0"
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.7.228"]])
(select-keys x [:childern :name :form :op])
(defproject joy/music "1.0.0"
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.7.228"]]
:plugins [[lein-cljsbuild "1.1.3"]]
(defn soft-attack
"Return a gain node that goes from silent at time <delay> up to
<volume> in 50 milliseconds, then ramps back down to silent after
<duration>"
[ctx {:keys [volume delay duration]}]
(let [node (.createGain ctx)]
(doto (.-gain node)
(.linearRampToValueAtTime 0 delay)
(.linearRampToValueAtTime volume (+ delay 0.05))
(.linearRampToValueAtTime 0 (+ delay duration)))
node))
(defn sine-tone
"Return an oscillator that plays starting at <delay> for <duration> seconds"
[ctx {:keys [cent delay duration]}]
(let [node (.createOscillator ctx)]
(set! (-> node .-frequency .-value) 440)
(set! (-> node .-detune .-value) (- cent 900))
(.start node delay)
(.stop node (+ delay duration))
node))
(defn woo
"Play a 'woo' sound; sounds a bit like a glass harp."
[ctx note]
(let [linger 1.5
note (update-in note [:duration] * linger)]
(-> (sine-tone ctx note)
(connect-to (soft-attack ctx note)))))