diff org/ear.org @ 163:985c73659923

renamed functions in ear.org
author Robert McIntyre <rlm@mit.edu>
date Sat, 04 Feb 2012 02:15:32 -0700
parents 2cbdd7034c6c
children c33a8e5fe7bc
line wrap: on
line diff
     1.1 --- a/org/ear.org	Sat Feb 04 01:44:06 2012 -0700
     1.2 +++ b/org/ear.org	Sat Feb 04 02:15:32 2012 -0700
     1.3 @@ -783,32 +783,14 @@
     1.4          (continuation
     1.5           (vec floats))))))
     1.6  
     1.7 -
     1.8 -
     1.9 -
    1.10 -;; Ears work the same way as vision.
    1.11 -
    1.12 -;; (hearing creature) will return [init-functions
    1.13 -;; sensor-functions]. The init functions each take the world and
    1.14 -;; register a SoundProcessor that does foureier transforms on the
    1.15 -;; incommong sound data, making it available to each sensor function.
    1.16 -
    1.17 -(defn creature-ears
    1.18 +(defn ears
    1.19    "Return the children of the creature's \"ears\" node."
    1.20 -  ;;dylan
    1.21 -  ;;"The ear nodes which are children of the \"ears\" node in the
    1.22 -  ;;creature."
    1.23    [#^Node creature]
    1.24    (if-let [ear-node (.getChild creature "ears")]
    1.25      (seq (.getChildren ear-node))
    1.26      (do (println-repl "could not find ears node") [])))
    1.27  
    1.28 -
    1.29 -;;dylan (defn follow-sense, adjoin-sense, attach-stimuli,
    1.30 -;;anchor-qualia, augment-organ, with-organ
    1.31 -
    1.32 -
    1.33 -(defn update-listener-velocity
    1.34 +(defn update-listener-velocity!
    1.35    "Update the listener's velocity every update loop."
    1.36    [#^Spatial obj #^Listener lis]
    1.37    (let [old-position (atom (.getLocation lis))]
    1.38 @@ -826,7 +808,7 @@
    1.39  
    1.40  (import com.aurellem.capture.audio.AudioSendRenderer)
    1.41  
    1.42 -(defn attach-ear
    1.43 +(defn create-listener!
    1.44    [#^Application world #^Node creature #^Spatial ear continuation]
    1.45    (let [target (closest-node creature ear)
    1.46          lis (Listener.)
    1.47 @@ -835,15 +817,15 @@
    1.48      (.setLocation lis (.getWorldTranslation ear))
    1.49      (.setRotation lis (.getWorldRotation ear))
    1.50      (bind-sense target lis)
    1.51 -    (update-listener-velocity target lis)
    1.52 +    (update-listener-velocity! target lis)
    1.53      (.addListener audio-renderer lis)
    1.54      (.registerSoundProcessor audio-renderer lis sp)))
    1.55  
    1.56 -(defn enable-hearing
    1.57 +(defn hearing-fn
    1.58    [#^Node creature #^Spatial ear]
    1.59    (let [hearing-data (atom [])]
    1.60      [(fn [world]
    1.61 -       (attach-ear world creature ear
    1.62 +       (create-listener! world creature ear
    1.63                     (fn [data]
    1.64                       (reset! hearing-data (vec data)))))
    1.65       [(fn []
    1.66 @@ -858,7 +840,7 @@
    1.67            [topology scaled-data]))
    1.68          ]]))
    1.69  
    1.70 -(defn hearing
    1.71 +(defn hearing!
    1.72    [#^Node creature]
    1.73    (reduce
    1.74     (fn [[init-a senses-a]
    1.75 @@ -866,8 +848,8 @@
    1.76       [(conj init-a init-b)
    1.77        (into senses-a senses-b)])
    1.78     [[][]]      
    1.79 -   (for [ear (creature-ears creature)]
    1.80 -     (enable-hearing creature ear))))
    1.81 +   (for [ear (ears creature)]
    1.82 +     (hearing-fn creature ear))))
    1.83  
    1.84  
    1.85  #+end_src
    1.86 @@ -925,7 +907,7 @@
    1.87  
    1.88  * COMMENT Code Generation
    1.89  
    1.90 -#+begin_src clojure :tangle ../cortex/src/cortex/hearing.clj
    1.91 +#+begin_src clojure :tangle ../src/cortex/hearing.clj
    1.92  <<ears>>
    1.93  #+end_src
    1.94