src/share/classes/javax/sound/sampled/ReverbType.java

Print this page




   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javax.sound.sampled;
  27 
  28 
  29 /**
  30  * The <code>ReverbType</code> class provides methods for
  31  * accessing various reverberation settings to be applied to
  32  * an audio signal.
  33  * <p>
  34  * Reverberation simulates the reflection of sound off of
  35  * the walls, ceiling, and floor of a room.  Depending on
  36  * the size of the room, and how absorbent or reflective the materials in the
  37  * room's surfaces are, the sound might bounce around for a
  38  * long time before dying away.
  39  * <p>
  40  * The reverberation parameters provided by <code>ReverbType</code> consist
  41  * of the delay time and intensity of early reflections, the delay time and
  42  * intensity of late reflections, and an overall decay time.
  43  * Early reflections are the initial individual low-order reflections of the
  44  * direct signal off the surfaces in the room.
  45  * The late Reflections are the dense, high-order reflections that characterize
  46  * the room's reverberation.
  47  * The delay times for the start of these two reflection types give the listener
  48  * a sense of the overall size and complexity of the room's shape and contents.
  49  * The larger the room, the longer the reflection delay times.
  50  * The early and late reflections' intensities define the gain (in decibels) of the reflected
  51  * signals as compared to the direct signal.  These intensities give the
  52  * listener an impression of the absorptive nature of the surfaces and objects
  53  * in the room.
  54  * The decay time defines how long the reverberation takes to exponentially
  55  * decay until it is no longer perceptible ("effective zero").
  56  * The larger and less absorbent the surfaces, the longer the decay time.
  57  * <p>
  58  * The set of parameters defined here may not include all aspects of reverberation
  59  * as specified by some systems.  For example, the Midi Manufacturer's Association
  60  * (MMA) has an Interactive Audio Special Interest Group (IASIG), which has a
  61  * 3-D Working Group that has defined a Level 2 Spec (I3DL2).  I3DL2
  62  * supports filtering of reverberation and
  63  * control of reverb density.  These properties are not included in the JavaSound 1.0
  64  * definition of a reverb control.  In such a case, the implementing system
  65  * should either extend the defined reverb control to include additional
  66  * parameters, or else interpret the system's additional capabilities in a way that fits
  67  * the model described here.
  68  * <p>
  69  * If implementing JavaSound on a I3DL2-compliant device:
  70  * <ul>
  71  * <li>Filtering is disabled (high-frequency attenuations are set to 0.0 dB)
  72  * <li>Density parameters are set to midway between minimum and maximum
  73  * </ul>
  74  * <p>
  75  * The following table shows what parameter values an implementation might use for a
  76  * representative set of reverberation settings.
  77  * <p>
  78  *
  79  * <b>Reverberation Types and Parameters</b>
  80  *
  81  * <table border=1 cellpadding=5 summary="reverb types and params: decay time, late intensity, late delay, early intensity, and early delay">
  82  *
  83  * <tr>
  84  *  <th>Type</th>
  85  *  <th>Decay Time (ms)</th>
  86  *  <th>Late Intensity (dB)</th>
  87  *  <th>Late Delay (ms)</th>
  88  *  <th>Early Intensity (dB)</th>
  89  *  <th>Early Delay(ms)</th>
  90  * </tr>
  91  *
  92  * <tr>
  93  *  <td>Cavern</td>
  94  *  <td>2250</td>
  95  *  <td>-2.0</td>
  96  *  <td>41.3</td>


 125  *  <td>2.0</td>
 126  * </tr>
 127  *
 128  * <tr>
 129  *  <td>Closet</td>
 130  *  <td>150</td>
 131  *  <td>-10.0</td>
 132  *  <td>2.5</td>
 133  *  <td>-7.0</td>
 134  *  <td>0.6</td>
 135  * </tr>
 136  *
 137  * </table>
 138  *
 139  * @author Kara Kytle
 140  * @since 1.3
 141  */
 142 public class ReverbType {
 143 
 144     /**
 145      * Descriptive name of the reverb type..
 146      */
 147     private String name;
 148 
 149     /**
 150      * Early reflection delay in microseconds.
 151      */
 152     private int earlyReflectionDelay;
 153 
 154     /**
 155      * Early reflection intensity.
 156      */
 157     private float earlyReflectionIntensity;
 158 
 159     /**
 160      * Late reflection delay in microseconds.
 161      */
 162     private int lateReflectionDelay;
 163 
 164     /**
 165      * Late reflection intensity.
 166      */
 167     private float lateReflectionIntensity;
 168 
 169     /**
 170      * Total decay time
 171      */
 172     private int decayTime;
 173 
 174 
 175     /**
 176      * Constructs a new reverb type that has the specified reverberation
 177      * parameter values.
 178      * @param name the name of the new reverb type, or a zero-length <code>String</code>
 179      * @param earlyReflectionDelay the new type's early reflection delay time in microseconds
 180      * @param earlyReflectionIntensity the new type's early reflection intensity in dB
 181      * @param lateReflectionDelay the new type's late reflection delay time in microseconds
 182      * @param lateReflectionIntensity the new type's late reflection intensity in dB






 183      * @param decayTime the new type's decay time in microseconds
 184      */
 185     protected ReverbType(String name, int earlyReflectionDelay, float earlyReflectionIntensity, int lateReflectionDelay, float lateReflectionIntensity, int decayTime) {
 186 
 187         this.name = name;
 188         this.earlyReflectionDelay = earlyReflectionDelay;
 189         this.earlyReflectionIntensity = earlyReflectionIntensity;
 190         this.lateReflectionDelay = lateReflectionDelay;
 191         this.lateReflectionIntensity = lateReflectionIntensity;
 192         this.decayTime = decayTime;
 193     }
 194 
 195 
 196     /**
 197      * Obtains the name of this reverb type.

 198      * @return the name of this reverb type
 199      * @since 1.5
 200      */
 201     public String getName() {
 202             return name;
 203     }
 204 
 205 
 206     /**
 207      * Returns the early reflection delay time in microseconds.
 208      * This is the amount of time between when the direct signal is
 209      * heard and when the first early reflections are heard.

 210      * @return  early reflection delay time for this reverb type, in microseconds
 211      */
 212     public final int getEarlyReflectionDelay() {
 213         return earlyReflectionDelay;
 214     }
 215 
 216 
 217     /**
 218      * Returns the early reflection intensity in decibels.
 219      * This is the amplitude attenuation of the first early reflections
 220      * relative to the direct signal.
 221      * @return  early reflection intensity for this reverb type, in dB
 222      */
 223     public final float getEarlyReflectionIntensity() {
 224         return earlyReflectionIntensity;
 225     }
 226 
 227 
 228     /**
 229      * Returns the late reflection delay time in microseconds.
 230      * This is the amount of time between when the first early reflections
 231      * are heard and when the first late reflections are heard.

 232      * @return  late reflection delay time for this reverb type, in microseconds
 233      */
 234     public final int getLateReflectionDelay() {
 235         return lateReflectionDelay;
 236     }
 237 
 238 
 239     /**
 240      * Returns the late reflection intensity in decibels.
 241      * This is the amplitude attenuation of the first late reflections
 242      * relative to the direct signal.
 243      * @return  late reflection intensity for this reverb type, in dB
 244      */
 245     public final float getLateReflectionIntensity() {
 246         return lateReflectionIntensity;
 247     }
 248 
 249 
 250     /**
 251      * Obtains the decay time, which is the amount of time over which the
 252      * late reflections attenuate to effective zero.  The effective zero
 253      * value is implementation-dependent.

 254      * @return  the decay time of the late reflections, in microseconds
 255      */
 256     public final int getDecayTime() {
 257         return decayTime;
 258     }
 259 
 260 
 261     /**
 262      * Indicates whether the specified object is equal to this reverb type,
 263      * returning <code>true</code> if the objects are identical.

 264      * @param obj the reference object with which to compare
 265      * @return <code>true</code> if this reverb type is the same as
 266      * <code>obj</code>; <code>false</code> otherwise
 267      */

 268     public final boolean equals(Object obj) {
 269         return super.equals(obj);
 270     }
 271 
 272 
 273     /**
 274      * Finalizes the hashcode method.
 275      */

 276     public final int hashCode() {
 277         return super.hashCode();
 278     }
 279 
 280 
 281     /**
 282      * Provides a <code>String</code> representation of the reverb type,
 283      * including its name and its parameter settings.
 284      * The exact contents of the string may vary between implementations of
 285      * Java Sound.
 286      * @return reverberation type name and description
 287      */

 288     public final String toString() {
 289 
 290         //$$fb2001-07-20: fix for bug 4385060: The "name" attribute of class "ReverbType" is not accessible.
 291         //return (super.toString() + ", early reflection delay " + earlyReflectionDelay +
 292         return (name + ", early reflection delay " + earlyReflectionDelay +
 293                 " ns, early reflection intensity " + earlyReflectionIntensity +
 294                 " dB, late deflection delay " + lateReflectionDelay +
 295                 " ns, late reflection intensity " + lateReflectionIntensity +
 296                 " dB, decay time " +  decayTime);
 297     }
 298 
 299 } // class ReverbType


   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javax.sound.sampled;
  27 

  28 /**
  29  * The {@code ReverbType} class provides methods for accessing various
  30  * reverberation settings to be applied to an audio signal.

  31  * <p>
  32  * Reverberation simulates the reflection of sound off of the walls, ceiling,
  33  * and floor of a room. Depending on the size of the room, and how absorbent or
  34  * reflective the materials in the room's surfaces are, the sound might bounce
  35  * around for a long time before dying away.

  36  * <p>
  37  * The reverberation parameters provided by {@code ReverbType} consist of the
  38  * delay time and intensity of early reflections, the delay time and intensity
  39  * of late reflections, and an overall decay time. Early reflections are the
  40  * initial individual low-order reflections of the direct signal off the
  41  * surfaces in the room. The late Reflections are the dense, high-order
  42  * reflections that characterize the room's reverberation. The delay times for
  43  * the start of these two reflection types give the listener a sense of the
  44  * overall size and complexity of the room's shape and contents. The larger the
  45  * room, the longer the reflection delay times. The early and late reflections'
  46  * intensities define the gain (in decibels) of the reflected signals as
  47  * compared to the direct signal. These intensities give the listener an
  48  * impression of the absorptive nature of the surfaces and objects in the room.


  49  * The decay time defines how long the reverberation takes to exponentially
  50  * decay until it is no longer perceptible ("effective zero"). The larger and
  51  * less absorbent the surfaces, the longer the decay time.
  52  * <p>
  53  * The set of parameters defined here may not include all aspects of
  54  * reverberation as specified by some systems. For example, the Midi
  55  * Manufacturer's Association (MMA) has an Interactive Audio Special Interest
  56  * Group (IASIG), which has a 3-D Working Group that has defined a Level 2 Spec
  57  * (I3DL2). I3DL2 supports filtering of reverberation and control of reverb
  58  * density. These properties are not included in the JavaSound 1.0 definition of
  59  * a reverb control. In such a case, the implementing system should either
  60  * extend the defined reverb control to include additional parameters, or else
  61  * interpret the system's additional capabilities in a way that fits the model
  62  * described here.
  63  * <p>
  64  * If implementing JavaSound on a I3DL2-compliant device:
  65  * <ul>
  66  * <li>Filtering is disabled (high-frequency attenuations are set to 0.0 dB)
  67  * <li>Density parameters are set to midway between minimum and maximum
  68  * </ul>
  69  * <p>
  70  * The following table shows what parameter values an implementation might use
  71  * for a representative set of reverberation settings.
  72  * <p>
  73  *
  74  * <b>Reverberation Types and Parameters</b>
  75  *
  76  * <table border=1 cellpadding=5 summary="reverb types and params: decay time, late intensity, late delay, early intensity, and early delay">
  77  *
  78  * <tr>
  79  *  <th>Type</th>
  80  *  <th>Decay Time (ms)</th>
  81  *  <th>Late Intensity (dB)</th>
  82  *  <th>Late Delay (ms)</th>
  83  *  <th>Early Intensity (dB)</th>
  84  *  <th>Early Delay(ms)</th>
  85  * </tr>
  86  *
  87  * <tr>
  88  *  <td>Cavern</td>
  89  *  <td>2250</td>
  90  *  <td>-2.0</td>
  91  *  <td>41.3</td>


 120  *  <td>2.0</td>
 121  * </tr>
 122  *
 123  * <tr>
 124  *  <td>Closet</td>
 125  *  <td>150</td>
 126  *  <td>-10.0</td>
 127  *  <td>2.5</td>
 128  *  <td>-7.0</td>
 129  *  <td>0.6</td>
 130  * </tr>
 131  *
 132  * </table>
 133  *
 134  * @author Kara Kytle
 135  * @since 1.3
 136  */
 137 public class ReverbType {
 138 
 139     /**
 140      * Descriptive name of the reverb type.
 141      */
 142     private String name;
 143 
 144     /**
 145      * Early reflection delay in microseconds.
 146      */
 147     private int earlyReflectionDelay;
 148 
 149     /**
 150      * Early reflection intensity.
 151      */
 152     private float earlyReflectionIntensity;
 153 
 154     /**
 155      * Late reflection delay in microseconds.
 156      */
 157     private int lateReflectionDelay;
 158 
 159     /**
 160      * Late reflection intensity.
 161      */
 162     private float lateReflectionIntensity;
 163 
 164     /**
 165      * Total decay time.
 166      */
 167     private int decayTime;
 168 

 169     /**
 170      * Constructs a new reverb type that has the specified reverberation
 171      * parameter values.
 172      *
 173      * @param  name the name of the new reverb type, or a zero-length
 174      *         {@code String}
 175      * @param  earlyReflectionDelay the new type's early reflection delay time
 176      *         in microseconds
 177      * @param  earlyReflectionIntensity the new type's early reflection
 178      *         intensity in dB
 179      * @param  lateReflectionDelay the new type's late reflection delay time in
 180      *         microseconds
 181      * @param  lateReflectionIntensity the new type's late reflection intensity
 182      *         in dB
 183      * @param  decayTime the new type's decay time in microseconds
 184      */
 185     protected ReverbType(String name, int earlyReflectionDelay, float earlyReflectionIntensity, int lateReflectionDelay, float lateReflectionIntensity, int decayTime) {
 186 
 187         this.name = name;
 188         this.earlyReflectionDelay = earlyReflectionDelay;
 189         this.earlyReflectionIntensity = earlyReflectionIntensity;
 190         this.lateReflectionDelay = lateReflectionDelay;
 191         this.lateReflectionIntensity = lateReflectionIntensity;
 192         this.decayTime = decayTime;
 193     }
 194 

 195     /**
 196      * Obtains the name of this reverb type.
 197      *
 198      * @return the name of this reverb type
 199      * @since 1.5
 200      */
 201     public String getName() {
 202             return name;
 203     }
 204 

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

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

 226     /**
 227      * Returns the late reflection delay time in microseconds. This is the
 228      * amount of time between when the first early reflections are heard and
 229      * when the first late reflections are heard.
 230      *
 231      * @return late reflection delay time for this reverb type, in microseconds
 232      */
 233     public final int getLateReflectionDelay() {
 234         return lateReflectionDelay;
 235     }
 236 

 237     /**
 238      * Returns the late reflection intensity in decibels. This is the amplitude
 239      * attenuation of the first late reflections relative to the direct signal.
 240      *
 241      * @return late reflection intensity for this reverb type, in dB
 242      */
 243     public final float getLateReflectionIntensity() {
 244         return lateReflectionIntensity;
 245     }
 246 

 247     /**
 248      * Obtains the decay time, which is the amount of time over which the late
 249      * reflections attenuate to effective zero. The effective zero value is
 250      * implementation-dependent.
 251      *
 252      * @return the decay time of the late reflections, in microseconds
 253      */
 254     public final int getDecayTime() {
 255         return decayTime;
 256     }
 257 

 258     /**
 259      * Indicates whether the specified object is equal to this reverb type,
 260      * returning {@code true} if the objects are identical.
 261      *
 262      * @param  obj the reference object with which to compare
 263      * @return {@code true} if this reverb type is the same as {@code obj};
 264      *         {@code false} otherwise
 265      */
 266     @Override
 267     public final boolean equals(Object obj) {
 268         return super.equals(obj);
 269     }
 270 

 271     /**
 272      * Finalizes the hashcode method.
 273      */
 274     @Override
 275     public final int hashCode() {
 276         return super.hashCode();
 277     }
 278 

 279     /**
 280      * Provides a {@code String} representation of the reverb type, including
 281      * its name and its parameter settings. The exact contents of the string may
 282      * vary between implementations of Java Sound.
 283      *
 284      * @return reverberation type name and description
 285      */
 286     @Override
 287     public final String toString() {
 288 
 289         //$$fb2001-07-20: fix for bug 4385060: The "name" attribute of class "ReverbType" is not accessible.
 290         //return (super.toString() + ", early reflection delay " + earlyReflectionDelay +
 291         return (name + ", early reflection delay " + earlyReflectionDelay +
 292                 " ns, early reflection intensity " + earlyReflectionIntensity +
 293                 " dB, late deflection delay " + lateReflectionDelay +
 294                 " ns, late reflection intensity " + lateReflectionIntensity +
 295                 " dB, decay time " +  decayTime);
 296     }
 297 }