comparison org/hearing.org @ 273:c39b8b29a79e

fixed ambigous in-text function references
author Robert McIntyre <rlm@mit.edu>
date Wed, 15 Feb 2012 06:56:47 -0700
parents f1a74d23e7e4
children 23aadf376e9d
comparison
equal deleted inserted replaced
271:5833b4ce877a 273:c39b8b29a79e
774 hearing abstraction is simple and closely parallels the [[./vision.org][vision]] 774 hearing abstraction is simple and closely parallels the [[./vision.org][vision]]
775 abstraction. 775 abstraction.
776 776
777 ** Hearing Pipeline 777 ** Hearing Pipeline
778 778
779 All sound rendering is done in the CPU, so =(hearing-pipeline)= is 779 All sound rendering is done in the CPU, so =hearing-pipeline= is
780 much less complicated than =(vision-pipelie)= The bytes available in 780 much less complicated than =vision-pipelie= The bytes available in
781 the ByteBuffer obtained from the =send= Device have different meanings 781 the ByteBuffer obtained from the =send= Device have different meanings
782 dependant upon the particular hardware or your system. That is why 782 dependant upon the particular hardware or your system. That is why
783 the =AudioFormat= object is necessary to provide the meaning that the 783 the =AudioFormat= object is necessary to provide the meaning that the
784 raw bytes lack. =(byteBuffer->pulse-vector)= uses the excellent 784 raw bytes lack. =byteBuffer->pulse-vector= uses the excellent
785 conversion facilities from [[http://www.tritonus.org/ ][tritonus]] ([[http://tritonus.sourceforge.net/apidoc/org/tritonus/share/sampled/FloatSampleTools.html#byte2floatInterleaved%2528byte%5B%5D,%2520int,%2520float%5B%5D,%2520int,%2520int,%2520javax.sound.sampled.AudioFormat%2529][javadoc]]) to generate a clojure vector of 785 conversion facilities from [[http://www.tritonus.org/ ][tritonus]] ([[http://tritonus.sourceforge.net/apidoc/org/tritonus/share/sampled/FloatSampleTools.html#byte2floatInterleaved%2528byte%5B%5D,%2520int,%2520float%5B%5D,%2520int,%2520int,%2520javax.sound.sampled.AudioFormat%2529][javadoc]]) to generate a clojure vector of
786 floats which represent the linear PCM encoded waveform of the 786 floats which represent the linear PCM encoded waveform of the
787 sound. With linear PCM (pulse code modulation) -1.0 represents maximum 787 sound. With linear PCM (pulse code modulation) -1.0 represents maximum
788 rarefaction of the air while 1.0 represents maximum compression of the 788 rarefaction of the air while 1.0 represents maximum compression of the
789 air at a given instant. 789 air at a given instant.
820 820
821 ** Physical Ears 821 ** Physical Ears
822 822
823 Together, these three functions define how ears found in a specially 823 Together, these three functions define how ears found in a specially
824 prepared blender file will be translated to =Listener= objects in a 824 prepared blender file will be translated to =Listener= objects in a
825 simulation. =(ears)= extracts all the children of to top level node 825 simulation. =ears= extracts all the children of to top level node
826 named "ears". =(add-ear!)= and =(update-listener-velocity!)= use 826 named "ears". =add-ear!= and =update-listener-velocity!= use
827 =(bind-sense)= to bind a =Listener= object located at the initial 827 =bind-sense= to bind a =Listener= object located at the initial
828 position of an "ear" node to the closest physical object in the 828 position of an "ear" node to the closest physical object in the
829 creature. That =Listener= will stay in the same orientation to the 829 creature. That =Listener= will stay in the same orientation to the
830 object with which it is bound, just as the camera in the [[http://aurellem.localhost/cortex/html/sense.html#sec-4-1][sense binding 830 object with which it is bound, just as the camera in the [[http://aurellem.localhost/cortex/html/sense.html#sec-4-1][sense binding
831 demonstration]]. =OpenAL= simulates the doppler effect for moving 831 demonstration]]. =OpenAL= simulates the doppler effect for moving
832 listeners, =(update-listener-velocity!)= ensures that this velocity 832 listeners, =update-listener-velocity!= ensures that this velocity
833 information is always up-to-date. 833 information is always up-to-date.
834 834
835 #+name: hearing-ears 835 #+name: hearing-ears
836 #+begin_src clojure 836 #+begin_src clojure
837 (defvar 837 (defvar
903 [#^Node creature] 903 [#^Node creature]
904 (for [ear (ears creature)] 904 (for [ear (ears creature)]
905 (hearing-kernel creature ear))) 905 (hearing-kernel creature ear)))
906 #+end_src 906 #+end_src
907 907
908 Each function returned by =(hearing-kernel!)= will register a new 908 Each function returned by =hearing-kernel!= will register a new
909 =Listener= with the simulation the first time it is called. Each time 909 =Listener= with the simulation the first time it is called. Each time
910 it is called, the hearing-function will return a vector of linear PCM 910 it is called, the hearing-function will return a vector of linear PCM
911 encoded sound data that was heard since the last frame. The size of 911 encoded sound data that was heard since the last frame. The size of
912 this vector is of course determined by the overall framerate of the 912 this vector is of course determined by the overall framerate of the
913 game. With a constant framerate of 60 frames per second and a sampling 913 game. With a constant framerate of 60 frames per second and a sampling