(ns cortex.test.hearing (:use (cortex world util hearing body)) (:use cortex.test.body) (:import (com.jme3.audio AudioNode Listener)) (:import java.io.File) (:import com.jme3.scene.Node com.jme3.system.AppSettings com.jme3.math.Vector3f) (:import (com.aurellem.capture Capture IsoTimer RatchetTimer))) (in-ns 'cortex.test.hearing) (defn test-java-hearing "Testing hearing: You should see a blue sphere flying around several cubes. As the sphere approaches each cube, it turns green." [] (doto (com.aurellem.capture.examples.Advanced.) (.setSettings (doto (AppSettings. true) (.setAudioRenderer "Send"))) (.setShowSettings false) (.setPauseOnLostFocus false))) (in-ns 'cortex.test.hearing) (defn test-worm-hearing "Testing hearing: You will see the worm fall onto a table. There is a long horizontal bar which shows the waveform of whatever the worm is hearing. When you play a sound, the bar should display a waveform. Keys: : play sound l : play hymn" ([] (test-worm-hearing false)) ([record?] (let [the-worm (doto (worm) (body!)) hearing (hearing! the-worm) hearing-display (view-hearing) tone (AudioNode. (asset-manager) "Sounds/pure.wav" false) hymn (AudioNode. (asset-manager) "Sounds/ear-and-eye.wav" false)] (world (nodify [the-worm (floor)]) (merge standard-debug-controls {"key-return" (fn [_ value] (if value (.play tone))) "key-l" (fn [_ value] (if value (.play hymn)))}) (fn [world] (light-up-everything world) (let [timer (IsoTimer. 60)] (.setTimer world timer) (display-dilated-time world timer)) (if record? (do (com.aurellem.capture.Capture/captureVideo world (File. "/home/r/proj/cortex/render/worm-audio/frames")) (com.aurellem.capture.Capture/captureAudio world (File. "/home/r/proj/cortex/render/worm-audio/audio.wav"))))) (fn [world tpf] (hearing-display (map #(% world) hearing) (if record? (File. "/home/r/proj/cortex/render/worm-audio/hearing-data"))))))))