chp-state.sgml 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731
  1. <chapter id="state-requests">
  2. <title>State and State Requests</title>
  3. <para>
  4. The majority of &AL; state is associated with individual &AL; objects,
  5. and has to be set and queried referencing the objects. However, some
  6. state - e.g. processing errors - is
  7. defined context specific. &AL; has global state that affects all
  8. objects and processing equally. This state is set using a variety
  9. of functions, and
  10. can be queried using query functions. The majority of queries
  11. has to use the interface described in "Simple Queries".
  12. </para>
  13. <sect1 id="state-query">
  14. <title>Querying &AL; State</title>
  15. <sect2>
  16. <title>Simple Queries</title>
  17. <para>
  18. Like &OGL;, &AL; uses a simplified interface for querying global
  19. state. The following functions accept a set of enumerations.
  20. <funcsynopsis><funcprototype>
  21. <funcdef> void <function> GetBooleanv </function></funcdef>
  22. <paramdef> &enum; <parameter> paramName </parameter></paramdef>
  23. <paramdef> &bool;* <parameter> dest </parameter></paramdef>
  24. </funcprototype></funcsynopsis>
  25. <funcsynopsis><funcprototype>
  26. <funcdef> void <function> GetIntegerv </function></funcdef>
  27. <paramdef> &enum; <parameter> paramName </parameter></paramdef>
  28. <paramdef> &int;* <parameter> dest </parameter></paramdef>
  29. </funcprototype></funcsynopsis>
  30. <funcsynopsis><funcprototype>
  31. <funcdef> void <function> GetFloatv </function></funcdef>
  32. <paramdef> &enum; <parameter> paramName </parameter></paramdef>
  33. <paramdef> &float;* <parameter> dest </parameter></paramdef>
  34. </funcprototype></funcsynopsis>
  35. <funcsynopsis><funcprototype>
  36. <funcdef> void <function> GetDoublev </function></funcdef>
  37. <paramdef> &enum; <parameter> paramName </parameter></paramdef>
  38. <paramdef> &double;* <parameter> dest </parameter></paramdef>
  39. </funcprototype></funcsynopsis>
  40. Legal values are e.g. DOPPLER_FACTOR, DOPPLER_VELOCITY, DISTANCE_MODEL.
  41. </para>
  42. <para>
  43. NULL destinations are quietly ignored. INVALID_ENUM is the
  44. response to errors in specifying paramName. The amount of memory
  45. required in the destination depends on the actual state requested.
  46. Usually, state variables are returned in only one or some of the
  47. formats above.
  48. </para>
  49. <para>
  50. To query state controlled by Enable/Disable there is an additional
  51. IsEnabled function defined (see "Controlling &AL; Execution").
  52. </para>
  53. </sect2>
  54. <sect2>
  55. <title>Data Conversions</title>
  56. <para>
  57. If a Get command is issued that returns value types different from
  58. the type of the value being obtained, a type converswion is
  59. performed. If GetBooleanv is called, a floating-point or integer
  60. value converts to FALSE if and only if it is zero (otherwise
  61. it converts to TRUE). If GetIntegerv is called, a boolean value
  62. is interpreted as either 1 or 0, and a floating-point value is
  63. rounded to the nearest integer. If GetFloatv is called, a boolean
  64. value is interpreted as either 1.0 or 0.0, an integer is
  65. coerced to floating point, and a double-presicion foating-point
  66. value is converted to single precision. Analogous conversions are
  67. carried out in the case of GetDoublev. If a value is so large
  68. in magnitude that it cannot be represented with the requested
  69. type, then the nearest value is representable using the requested
  70. type is returned.
  71. </para>
  72. <![ %Annote [
  73. <note><title>Annotation (Query of Modes)</title><para>
  74. Modes (e.g. the current distance model) can be queried
  75. using the respective tokens. The recommended query
  76. command is GetIntegerv.
  77. </para></note>
  78. ]]>
  79. </sect2>
  80. <sect2>
  81. <title>String Queries</title>
  82. <para>
  83. The application can retrieve state information global to the current
  84. &AL; Context. GetString will return a pointer to a constant string.
  85. Valid values for param are VERSION, RENDERER, VENDOR, and EXTENSIONS,
  86. as well as the error codes defined by &AL;. The application can
  87. use GetString to retrieve a string for an error code.
  88. <funcsynopsis><funcprototype>
  89. <funcdef> const &ubyte;* <function> GetString </function></funcdef>
  90. <paramdef> &enum; <parameter> paramName</parameter></paramdef>
  91. </funcprototype></funcsynopsis>
  92. </para>
  93. </sect2>
  94. </sect1>
  95. <sect1 id="time">
  96. <title>Time and Frequency</title>
  97. <para>
  98. By default, &AL; uses seconds and Hertz as units for
  99. time and frequency, respectively.
  100. A float or integral value of one
  101. for a variable that specifies quantities like duration,
  102. latency, delay, or any other parameter measured as time,
  103. specifies 1 second.
  104. For frequency, the basic unit is 1/second, or Hertz.
  105. In other words, sample frequencies and frequency
  106. cut-offs or filter parameters specifying frequencies
  107. are expressed in units of Hertz.
  108. </para>
  109. <![ %RFC [
  110. <note id="rfc-bk000927-01"><title>RFC: Query and Factor?</title><para>
  111. Will time be an &AL; state that can be queried and scaled?
  112. &AL; usually (always) implements a real-time
  113. process with the constraint that it has to be
  114. synchronized with the time as experienced by the user.
  115. Do the units used with respect to time and frequency have
  116. a fixed meaning?
  117. </para></note>
  118. ]]>
  119. <![ %RFC [
  120. <note id="rfc-bk000803-03"><title>RFC: Setting Time/Long</title><para>
  121. Given a frequency range from a few Hz to 50kHz or more,
  122. we need a temporal resolution of 20 microseconds or less.
  123. For simplicity that means we either resolve Milliseconds
  124. and loose precision, or we resolve microseconds.
  125. Applications might run hours or days, which is 10E5 seconds
  126. or more. If we cover 12 orders of magnitude (10E6 to 10E-6)
  127. 32bit unsigned integer will not suffice. Do we introduce
  128. a 64 signed integer for the purpose of specifying time
  129. over a duration of several days at microseconds resolution,
  130. or do we use two 32bit integers, and how do we split them?
  131. </para></note>
  132. ]]>
  133. <![ %RFC [
  134. <note id="rfc-bk000806-03"><title>RFC: Duration Query</title>
  135. <para>
  136. The application might want to cull Sources based on
  137. how many milliseconds are left for their current buffer
  138. or queue (either to stop those that will stop soon
  139. anyway, or to stop those that will take too long,
  140. depending).
  141. </para>
  142. <para>
  143. We need to divorce sample (memory) count from duration,
  144. because of compression and differences between
  145. internal and external sample format.
  146. </para>
  147. <para>
  148. Duration can be queried in microsecond resolution in
  149. case we want to account for O(10Khz) sampling
  150. frequencies properly, or milliseconds if we
  151. do not anticipate the need to go beyond typical
  152. operating system time resolution.
  153. </para>
  154. <para>
  155. We need query as double, float, and possibly
  156. long (as of now an undefined data type).
  157. We might need an INVALID_RANGE error on the getter,
  158. especially if large reptition counters can be set.
  159. For paused source, the remainder will be the same
  160. as for playing sources. The application can query
  161. the Source State to find out the additional
  162. information. INFINITE is not needed,
  163. no is UNKNOWN as we operate on known
  164. queues.
  165. </para></note>
  166. ]]>
  167. <![ %Scratch [
  168. <![ %Annote [
  169. <note><title>Annotation (Buffer vs. Queue Duration)</title><para>
  170. Sourcel( sName , REMAINDER, &amp;rem ) queries the remainder
  171. for the current buffer (zero if the Source is STOPPED,
  172. duration of the first buffer if the source is INITIAL).
  173. Sourcel( sName, REMAINDER_QUEUE, &amp;rem ) queries the remainder
  174. of the entire queue.
  175. A STOPPED Source has remainder==0.
  176. An INITIAL Source has full remainder.
  177. </para></note>
  178. ]]>
  179. <![ %Annote [
  180. <note><title>Annotation (DURATION vs. REMAINDER)</title><para>
  181. DURATION is a buffer attribute independent of
  182. execution state. REMAINDER is a Source attribute
  183. that encapsulates part of the execution state.
  184. Sources and Buffers should not share these attributes:
  185. there is no Buffer REMAINDER and no Source DURATION.
  186. </para></note>
  187. ]]>
  188. ]]>
  189. </sect1>
  190. <sect1 id="scaling">
  191. <title>Space and Distance</title>
  192. <para>
  193. &AL; does not define the units of measurement for distances.
  194. The application is free to use meters, inches, or parsecs.
  195. &AL; provides means for simulating the natural attenuation
  196. of sound according to distance, and to exagerate or reduce
  197. this effect. However, the resulting effects do not depend on
  198. the distance unit used by the application to express source
  199. and listener coordinates. &AL; calculations are scale
  200. invariant.
  201. </para>
  202. <para>
  203. The specification assumes Euclidean calculation of
  204. distances, and mandates that if two Sources are
  205. sorted with respect to the Euclidean metric, the
  206. distance calculation used by the implementation has
  207. to preserve that order.
  208. </para>
  209. <![ %Annote [
  210. <note><title>Annotation (No DistanceFactor)</title><para>
  211. &AL; does not provide a global, per Context DISTANCE_FACTOR,
  212. as all calculations are scale invariant.
  213. </para></note>
  214. ]]>
  215. <![ %Annote [
  216. <note><title>Annotation (Distance Calculations)</title><para>
  217. The specification does not enforce that distances
  218. are calculated using the euclidean norm, to permit
  219. using computationally cheaper approximations.
  220. Implementations that opt to use approximations
  221. might cause audible artifacts. The specification does
  222. not enforce any upper limits on distance calculation
  223. errors yet.
  224. </para></note>
  225. ]]>
  226. <![ %RFC [
  227. <note id="rfc-bk000915-02"><title>RFC: Limiting Errors</title><para>
  228. Do we limit permissible errors on distance or gain
  229. calculations? How much quality
  230. and accuracy do we expect from conformant implementations?
  231. </para></note>
  232. ]]>
  233. <![ %Annote [
  234. <note><title>Annotation (DS3D DistanceFactor)</title><para>
  235. The DS3D documentation explicitely states that the default
  236. unit is 1 meter. &AL; does not specify any units.
  237. &AL; calculations are scale invariant. The main purpose
  238. of the DS3D DistanceFactor (modifying Doppler Shift
  239. by scaling velocity but not reference velocity) is
  240. accomplished using DOPPLER_VELOCITY in &AL;. &AL;
  241. does not have an equivalent to A3D's SetUnitsPerMeter
  242. either.
  243. <!-- http://msdn.microsoft.com/library/psdk/directx/dsover_6jj8.htm -->
  244. </para></note>
  245. ]]>
  246. </sect1>
  247. <sect1 id="attenuation-by-distance">
  248. <title>Attenuation By Distance</title>
  249. <para>
  250. Samples usually use the entire dynamic range of the
  251. chosen format/encoding, independent of their real world
  252. intensity. In other words, a jet engine and a clockwork
  253. both will have samples with full amplitude. The application
  254. will then have to adjust Source GAIN accordingly to account
  255. for relative differences.
  256. </para>
  257. <para>
  258. Source GAIN is then attenuated by distance.
  259. The effective attenuation of a Source depends on many
  260. factors, among which distance attenuation and source
  261. and Listener GAIN are only some of the contributing
  262. factors. Even if the source and Listener GAIN exceed 1.0
  263. (amplification beyond the guaranteed dynamic range),
  264. distance and other attenuation might ultimately limit
  265. the overall GAIN to a value below 1.0.
  266. </para>
  267. <para>
  268. &AL; currently supports three modes of operation
  269. with respect to distance attenuation. It supports
  270. two distance-dependent attenuation models, including one
  271. that is similar to the IASIG I3DL2 (and DS3D) model.
  272. The application chooses one of these two models (or
  273. chooses to disable distance-dependent attenuation)
  274. on a per-context basis.
  275. <funcsynopsis><funcprototype>
  276. <funcdef> void <function> DistanceModel </function></funcdef>
  277. <paramdef> &enum; <parameter> modelName </parameter></paramdef>
  278. </funcprototype></funcsynopsis>
  279. Legal arguments are NONE, INVERSE_DISTANCE, and
  280. INVERSE_DISTANCE_CLAMPED. NONE bypasses all distance
  281. attenuation calculation for all Sources. The implementation
  282. is expected to optimize this situation. INVERSE_DISTANCE_CLAMPED
  283. is the DS3D model, with REFERENCE_DISTANCE indicating both the
  284. reference distance and the distance below which gain will
  285. be clamped. INVERSE_DISTANCE is equivalent to the DS3D model
  286. with the exception that REFERENCE_DISTANCE does not imply any
  287. clamping. The &AL; implementation is still free to apply
  288. any range clamping as necessary. The current distance model
  289. chosen can be queried using GetIntegerv and DISTANCE_MODEL.
  290. </para>
  291. <![ %Annote [
  292. <note><title>Annotation (Inverse Square Law)</title><para>
  293. The "inverse square law" used in physics applies to sound
  294. intensity (energy), which is proportional to the square
  295. of linear gain (amplitude). Thus the inverse distance model
  296. describes a physically correct inverse square behavior
  297. if ROLLOFF_FACTOR is set to 1.0.
  298. </para></note>
  299. ]]>
  300. <![ %Annote [
  301. <note><title>Annotation (Enable/Disable Attenuation)</title><para>
  302. As ROLLOFF_FACTOR is a per-Source attribute, setting it to zero
  303. can not be used to globally enable or disable distance
  304. attenuation, which (e.g. when using tables) can be resource
  305. intensive. Using Enable/Disable/IsEnabled with a DISTANCE_ATTENUATION
  306. token is redundant with respect to the possibility that support
  307. for different distance models might be desired at a later time.
  308. </para></note>
  309. ]]>
  310. <sect2>
  311. <title>Inverse Distance Rolloff Model</title>
  312. <para>
  313. The following formula describes the distance attenutation
  314. defined by the Rolloff Attenutation Model, as logarithmic
  315. calculation.
  316. <literallayout>
  317. G_dB = GAIN - 20*log10(1 + ROLLOFF_FACTOR*(dist-REFERENCE_DISTANCE)/REFERENCE_DISTANCE );
  318. G_dB = min(G_dB,MAX_GAIN);
  319. G_dB = max(G_dB,MIN_GAIN);
  320. </literallayout>
  321. The REFERENCE_DISTANCE parameter used here is a per-Source attribute
  322. that can be set and queried using the REFERENCE_DISTANCE token.
  323. REFERENCE_DISTANCE is the distance at which the Listener will
  324. experience GAIN (unless the implementation had to clamp effective
  325. GAIN to the available dynamic range).
  326. ROLLOFF_FACTOR is per-Source parameter the application can use
  327. to increase or decrease the range of a source by decreasing
  328. or increasing the attenuation, respectively. The default value
  329. is 1. The implementation is free to optimize for a
  330. ROLLOFF_FACTOR value of 0, which indicates that the application
  331. does not wish any distance attenuation on the respective Source.
  332. </para>
  333. <![ %Annote [
  334. <note><title>Annotation (Linear Calculation)</title><para>
  335. The logarithmic formula above is equivalent to
  336. <literallayout>
  337. G = gain_linear / ( 1 + ROLLOFF_FACTOR*((dist-REFERENCE_DISTANCE)/REFERENCE_DISTANCE) );
  338. G = min(G,max_gain_linear);
  339. G = max(G,min_gain_linear);
  340. </literallayout>
  341. with linear gains calculated from the logarithmic GAIN,
  342. MIN_GAIN, MAX_GAIN accordingly.
  343. By means of explanation: linear GAIN is applied to the sample, which describes
  344. an amplitude ultimately (DAC) converted into voltage. The actual power of the
  345. signal is proportional to the square of the amplitude (voltage). Logarithmic
  346. measurement is done by comparing the actual power with a reference value,
  347. i.e. the power (e.g in Watt) at the reference distance. The original Bel unit
  348. of measure (named after Alexander Graham Bell) was defined to account for the
  349. logarithmic response of the human ear: our subjective impression of "loudness"
  350. is not linear in the power of the acoustic signal. For practical purposes (range
  351. of volumes the human ear can handle) the deciBel (dB) is a better unit:
  352. <literallayout>
  353. dB = 10 * log( P/P0 ) = 10 * log( sqr(A/A0 ) = 20 * log( A/A0 )
  354. </literallayout>
  355. Common power/amplitude ratios and attenuations per distance are:
  356. <table>
  357. <title>Logarithmic Scale and Gain</title>
  358. <tgroup cols="4" align="left" colsep=1 rowsep=1>
  359. <thead>
  360. <row>
  361. <entry>Distance</>
  362. <entry>Attenuation</>
  363. <entry>Power Ratio</>
  364. <entry>Amplitude Ratio</>
  365. </row>
  366. </thead>
  367. <tbody>
  368. <row>
  369. <entry>REF</>
  370. <entry> 0dB </>
  371. <entry> 1:1 </>
  372. <entry> 1:1 </>
  373. </row>
  374. <row>
  375. <entry> 2*REF </>
  376. <entry> -6dB </>
  377. <entry> 1:4 </>
  378. <entry> 1:2 </>
  379. </row>
  380. <row>
  381. <entry> 4*REF </>
  382. <entry> -12dB </>
  383. <entry> 1:16 </>
  384. <entry> 1:4 </>
  385. </row>
  386. <row>
  387. <entry> 8*REF </>
  388. <entry> -18dB </>
  389. <entry> 1:64 </>
  390. <entry> 1:8 </>
  391. </row>
  392. <row>
  393. <entry> 0.5*REF </>
  394. <entry> 6dB </>
  395. <entry> 2:1 </>
  396. <entry> 4:1 </>
  397. </row>
  398. <row>
  399. <entry> 0.25*REF </>
  400. <entry> 12dB </>
  401. <entry> 4:1 </>
  402. <entry> 16:1 </>
  403. </row>
  404. </tbody>
  405. </tgroup>
  406. </table>
  407. The logarithmic gain will drop from zero (linear gain 1) to negative infinity
  408. (approaching linear gain 0). A linear gain of zero can not be represented
  409. logarithmically. Any doubling of the reference distance will add another
  410. -6dB (i.e. 6dB of attenuation). This approximates an inverse square law falloff
  411. of signal power with distance, as long as the distance exceeds the reference
  412. distance.
  413. </para></note>
  414. ]]>
  415. <![ %Annote [
  416. <note><title>Annotation (Rolloff quantization)</title><para>
  417. Implementations that use lookup tables to speed up
  418. distance attenuation calculation may opt to map
  419. ROLLOFF_FACTOR to a limited set of internally used
  420. values, to minimize expense of per-Source calculations
  421. and setup/memory costs.
  422. </para></note>
  423. ]]>
  424. <![ %Annote [
  425. <note><title>Annotation (Gain Clamping)</title><para>
  426. In the absence of user MIN_GAIN and MAX_GAIN selections,
  427. clamping is implied by implementation constraints, and
  428. clamping behavior might change.
  429. The &AL; implementation should not clamp intermediate
  430. values of effective gain to unit range.
  431. Any clamping, if necessary, should be applied at the latest
  432. possible stage. In other words, GAIN&gt;1 is perfectly
  433. valid as the implementation is free to clamp the value as
  434. needed for maximum mixing accuracy and to account for the
  435. actual dynamic range of the output device.
  436. </para></note>
  437. ]]>
  438. <![ %Annote [
  439. <note><title>Annotation (Extended Dynamic Range)</title><para>
  440. For applications that
  441. change GAIN but do not want to adjust ROLLOFF_FACTOR
  442. and REFERENCE_DISTANCE to account for different ranges,
  443. the separation in this distance model might allow for
  444. more intuitive adjustments:
  445. If we put a damper on the jet engine by lowering GAIN,
  446. we still want the listener to perceive the full volume,
  447. but now at a closer distance, without changing the
  448. reference distance.
  449. </para></note>
  450. ]]>
  451. </sect2>
  452. <sect2>
  453. <title>Inverse Distance Clamped Model</title>
  454. <para>
  455. This is essentially the Inverse Distance model,
  456. extended to guarantee that for distances below
  457. REFERENCE_DISTANCE, gain is clamped. This mode
  458. is equivalent to the IASIG I3DL2 (and DS3D) distance
  459. model.
  460. <literallayout>
  461. dist = max(dist,REFERENCE_DISTANCE);
  462. dist = min(dist,MAX_DISTANCE);
  463. G_dB = GAIN - 20*log10(1 + ROLLOFF_FACTOR*(dist-REFERENCE_DISTANCE)/REFERENCE_DISTANCE )
  464. G_dB = min(G_dB,MAX_GAIN);
  465. G_dB = max(G_dB,MIN_GAIN);
  466. </literallayout>
  467. </para>
  468. <![ %Annote [
  469. <note><title>Annotation (DS3D MIN_DISTANCE)</title><para>
  470. The DS3D attenuation model is extended by an explicit
  471. clamping mechanism. REFERENCE_DISTANCE is equivalent
  472. to DS3D MIN_DISTANCE if the INVERSE_DISTANCE_CLAMPED
  473. mode is used.
  474. </para></note>
  475. ]]>
  476. <![ %Annote [
  477. <note><title>Annotation (High Frequency Rolloff)</title><para>
  478. To simulate different atmospheric conditions, a frequency
  479. dependent attenuation is used in A3D and EAX.
  480. At this time &AL; does not have a mechanism to specify
  481. lowpass filtering parameterized by distance.
  482. </para></note>
  483. ]]>
  484. </sect2>
  485. </sect1>
  486. <sect1 id="order-distance">
  487. <title>Evaluation of Gain/Attenuation Related State</title>
  488. <para>
  489. While amplification/attenuation commute (mulplication of
  490. scaling factors), clamping operations do not. The order
  491. in which various gain related operations are applied is:
  492. Distance attenuation is calculated first, including
  493. minimum (REFERENCE_DISTANCE) and maximum (MAX_DISTANCE)
  494. thresholds. If the Source is directional (CONE_INNER_ANGLE
  495. less than CONE_OUTER_ANGLE), an angle-dependent attenuation
  496. is calculated depending on CONE_OUTER_GAIN, and multiplied
  497. with the distance dependent attenuation.
  498. The resulting attenuation factor for the given angle and
  499. distance between Listener and Source is multiplied
  500. with Source GAIN. The effective GAIN computed this way
  501. is compared against MIN_GAIN and MAX_GAIN thresholds.
  502. The result is guaranteed to be clamped to [MIN_GAIN, MAX_GAIN],
  503. and subsequently multiplied by Listener GAIN which serves
  504. as an overall volume control. The implementation is free
  505. to clamp Listener GAIN if necessary due to hardware or
  506. implementation constraints.
  507. </para>
  508. </sect1>
  509. <sect1 id="culling-by-distance">
  510. <title>No Culling By Distance</title>
  511. <para>
  512. With the DS3D compatible Inverse Clamped Distance Model,
  513. &AL; provides a per-Source MAX_DISTANCE attribute
  514. that can be used to define a distance beyond which the Source will
  515. not be further attenuated by distance.
  516. The DS3D distance attenuation model and its clamping of volume
  517. is also extended by a mechanism to cull (mute) sources from proccessing,
  518. based on distance. However, &AL; does not
  519. support culling a Source from processing based on a distance
  520. threshold.
  521. </para>
  522. <para>
  523. At this time &AL; is not meant to support culling at all. Culling
  524. based on distance, or bounding volumes, or other criteria, is best
  525. left to the application. For example, the application might
  526. employ sophisticated techniques to determine whether sources
  527. are audible that are beyond the scope of &AL;. In particular,
  528. rule based culling inevitably introduces acoustic artifacts.
  529. E.g. if the Listener-Source distance is nearly equal to the
  530. culling threshold distance, but varies above and below, there
  531. will be popping artifacts in the absence of hysteresis.
  532. </para>
  533. <![ %Annote [
  534. <note><title>Annotation (No MAX_DISTANCE plus MUTE)</title><para>
  535. &AL; does support the AUDIBLE mode with MAX_DISTANCE (clamping),
  536. but does not support culling. Applications that employ this
  537. DS3D feature will have to perform their own distance calculation
  538. and mute the source (Source GAIN equals zero) as desired.
  539. </para></note>
  540. ]]>
  541. <![ %RFC [
  542. <note id="rfc-bk000803-07"><title>RFC: DS3D-like Extension</title><para>
  543. For ease of portability, should we define an Extension that
  544. provides MAX_DISTANCE for MUTE mode?
  545. </para></note>
  546. ]]>
  547. </sect1>
  548. <![ %Scratch [
  549. <sect1 id="sound-speed">
  550. <title>NO Sound Propagation Speed</title>
  551. <para>
  552. &AL; implementations can choose to model sound propagation with
  553. limited speed for certain effects, e.g. early reflections.
  554. In addition, the Doppler Effect is defined with respect to the
  555. speed of sound in the predominant medium. The application can
  556. set the speed of sound as a scalar value. The speed is defined
  557. with respect to the scaled unit. If D I S T A N C E _ S C A L E is changed,
  558. this will affect both the distance and the propagation speed,
  559. leaving the propagation time unaffected.
  560. <funcsynopsis><funcprototype>
  561. <funcdef> void <function> PropagationSpeed </function></funcdef>
  562. <paramdef> &float; <parameter> propSpeed </parameter></paramdef>
  563. </funcprototype></funcsynopsis>
  564. </para>
  565. <para>
  566. A negative scale will result in an INVALID_VALUE error, the
  567. command is then ignored. The default value is 1. The current
  568. setting can be queried using GetFloatv and PROPAGATION_SPEED.
  569. </para>
  570. </sect1>
  571. ]]>
  572. <sect1 id="doppler-scale">
  573. <title>Velocity Dependent Doppler Effect</title>
  574. <para>
  575. The Doppler Effect depends on the velocities of Source and
  576. Listener relative to the medium, and the propagation speed
  577. of sound in that medium. The application might want to
  578. emphasize or de-emphasize the Doppler Effect as physically
  579. accurate calculation might not give the desired results. The
  580. amount of frequency shift (pitch change) is proportional
  581. to the speed of listener and source along their line of
  582. sight. The application can increase or decrease that
  583. frequency shift by specifying the scaling factor &AL;
  584. should apply to the result of the calculation.
  585. </para>
  586. <para>
  587. The Doppler Effect as implemented by &AL; is described
  588. by the formula below. Effects of the medium (air, water)
  589. moving with respect to listener and source are ignored.
  590. DOPPLER_VELOCITY is the propagation speed relative to
  591. which the Source velocities are interpreted.
  592. <literallayout>
  593. VD: DOPPLER_VELOCITY
  594. DF: DOPPLER_FACTOR
  595. vl: Listener velocity (scalar, projected on source-listener vector)
  596. vs: Source velocity (scalar, projected on source-listener vector)
  597. f: Frequency of sample
  598. f': effective Doppler shifted frequency
  599. f' = DF * f * (VD-vl)/(VD+vs)
  600. vl<0, vs>0 : source and listener approaching each other
  601. vl>0, vs<0 : source and listener moving away from each other
  602. </literallayout>
  603. The implementation has to clamp the projected Listener
  604. velocity vl, if abs(vl) is greater or equal to VD. It similarly has to
  605. clamp the projected Source velocity vs if abs(vs) is greater or equal
  606. to VD.
  607. </para>
  608. <para>
  609. There are two API calls global to the current context that provide
  610. control of the two related parameters. DOPPLER_FACTOR is a simple
  611. scaling to exaggerate or deemphasize the Doppler (pitch) shift
  612. resulting from the calculation.
  613. <funcsynopsis><funcprototype>
  614. <funcdef> void <function> DopplerFactor </function></funcdef>
  615. <paramdef> &float; <parameter> dopplerFactor </parameter></paramdef>
  616. </funcprototype></funcsynopsis>
  617. A negative value will result in an INVALID_VALUE error, the
  618. command is then ignored. The default value is 1. The current
  619. setting can be queried using GetFloatv and DOPPLER_FACTOR.
  620. The implementation is free to optimize the case of DOPPLER_FACTOR
  621. being set to zero, as this effectively disables the effect.
  622. </para>
  623. <![ %Annote [
  624. <note><title>Annotation (No Enable)</title><para>
  625. There is currently no mechanism to switch on/off Doppler
  626. calculation using e.g. a DOPPLER_SHIFT token and Enable/Disable.
  627. For the time being, DopplerFactor(0) may be used to signal
  628. to the implementation that no Doppler Effect calculation is
  629. required.
  630. </para></note>
  631. ]]>
  632. <para>
  633. DOPPLER_VELOCITY allows the application to change the
  634. reference (propagation) velocity used in the Doppler Effect
  635. calculation. This permits the application to use a velocity
  636. scale appropriate to its purposes.
  637. <funcsynopsis><funcprototype>
  638. <funcdef> void <function> DopplerVelocity </function></funcdef>
  639. <paramdef> &float; <parameter> dopplerVelocity</parameter></paramdef>
  640. </funcprototype></funcsynopsis>
  641. A negative or zero value will result in an INVALID_VALUE error, and the
  642. command is ignored. The default value is 1.
  643. The current setting can be queried using GetFloatv and DOPPLER_VELOCITY.
  644. </para>
  645. <![ %Annote [
  646. <note><title>Annotation (No Sideeffects on Delay)</title><para>
  647. To permit independent control of Doppler Effect as opposed
  648. to other, sound wave propagation related effects (delays,
  649. echos, reverberation), DOPPLER_VELOCITY is not taken into
  650. account for any other calculation than Doppler Shift.
  651. </para></note>
  652. ]]>
  653. <![ %Annote [
  654. <note><title>Annotation (SetUnitsPerMeter)</title><para>
  655. DOPPLER_VELOCITY accomplishes the purposes of DS3D
  656. scaling parameters in a straightforward way, without
  657. introducing the undesirable connotations of real world
  658. units.
  659. </para></note>
  660. ]]>
  661. </sect1>
  662. </chapter>