Java 3D API Specification
C H A P T E R![]() |
Audio Devices |
A Java 3D application running on a particular machine could have one of several options available to it for playing the audio image created by the sound renderer. Perhaps the machine on which Java 3D is executing has more than one sound card (for example, one that is a wave table synthesis card and the other with accelerated sound spatialization hardware). Furthermore, suppose there are Java 3D audio device drivers that execute Java 3D audio methods on each of these specific cards. The application would therefore have at least two audio device drivers through which the audio could be produced. For such a case the Java 3D application must choose the audio device driver with which sound rendering is to be performed. Once this audio device is chosen, the application can additionally select the type of audio playback on which device the rendered sound image is to be output. The playback device (headphones or speaker(s)) is physically connected to the port to which the selected device driver outputs.
11.1
The selection of this device driver is done through methods in the PhysicalEnvironment object (see Section C.9, "The PhysicalEnvironment Object"). The application queries how many audio devices are available. For each device, the user can get the AudioDevice object that describes it and query its characteristics. Once a decision is made about which of the available audio devices to use for a PhysicalEnvironment, the particular device is set into this PhysicalEnvironment's fields. Each PhysicalEnvironment object may use only a single audio device.AudioDevice Interface
The AudioDevice object interface specifies an abstract audio device that creators of Java 3D class libraries would implement for a particular device. Java 3D uses several methods to interact with specific devices. Since all audio devices implement this consistent interface, the user could have a portable means of initializing, setting particular audio device elements, and querying generic character-istics for any audio device.
public final static int HEADPHONESSpecifies that audio playback will be through stereo headphones.public final static int MONO_SPEAKERSpecifies that audio playback will be through a single speaker some distance away from the listener.public final static int STEREO_SPEAKERSSpecifies that audio playback will be through stereo speakers some distance away from, and at some angle to, the listener.
11.1.1
Each audio device driver must be initialized. The chosen device driver should be initialized before any Java 3D Sound methods are executed because the implementation of the Sound methods, in general, is potentially device-driver dependent.Initialization
public abstract boolean initialize()Initialize the audio device. Exactly what occurs during initialization is implementation dependent. This method provides explicit control by the user over when this initialization occurs.public abstract boolean close()Closes the audio device, releasing resources associated with this device.
11.1.2
Methods to set and retrieve the audio playback parameters are part of the AudioDevice object. The audio playback information specifies that playback will be through one of the following:Audio Playback
- Stereo headphones.
- A monaural speaker.
The type of playback chosen affects the sound image generated. Cross-talk cancellation is applied to the audio image if playback over stereo speakers is selected.
- A pair of speakers, equally distant from the listener, both at some angle from the head coordinate system Z axis. It's assumed that the speakers are at the same elevation and oriented symmetrically about the listener.
Methods
The following methods affect the playback of sound processed by the Java 3D sound renderer.public abstract void setAudioPlaybackType(int type) public abstract int getAudioPlaybackType()These methods set and retrieve the type of audio playback device (HEADPHONES
,MONO_SPEAKER
, orSTEREO_SPEAKERS
) used to output the analog audio from rendering Java 3D Sound nodes.public abstract void setCenterEarToSpeaker(float distance) public abstract float getCenterEarToSpeaker()These methods set and retrieve the distance in meters from the center ear (the midpoint between the left and right ears) and one of the speakers in the listener's environment. For monaural speaker playback, a typical distance from the listener to the speaker in a workstation cabinet is 0.76 meters. For stereo speakers placed at the sides of the display, this might be 0.82 meters.public abstract void setAngleOffsetToSpeaker(float angle) public abstract float getAngleOffsetToSpeaker()These methods set and retrieve the angle, in radians, between the vectors from the center ear to each of the speaker transducers and the vectors from the center ear parallel to the head coordinate's Z axis. Speakers placed at the sides of the computer display typically range between 0.175 and 0.350 radians (between 10 and 20 degrees).public abstract PhysicalEnvironment getPhysicalEnvironment()This method returns a reference to the AudioDevice's PhysicalEnvironment object.
11.1.3
While the sound image created for final output to the playback system is either only monaural or stereo (for this version of Java 3D), most device-driver implementations will mix the left and right image signals generated for each rendered sound source before outputting the final playback image. Each sound source will use N input channels of this internal mixer.Device-Driver-Specific Data
Each implemented Java 3D audio device driver will have its own limitations and driver-specific characteristics. These include channel availability and usage (during rendering). Methods for querying these device-driver-specific characteristics are provided below.
public abstract int getTotalChannels()This method retrieves the maximum number of channels available for Java 3D sound rendering for all sound sources.public abstract int getChannelsAvailable()During rendering, when Sound nodes are playing, this method returns the number of channels still available to Java 3D for rendering additional Sound nodes.public abstract int getChannelsUsedForSound(Sound node)This is a deprecated method. This method is now part of the Sound class.
11.2
A browser or applications developer must instantiate whatever system-specific audio devices that he or she needs and that exist on the system. This device information typically exists in a site configuration file. The browser or application will instantiate the physical environment as requested by the end user.Instantiating and Registering a New Device
The API for instantiating devices is site-specific, but it consists of a device object with a constructor and at least all of the methods specified in the AudioDevice interface.
Once instantiated, the browser or application must register the device with the Java 3D sound scheduler by associating this device with a PhysicalEnvironment object. The
setAudioDevice
method introduces new devices to the Java 3D environment and theallAudioDevices
method produces an enumeration that allows examination of all available devices within a Java 3D environment. See Section C.9, "The PhysicalEnvironment Object," for more details.
11.3
TheAudioMixerDevice Interface
AudioMixerDevice
interface extension is under construction until the Version 1.1 Java 3D API Specification is frozen. Check the javadoc for details.The intent is for this interface to be implemented by AudioDevice driver developers. The
AudioMixerDevice
interface methods should not be called by an application. Eventually this interface (when it is stable) will be used by those implementing their own Audio Devices.
![]()
![]()
![]()
Java 3D API Specification
Copyright © 1998, Sun Microsystems, Inc. All rights reserved.