Permalink
Browse files

replace boot events with deps

  • Loading branch information...
1 parent c4a9e2b commit a2c5a983e8f8a19413a66cbf40550a0f2ee30530 @samaaron samaaron committed Mar 7, 2011
View
@@ -12,7 +12,7 @@
[supercollider ScSynth ScSynthStartedListener MessageReceivedListener])
(:require [overtone.log :as log])
(:use
- [overtone event config setup util time-utils]
+ [overtone event config setup util time-utils deps]
[overtone.sc allocator]
[clojure.contrib.java-utils :only [file]]
[clojure.contrib pprint]
@@ -120,6 +120,7 @@
(dosync (ref-set status* :connected))
(notify true) ; turn on notifications now that we can communicate
(event :reset)
+ (satisfy-dep :connected)
(event :connected)
(remove-handler "status.reply" ::connected-handler1)
(remove-handler "/status.reply" ::connected-handler2))]
@@ -261,8 +262,7 @@
:mac ["-U" "/Applications/SuperCollider/plugins"] })
(if (= :linux (@config* :os))
- (on-sync-event :connected ::jack-connector
- #(connect-jack-ports)))
+ (with-dep :connected ::connect-jack-ports #(connect-jack-ports)))
(defonce scsynth-server* (ref nil))
@@ -276,7 +276,7 @@
listener (reify ScSynthStartedListener
(started [this]
(log/info "Boot listener...")
- (event :booted)
+ (satisfy-dep :booted)
(reset! running?* true)))]
(.addScSynthStartedListener server listener)
(dosync (ref-set sc-world* server))
@@ -292,7 +292,7 @@
(log/debug "Booting SuperCollider internal server (scsynth)...")
(.start sc-thread)
(dosync (ref-set server-thread* sc-thread))
- (on-sync-event :booted ::internal-boot-connector #(connect))
+ (with-dep :booted ::boot-internal connect)
:booting))))
(defn- sc-log
@@ -367,7 +367,8 @@
(osc-close @server* true))
(dosync
(ref-set server* nil)
- (ref-set status* :no-audio)))
+ (ref-set status* :no-audio)
+ (reset-all-dependencies!)))
; TODO: Come up with a better way to delay shutdown until all of the :quit event handlers
; have executed. For now we just use 500ms.
View
@@ -2,7 +2,7 @@
(:require
[overtone.log :as log])
(:use
- [overtone event util]
+ [overtone event util deps]
[overtone.sc core allocator]))
;; ## Node and Group Management
@@ -282,8 +282,7 @@
(with-meta (parse-node-tree tree)
{:type ::node-tree})))))
-(on-sync-event :connected ::root-group-creator
- #(dosync (ref-set synth-group* (group :head ROOT-GROUP))))
+(with-dep :connected ::create-root-group #(dosync (ref-set synth-group* (group :head ROOT-GROUP))))
(on-sync-event :reset :reset-base
(fn []
@@ -2,8 +2,9 @@
^{:doc "Making it easy to load and play audio samples (wav or aif files)."
:author "Jeff Rose"}
overtone.sc.sample
- (:use [overtone.sc core synth ugen buffer allocator]
- [overtone event util]))
+ (:use
+ [overtone event util deps]
+ [overtone.sc core synth ugen buffer allocator]))
; Define a default wav player synth
(defsynth mono-player
@@ -55,7 +56,7 @@
(doseq [[[path args] buf] @loaded-samples*]
(apply load-sample* path args)))
-(on-sync-event :connected :sample-loader load-all-samples)
+(with-dep :connected ::load-samples load-all-samples)
(defn sample?
[s]
@@ -7,7 +7,7 @@
(:import [java.net URL])
(:require [overtone.log :as log])
(:use byte-spec
- [overtone util event]
+ [overtone util event deps]
[overtone.sc core]))
;; param-name is :
@@ -217,7 +217,7 @@
(doseq [[sname sdef] @loaded-synthdefs*]
(snd "/d_recv" (synthdef-bytes sdef))))
-(on-sync-event :connected ::synthdef-loader load-all-synthdefs)
+(with-dep :connected ::load-synthdefs load-all-synthdefs)
(defn load-synth-file
"Load a synth definition file onto the audio server."
@@ -1,6 +1,6 @@
(ns overtone.studio.core
(:use
- [overtone util event time-utils]
+ [overtone util event time-utils deps]
[overtone.sc.ugen.defaults]
[overtone.sc core synth ugen envelope node synthdef]
[overtone.music rhythm]))
@@ -42,7 +42,7 @@
(let [mix (mixer :tgt @mixer-group*)]
(dosync (ref-set mixer-id* mix))))
-(on-event :studio-setup-completed :start-mixer start-mixer)
+(with-dep :studio-setup-completed ::start-mixer start-mixer)
(defn setup-studio []
(let [g (group :head ROOT-GROUP)
@@ -54,9 +54,9 @@
(ref-set record-group* r)
(ref-set instruments* (map-vals #(assoc % :group (group :tail g))
@instruments*)))
- (event :studio-setup-completed)))
+ (satisfy-dep :studio-setup-completed)))
-(on-sync-event :connected :studio-setup setup-studio)
+(with-dep :connected ::setup-studio setup-studio)
;; Clear and re-create the instrument groups after a reset
;; TODO: re-create the instrument groups

0 comments on commit a2c5a98

Please sign in to comment.