1. /*
  2. * @(#)ReverbType.java 1.11 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.sound.sampled;
  8. /**
  9. * The <code>ReverbType</code> class provides methods for
  10. * accessing various reverberation settings to be applied to
  11. * an audio signal.
  12. * <p>
  13. * Reverberation simulates the reflection of sound off of
  14. * the walls, ceiling, and floor of a room. Depending on
  15. * the size of the room, and how absorbent or reflective the materials in the
  16. * room's surfaces are, the sound might bounce around for a
  17. * long time before dying away.
  18. * <p>
  19. * The reverberation parameters provided by <code>ReverbType</code> consist
  20. * of the delay time and intensity of early reflections, the delay time and
  21. * intensity of late reflections, and an overall decay time.
  22. * Early reflections are the initial individual low-order reflections of the
  23. * direct signal off the surfaces in the room.
  24. * The late Relections are the dense, high-order reflections that characterize
  25. * the room's reverberation.
  26. * The delay times for the start of these two reflection types give the listener
  27. * a sense of the overall size and complexity of the room's shape and contents.
  28. * The larger the room, the longer the reflection delay times.
  29. * The early and late reflections' intensities define the gain (in decibels) of the reflected
  30. * signals as compared to the direct signal. These intensities give the
  31. * listener an impression of the absorptive nature of the surfaces and objects
  32. * in the room.
  33. * The decay time defines how long the reverberation takes to exponentially
  34. * decay until it is no longer perceptible ("effective zero").
  35. * The larger and less absorbent the surfaces, the longer the decay time.
  36. * <p>
  37. * The set of parameters defined here may not include all aspects of reverberation
  38. * as specified by some systems. For example, the Midi Manufacturer's Association
  39. * (MMA) has an Interactive Audio Special Interest Group (IASIG), which has a
  40. * 3-D Working Group that has defined a Level 2 Spec (I3DL2). I3DL2
  41. * supports filtering of reverberation and
  42. * control of reverb density. These properties are not included in the JavaSound 1.0
  43. * definition of a reverb control. In such a case, the implementing system
  44. * should either extend the defined reverb control to include additional
  45. * parameters, or else interpret the system's additional capabilities in a way that fits
  46. * the model described here.
  47. * <p>
  48. * If implementing JavaSound on a I3DL2-compliant device:
  49. * <ul>
  50. * <li>Filtering is disabled (high-frequency attenuations are set to 0.0 dB)
  51. * <li>Density parameters are set to midway between minimum and maximum
  52. * </ul>
  53. * <p>
  54. * The following table shows what parameter values an implementation might use for a
  55. * representative set of reverberation settings.
  56. * <p>
  57. *
  58. * <b>Reverberation Types and Parameters</b>
  59. * <p>
  60. * <table border=1 cellpadding=5 summary="reverb types and params: decay time, late intensity, late delay, early intensity, and early delay">
  61. *
  62. * <tr>
  63. * <th>Type</th>
  64. * <th>Decay Time (ms)</th>
  65. * <th>Late Intensity (dB)</th>
  66. * <th>Late Delay (ms)</th>
  67. * <th>Early Intensity (dB)</th>
  68. * <th>Early Delay(ms)</th>
  69. * </tr>
  70. *
  71. * <tr>
  72. * <td>Cavern</td>
  73. * <td>2250</td>
  74. * <td>-2.0</td>
  75. * <td>41.3</td>
  76. * <td>-1.4</td>
  77. * <td>10.3</td>
  78. * </tr>
  79. *
  80. * <tr>
  81. * <td>Dungeon</td>
  82. * <td>1600</td>
  83. * <td>-1.0</td>
  84. * <td>10.3</td>
  85. * <td>-0.7</td>
  86. * <td>2.6</td>
  87. * </tr>
  88. *
  89. * <tr>
  90. * <td>Garage</td>
  91. * <td>900</td>
  92. * <td>-6.0</td>
  93. * <td>14.7</td>
  94. * <td>-4.0</td>
  95. * <td>3.9</td>
  96. * </tr>
  97. *
  98. * <tr>
  99. * <td>Acoustic Lab</td>
  100. * <td>280</td>
  101. * <td>-3.0</td>
  102. * <td>8.0</td>
  103. * <td>-2.0</td>
  104. * <td>2.0</td>
  105. * </tr>
  106. *
  107. * <tr>
  108. * <td>Closet</td>
  109. * <td>150</td>
  110. * <td>-10.0</td>
  111. * <td>2.5</td>
  112. * <td>-7.0</td>
  113. * <td>0.6</td>
  114. * </tr>
  115. *
  116. * </table>
  117. *
  118. * @author Kara Kytle
  119. * @version 1.11, 03/01/23
  120. * @since 1.3
  121. */
  122. public class ReverbType {
  123. /**
  124. * Descriptive name of the reverb type..
  125. */
  126. private String name;
  127. /**
  128. * Early reflection delay in microseconds.
  129. */
  130. private int earlyReflectionDelay;
  131. /**
  132. * Early reflection intensity.
  133. */
  134. private float earlyReflectionIntensity;
  135. /**
  136. * Late reflection delay in microseconds.
  137. */
  138. private int lateReflectionDelay;
  139. /**
  140. * Late reflection intensity.
  141. */
  142. private float lateReflectionIntensity;
  143. /**
  144. * Total decay time
  145. */
  146. private int decayTime;
  147. /**
  148. * Constructs a new reverb type that has the specified reverberation
  149. * parameter values.
  150. * @param name the name of the new reverb type, or a zero-length <code>String</code>
  151. * @param earlyReflectionDelay the new type's early reflection delay time in microseconds
  152. * @param earlyReflectionIntensity the new type's early reflection intensity in dB
  153. * @param lateReflectionDelay the new type's late reflection delay time in microseconds
  154. * @param lateReflectionIntensity the new type's late reflection intensity in dB
  155. * @param decayTime the new type's decay time in microseconds
  156. */
  157. protected ReverbType(String name, int earlyReflectionDelay, float earlyReflectionIntensity, int lateReflectionDelay, float lateReflectionIntensity, int decayTime) {
  158. this.name = name;
  159. this.earlyReflectionDelay = earlyReflectionDelay;
  160. this.earlyReflectionIntensity = earlyReflectionIntensity;
  161. this.lateReflectionDelay = lateReflectionDelay;
  162. this.lateReflectionIntensity = lateReflectionIntensity;
  163. this.decayTime = decayTime;
  164. }
  165. /**
  166. * Returns the early reflection delay time in microseconds.
  167. * This is the amount of time between when the direct signal is
  168. * heard and when the first early reflections are heard.
  169. * @return early reflection delay time for this reverb type, in microseconds
  170. */
  171. public final int getEarlyReflectionDelay() {
  172. return earlyReflectionDelay;
  173. }
  174. /**
  175. * Returns the early reflection intensity in decibels.
  176. * This is the amplitude attenuation of the first early reflections
  177. * relative to the direct signal.
  178. * @return early reflection intensity for this reverb type, in dB
  179. */
  180. public final float getEarlyReflectionIntensity() {
  181. return earlyReflectionIntensity;
  182. }
  183. /**
  184. * Returns the late reflection delay time in microseconds.
  185. * This is the amount of time between when the first early reflections
  186. * are heard and when the first late reflections are heard.
  187. * @return late reflection delay time for this reverb type, in microseconds
  188. */
  189. public final int getLateReflectionDelay() {
  190. return lateReflectionDelay;
  191. }
  192. /**
  193. * Returns the late reflection intensity in decibels.
  194. * This is the amplitude attenuation of the first late reflections
  195. * relative to the direct signal.
  196. * @return late reflection intensity for this reverb type, in dB
  197. */
  198. public final float getLateReflectionIntensity() {
  199. return lateReflectionIntensity;
  200. }
  201. /**
  202. * Obtains the decay time, which is the amount of time over which the
  203. * late reflections attenuate to effective zero. The effective zero
  204. * value is implementation-dependent.
  205. * @return the decay time of the late reflections, in microseconds
  206. */
  207. public final int getDecayTime() {
  208. return decayTime;
  209. }
  210. /**
  211. * Indicates whether the specified object is equal to this reverb type,
  212. * returning <code>true</code> if the objects are identical.
  213. * @param obj the reference object with which to compare
  214. * @return <code>true</code> if this reverb type is the same as
  215. * <code>obj</code> <code>false</code> otherwise
  216. */
  217. public final boolean equals(Object obj) {
  218. return super.equals(obj);
  219. }
  220. /**
  221. * Finalizes the hashcode method.
  222. */
  223. public final int hashCode() {
  224. return super.hashCode();
  225. }
  226. /**
  227. * Provides a <code>String</code> representation of the reverb type,
  228. * including its name and its parameter settings.
  229. * The exact contents of the string may vary between implementations of
  230. * Java Sound.
  231. * @return reverberation type name and description
  232. */
  233. public final String toString() {
  234. //$$fb2001-07-20: fix for bug 4385060: The "name" attribute of class "ReverbType" is not accessible.
  235. //return (super.toString() + ", early reflection delay " + earlyReflectionDelay +
  236. return (name + ", early reflection delay " + earlyReflectionDelay +
  237. " ns, early reflection intensity " + earlyReflectionIntensity +
  238. " dB, late deflection delay " + lateReflectionDelay +
  239. " ns, late reflection intensity " + lateReflectionIntensity +
  240. " dB, decay time " + decayTime);
  241. }
  242. } // class ReverbType