Mercurial > cortex
comparison org/hearing.org @ 283:23aadf376e9d
upgraded to latest jMonkeyEngine, streamlined tests
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Wed, 15 Feb 2012 16:56:01 -0700 |
parents | c39b8b29a79e |
children | 7e7f8d6d9ec5 |
comparison
equal
deleted
inserted
replaced
282:2ad29b68ff22 | 283:23aadf376e9d |
---|---|
1016 | 1016 |
1017 #+name: test-hearing-2 | 1017 #+name: test-hearing-2 |
1018 #+begin_src clojure | 1018 #+begin_src clojure |
1019 (in-ns 'cortex.test.hearing) | 1019 (in-ns 'cortex.test.hearing) |
1020 | 1020 |
1021 (cortex.import/mega-import-jme3) | 1021 (defn test-worm-hearing |
1022 (import java.io.File) | 1022 ([] (test-worm-hearing false)) |
1023 | 1023 ([record?] |
1024 (use 'cortex.body) | 1024 (let [the-worm (doto (worm) (body!)) |
1025 | 1025 hearing (hearing! the-worm) |
1026 (defn test-worm-hearing [] | 1026 hearing-display (view-hearing) |
1027 (let [the-worm (doto (worm) (body!)) | 1027 |
1028 hearing (hearing! the-worm) | 1028 tone (AudioNode. (asset-manager) |
1029 hearing-display (view-hearing) | 1029 "Sounds/pure.wav" false) |
1030 | |
1031 hymn (AudioNode. (asset-manager) | |
1032 "Sounds/ear-and-eye.wav" false)] | |
1033 (world | |
1034 (nodify [the-worm (floor)]) | |
1035 (merge standard-debug-controls | |
1036 {"key-return" | |
1037 (fn [_ value] | |
1038 (if value (.play tone))) | |
1039 "key-l" | |
1040 (fn [_ value] | |
1041 (if value (.play hymn)))}) | |
1042 (fn [world] | |
1043 (light-up-everything world) | |
1044 (if record? | |
1045 (do | |
1046 (com.aurellem.capture.Capture/captureVideo | |
1047 world | |
1048 (File."/home/r/proj/cortex/render/worm-audio/frames")) | |
1049 (com.aurellem.capture.Capture/captureAudio | |
1050 world | |
1051 (File."/home/r/proj/cortex/render/worm-audio/audio.wav"))))) | |
1030 | 1052 |
1031 tone (AudioNode. (asset-manager) | 1053 (fn [world tpf] |
1032 "Sounds/pure.wav" false) | 1054 (hearing-display |
1033 | 1055 (map #(% world) hearing) |
1034 hymn (AudioNode. (asset-manager) | 1056 (if record? |
1035 "Sounds/ear-and-eye.wav" false)] | 1057 (File. "/home/r/proj/cortex/render/worm-audio/hearing-data")))))))) |
1036 (world | |
1037 (nodify [the-worm (floor)]) | |
1038 (merge standard-debug-controls | |
1039 {"key-return" | |
1040 (fn [_ value] | |
1041 (if value (.play tone))) | |
1042 "key-l" | |
1043 (fn [_ value] | |
1044 (if value (.play hymn)))}) | |
1045 (fn [world] | |
1046 (light-up-everything world) | |
1047 (com.aurellem.capture.Capture/captureVideo | |
1048 world | |
1049 (File."/home/r/proj/cortex/render/worm-audio/frames")) | |
1050 (com.aurellem.capture.Capture/captureAudio | |
1051 world | |
1052 (File."/home/r/proj/cortex/render/worm-audio/audio.wav"))) | |
1053 | |
1054 (fn [world tpf] | |
1055 (hearing-display | |
1056 (map #(% world) hearing) | |
1057 (File. "/home/r/proj/cortex/render/worm-audio/hearing-data")))))) | |
1058 #+end_src | 1058 #+end_src |
1059 | 1059 |
1060 In this test, I load the worm with its newly formed ear and let it | 1060 In this test, I load the worm with its newly formed ear and let it |
1061 hear sounds. The sound the worm is hearing is localized to the origin | 1061 hear sounds. The sound the worm is hearing is localized to the origin |
1062 of the world, and you can see that as the worm moves farther away from | 1062 of the world, and you can see that as the worm moves farther away from |
1152 #+end_src | 1152 #+end_src |
1153 | 1153 |
1154 #+name: test-header | 1154 #+name: test-header |
1155 #+begin_src clojure | 1155 #+begin_src clojure |
1156 (ns cortex.test.hearing | 1156 (ns cortex.test.hearing |
1157 (:use (cortex world util hearing)) | 1157 (:use (cortex world util hearing body)) |
1158 (:use cortex.test.body) | 1158 (:use cortex.test.body) |
1159 (:import (com.jme3.audio AudioNode Listener)) | 1159 (:import (com.jme3.audio AudioNode Listener)) |
1160 (:import java.io.File) | |
1160 (:import com.jme3.scene.Node | 1161 (:import com.jme3.scene.Node |
1161 com.jme3.system.AppSettings)) | 1162 com.jme3.system.AppSettings |
1163 com.jme3.math.Vector3f)) | |
1162 #+end_src | 1164 #+end_src |
1163 | 1165 |
1164 * Source Listing | 1166 * Source Listing |
1165 - [[../src/cortex/hearing.clj][cortex.hearing]] | 1167 - [[../src/cortex/hearing.clj][cortex.hearing]] |
1166 - [[../src/cortex/test/hearing.clj][cortex.test.hearing]] | 1168 - [[../src/cortex/test/hearing.clj][cortex.test.hearing]] |