# HG changeset patch # User Robert McIntyre # Date 1323574970 21600 # Node ID cdf320cb594996fcd497ccbb3cdf728d19aa9411 # Parent 1fc162d84343863c014bdd869c7884174bcdfaa1 updated test suite diff -r 1fc162d84343 -r cdf320cb5949 org/ear.org --- a/org/ear.org Sat Nov 19 20:09:50 2011 -0700 +++ b/org/ear.org Sat Dec 10 21:42:50 2011 -0600 @@ -90,7 +90,7 @@ ** =send.c= ** Header -#+srcname: send-header +#+name: send-header #+begin_src C #include "config.h" #include @@ -150,7 +150,7 @@ only one context at a time. ** Necessary State -#+srcname: send-state +#+name: send-state #+begin_src C //////////////////// State @@ -178,7 +178,7 @@ of the actual device state whenever a context is rendered. ** Synchronization Macros -#+srcname: sync-macros +#+name: sync-macros #+begin_src C //////////////////// Context Creation / Synchronization @@ -221,7 +221,7 @@ synchronization code involving these similar low-level =OpenAL= functions. ** Source Synchronization -#+srcname: sync-sources +#+name: sync-sources #+begin_src C void syncSources(ALsource *masterSource, ALsource *slaveSource, ALCcontext *masterCtx, ALCcontext *slaveCtx){ @@ -294,7 +294,7 @@ good description of =OpenAL='s internals. ** Context Synchronization -#+srcname: sync-contexts +#+name: sync-contexts #+begin_src C void syncContexts(ALCcontext *master, ALCcontext *slave){ /* If there aren't sufficient sources in slave to mirror @@ -332,7 +332,7 @@ does not have the same number of sources as the master context. ** Context Creation -#+srcname: context-creation +#+name: context-creation #+begin_src C static void addContext(ALCdevice *Device, ALCcontext *context){ send_data *data = (send_data*)Device->ExtraData; @@ -361,7 +361,7 @@ eventually go. ** Context Switching -#+srcname: context-switching +#+name: context-switching #+begin_src C //////////////////// Context Switching @@ -407,7 +407,7 @@ context separate from all the others. ** Main Device Loop -#+srcname: main-loop +#+name: main-loop #+begin_src C //////////////////// Main Device Loop @@ -464,7 +464,7 @@ by the way LWJGL interfaces with =OpenAL=. *** step -#+srcname: jni-step +#+name: jni-step #+begin_src C //////////////////// JNI Methods @@ -491,7 +491,7 @@ *** getSamples -#+srcname: jni-get-samples +#+name: jni-get-samples #+begin_src C /* * Class: com_aurellem_send_AudioSend @@ -522,7 +522,7 @@ necessary to change the properties of any listener other than the master one, since only the listener of the current active context is affected by the normal =OpenAL= listener calls. -#+srcname: listener-manage +#+name: listener-manage #+begin_src C /* * Class: com_aurellem_send_AudioSend @@ -589,7 +589,7 @@ =javax.sound.sampled.AudioFormat= object from data in the Device. This way, there is no ambiguity about what the bits created by =step= and returned by =getSamples= mean. -#+srcname: jni-init +#+name: jni-init #+begin_src C /* * Class: com_aurellem_send_AudioSend @@ -642,7 +642,7 @@ ** Boring Device management stuff This code is more-or-less copied verbatim from the other =OpenAL= backends. It's the basis for =OpenAL='s primitive object system. -#+srcname: device-init +#+name: device-init #+begin_src C //////////////////// Device Initialization / Management @@ -749,7 +749,7 @@ #+include "../../jmeCapture/src/com/aurellem/capture/audio/SoundProcessor.java" src java -#+srcname: ears +#+name: ears #+begin_src clojure (ns cortex.hearing "Simulate the sense of hearing in jMonkeyEngine3. Enables multiple @@ -795,12 +795,13 @@ * Example -#+srcname: test-hearing +#+name: test-hearing #+begin_src clojure :results silent -(ns test.hearing +(ns cortex.test.hearing (:use (cortex world util hearing)) (:import (com.jme3.audio AudioNode Listener)) - (:import com.jme3.scene.Node)) + (:import com.jme3.scene.Node + com.jme3.system.AppSettings)) (defn setup-fn [world] (let [listener (Listener.)] @@ -812,17 +813,30 @@ (.playSource (.getAudioRenderer world) node)))) (defn test-basic-hearing [] - (.start (let [node1 (AudioNode. (asset-manager) "Sounds/pure.wav" false false)] (world (Node.) {"key-space" (partial play-sound node1)} setup-fn - no-op)))) + no-op))) + +(defn test-advanced-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))) + #+end_src This extremely basic program prints out the first sample it encounters -at every time stamp. You can see the rendered sound begin printed at +at every time stamp. You can see the rendered sound being printed at the REPL. - As a bonus, this method of capturing audio for AI can also be used @@ -836,11 +850,10 @@ <> #+end_src -#+begin_src clojure :tangle ../../cortex/src/test/hearing.clj +#+begin_src clojure :tangle ../../cortex/src/cortex/test/hearing.clj <> #+end_src - #+begin_src C :tangle ../Alc/backends/send.c <> <>