KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > sound > sampled > ReverbType


1 /*
2  * @(#)ReverbType.java 1.13 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.sound.sampled;
9
10
11 /**
12  * The <code>ReverbType</code> class provides methods for
13  * accessing various reverberation settings to be applied to
14  * an audio signal.
15  * <p>
16  * Reverberation simulates the reflection of sound off of
17  * the walls, ceiling, and floor of a room. Depending on
18  * the size of the room, and how absorbent or reflective the materials in the
19  * room's surfaces are, the sound might bounce around for a
20  * long time before dying away.
21  * <p>
22  * The reverberation parameters provided by <code>ReverbType</code> consist
23  * of the delay time and intensity of early reflections, the delay time and
24  * intensity of late reflections, and an overall decay time.
25  * Early reflections are the initial individual low-order reflections of the
26  * direct signal off the surfaces in the room.
27  * The late Relections are the dense, high-order reflections that characterize
28  * the room's reverberation.
29  * The delay times for the start of these two reflection types give the listener
30  * a sense of the overall size and complexity of the room's shape and contents.
31  * The larger the room, the longer the reflection delay times.
32  * The early and late reflections' intensities define the gain (in decibels) of the reflected
33  * signals as compared to the direct signal. These intensities give the
34  * listener an impression of the absorptive nature of the surfaces and objects
35  * in the room.
36  * The decay time defines how long the reverberation takes to exponentially
37  * decay until it is no longer perceptible ("effective zero").
38  * The larger and less absorbent the surfaces, the longer the decay time.
39  * <p>
40  * The set of parameters defined here may not include all aspects of reverberation
41  * as specified by some systems. For example, the Midi Manufacturer's Association
42  * (MMA) has an Interactive Audio Special Interest Group (IASIG), which has a
43  * 3-D Working Group that has defined a Level 2 Spec (I3DL2). I3DL2
44  * supports filtering of reverberation and
45  * control of reverb density. These properties are not included in the JavaSound 1.0
46  * definition of a reverb control. In such a case, the implementing system
47  * should either extend the defined reverb control to include additional
48  * parameters, or else interpret the system's additional capabilities in a way that fits
49  * the model described here.
50  * <p>
51  * If implementing JavaSound on a I3DL2-compliant device:
52  * <ul>
53  * <li>Filtering is disabled (high-frequency attenuations are set to 0.0 dB)
54  * <li>Density parameters are set to midway between minimum and maximum
55  * </ul>
56  * <p>
57  * The following table shows what parameter values an implementation might use for a
58  * representative set of reverberation settings.
59  * <p>
60  *
61  * <b>Reverberation Types and Parameters</b>
62  * <p>
63  * <table border=1 cellpadding=5 summary="reverb types and params: decay time, late intensity, late delay, early intensity, and early delay">
64  *
65  * <tr>
66  * <th>Type</th>
67  * <th>Decay Time (ms)</th>
68  * <th>Late Intensity (dB)</th>
69  * <th>Late Delay (ms)</th>
70  * <th>Early Intensity (dB)</th>
71  * <th>Early Delay(ms)</th>
72  * </tr>
73  *
74  * <tr>
75  * <td>Cavern</td>
76  * <td>2250</td>
77  * <td>-2.0</td>
78  * <td>41.3</td>
79  * <td>-1.4</td>
80  * <td>10.3</td>
81  * </tr>
82  *
83  * <tr>
84  * <td>Dungeon</td>
85  * <td>1600</td>
86  * <td>-1.0</td>
87  * <td>10.3</td>
88  * <td>-0.7</td>
89  * <td>2.6</td>
90  * </tr>
91  *
92  * <tr>
93  * <td>Garage</td>
94  * <td>900</td>
95  * <td>-6.0</td>
96  * <td>14.7</td>
97  * <td>-4.0</td>
98  * <td>3.9</td>
99  * </tr>
100  *
101  * <tr>
102  * <td>Acoustic Lab</td>
103  * <td>280</td>
104  * <td>-3.0</td>
105  * <td>8.0</td>
106  * <td>-2.0</td>
107  * <td>2.0</td>
108  * </tr>
109  *
110  * <tr>
111  * <td>Closet</td>
112  * <td>150</td>
113  * <td>-10.0</td>
114  * <td>2.5</td>
115  * <td>-7.0</td>
116  * <td>0.6</td>
117  * </tr>
118  *
119  * </table>
120  *
121  * @author Kara Kytle
122  * @version 1.13, 03/12/19
123  * @since 1.3
124  */

125 public class ReverbType {
126
127     /**
128      * Descriptive name of the reverb type..
129      */

130     private String JavaDoc name;
131
132     /**
133      * Early reflection delay in microseconds.
134      */

135     private int earlyReflectionDelay;
136
137     /**
138      * Early reflection intensity.
139      */

140     private float earlyReflectionIntensity;
141
142     /**
143      * Late reflection delay in microseconds.
144      */

145     private int lateReflectionDelay;
146
147     /**
148      * Late reflection intensity.
149      */

150     private float lateReflectionIntensity;
151
152     /**
153      * Total decay time
154      */

155     private int decayTime;
156
157         
158     /**
159      * Constructs a new reverb type that has the specified reverberation
160      * parameter values.
161      * @param name the name of the new reverb type, or a zero-length <code>String</code>
162      * @param earlyReflectionDelay the new type's early reflection delay time in microseconds
163      * @param earlyReflectionIntensity the new type's early reflection intensity in dB
164      * @param lateReflectionDelay the new type's late reflection delay time in microseconds
165      * @param lateReflectionIntensity the new type's late reflection intensity in dB
166      * @param decayTime the new type's decay time in microseconds
167      */

168     protected ReverbType(String JavaDoc name, int earlyReflectionDelay, float earlyReflectionIntensity, int lateReflectionDelay, float lateReflectionIntensity, int decayTime) {
169
170     this.name = name;
171     this.earlyReflectionDelay = earlyReflectionDelay;
172     this.earlyReflectionIntensity = earlyReflectionIntensity;
173     this.lateReflectionDelay = lateReflectionDelay;
174     this.lateReflectionIntensity = lateReflectionIntensity;
175     this.decayTime = decayTime;
176     }
177
178
179     /**
180      * Obtains the name of this reverb type.
181      * @return the name of this reverb type
182      * @since 1.5
183      */

184     public String JavaDoc getName() {
185             return name;
186     }
187
188     
189     /**
190      * Returns the early reflection delay time in microseconds.
191      * This is the amount of time between when the direct signal is
192      * heard and when the first early reflections are heard.
193      * @return early reflection delay time for this reverb type, in microseconds
194      */

195     public final int getEarlyReflectionDelay() {
196     return earlyReflectionDelay;
197     }
198
199
200     /**
201      * Returns the early reflection intensity in decibels.
202      * This is the amplitude attenuation of the first early reflections
203      * relative to the direct signal.
204      * @return early reflection intensity for this reverb type, in dB
205      */

206     public final float getEarlyReflectionIntensity() {
207     return earlyReflectionIntensity;
208     }
209
210
211     /**
212      * Returns the late reflection delay time in microseconds.
213      * This is the amount of time between when the first early reflections
214      * are heard and when the first late reflections are heard.
215      * @return late reflection delay time for this reverb type, in microseconds
216      */

217     public final int getLateReflectionDelay() {
218     return lateReflectionDelay;
219     }
220
221
222     /**
223      * Returns the late reflection intensity in decibels.
224      * This is the amplitude attenuation of the first late reflections
225      * relative to the direct signal.
226      * @return late reflection intensity for this reverb type, in dB
227      */

228     public final float getLateReflectionIntensity() {
229     return lateReflectionIntensity;
230     }
231
232
233     /**
234      * Obtains the decay time, which is the amount of time over which the
235      * late reflections attenuate to effective zero. The effective zero
236      * value is implementation-dependent.
237      * @return the decay time of the late reflections, in microseconds
238      */

239     public final int getDecayTime() {
240     return decayTime;
241     }
242
243
244     /**
245      * Indicates whether the specified object is equal to this reverb type,
246      * returning <code>true</code> if the objects are identical.
247      * @param obj the reference object with which to compare
248      * @return <code>true</code> if this reverb type is the same as
249      * <code>obj</code>; <code>false</code> otherwise
250      */

251     public final boolean equals(Object JavaDoc obj) {
252     return super.equals(obj);
253     }
254
255
256     /**
257      * Finalizes the hashcode method.
258      */

259     public final int hashCode() {
260     return super.hashCode();
261     }
262
263         
264     /**
265      * Provides a <code>String</code> representation of the reverb type,
266      * including its name and its parameter settings.
267      * The exact contents of the string may vary between implementations of
268      * Java Sound.
269      * @return reverberation type name and description
270      */

271     public final String JavaDoc toString() {
272             
273     //$$fb2001-07-20: fix for bug 4385060: The "name" attribute of class "ReverbType" is not accessible.
274
//return (super.toString() + ", early reflection delay " + earlyReflectionDelay +
275
return (name + ", early reflection delay " + earlyReflectionDelay +
276         " ns, early reflection intensity " + earlyReflectionIntensity +
277         " dB, late deflection delay " + lateReflectionDelay +
278         " ns, late reflection intensity " + lateReflectionIntensity +
279         " dB, decay time " + decayTime);
280     }
281
282 } // class ReverbType
283
Popular Tags