Class JavaSoundMixer
java.lang.Object
com.sun.j3d.audioengines.AudioEngine
com.sun.j3d.audioengines.AudioEngine3D
com.sun.j3d.audioengines.AudioEngine3DL2
com.sun.j3d.audioengines.javasound.JavaSoundMixer
- All Implemented Interfaces:
AudioDevice
,AudioDevice3D
,AudioDevice3DL2
The JavaSoundMixer Class defines an audio output device that accesses
JavaSound functionality stream data.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected float
protected static final int
protected int
protected static final int
protected static final int
protected static final int
Fields inherited from class com.sun.j3d.audioengines.AudioEngine3D
attribs, currentView, samples
Fields inherited from interface javax.media.j3d.AudioDevice
HEADPHONES, MONO_SPEAKER, STEREO_SPEAKERS
Fields inherited from interface javax.media.j3d.AudioDevice3D
BACKGROUND_SOUND, BUFFERED_AUDIO_DATA, CONE_SOUND, POINT_SOUND, STREAMING_AUDIO_DATA
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clearSound
(int index) Clears the fields associated with sample data for this sound.boolean
close()
Code to close the device.int
getNumberOfChannelsUsed
(int index) Get number of channels used by a particular sample on the audio device.int
getNumberOfChannelsUsed
(int index, boolean muted) Overriden method from AudioEngine3D.long
getSampleDuration
(int index) Get length of time a sample would play if allowed to play to completion.long
getStartTime
(int index) Get time this sample begun playing on the audio device.int
Query total number of channels available for sound rendering for this audio device.boolean
Code to initialize the device New interface to mixer/engine specific methodsvoid
muteSample
(int index) Mute sample.void
pause()
Pauses audio device engine without closing the device and associated threads.void
pauseSample
(int index) Pause sample.int
prepareSound
(int soundType, MediaContainer soundData) Code to load sound data into a channel of device mixer.void
resume()
Resumes audio device engine (if previously paused) without reinitializing * the device.void
setDirection
(int index, javax.vecmath.Vector3d direction) Set direction vector of sample.void
setGain
(float scaleFactor) Set overall gain control of all sounds playing on the audio device.void
setLoop
(int index, int count) Set number of times sample is looped.void
setPosition
(int index, javax.vecmath.Point3d position) Set location of sample.void
setRateScaleFactor
(int index, float rateScaleFactor) Set scale factor applied to sample playback rate for a particular sound associated with the audio device.void
setReflectionCoefficient
(float coefficient) Set reverberation surface reflection coefficient value for current aural attribute applied to all samples.void
setReverbDelay
(float reverbDelay) Set reverberation delay time for current aural attribute applied to all samples.void
setReverbOrder
(int reverbOrder) Set reverberation order for current aural attribute applied to all samples.void
setVworldXfrm
(int index, Transform3D trans) Save a reference to the local to virtual world coordinate space Overriden method from AudioEngine3D.int
startSample
(int index) Start sample playing on audio deviceint
stopSample
(int index) Stop sample playing on audio devicevoid
unmuteSample
(int index) Unmute sample.void
unpauseSample
(int index) Unpause sample.void
updateSample
(int index) Update sample.Methods inherited from class com.sun.j3d.audioengines.AudioEngine3DL2
setDecayFilter, setDecayTime, setDensity, setDiffusion, setObstructionFilter, setObstructionGain, setOcclusionFilter, setOcclusionGain, setReflectionDelay, setReverbCoefficient
Methods inherited from class com.sun.j3d.audioengines.AudioEngine3D
getAuralParameters, getSample, getSampleList, getSampleListSize, getView, setAngularAttenuation, setDistanceFilter, setDistanceGain, setFrequencyScaleFactor, setRolloff, setSampleGain, setVelocityScaleFactor, setView
Methods inherited from class com.sun.j3d.audioengines.AudioEngine
getAngleOffsetToSpeaker, getAudioPlaybackType, getCenterEarToSpeaker, getChannelsAvailable, getChannelsUsedForSound, setAngleOffsetToSpeaker, setAudioPlaybackType, setCenterEarToSpeaker
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.media.j3d.AudioDevice
getAngleOffsetToSpeaker, getAudioPlaybackType, getCenterEarToSpeaker, getChannelsAvailable, getChannelsUsedForSound, setAngleOffsetToSpeaker, setAudioPlaybackType, setCenterEarToSpeaker
Methods inherited from interface javax.media.j3d.AudioDevice3D
setAngularAttenuation, setDistanceFilter, setDistanceGain, setFrequencyScaleFactor, setRolloff, setSampleGain, setVelocityScaleFactor, setView
-
Field Details
-
deviceGain
protected float deviceGain -
NOT_PAUSED
protected static final int NOT_PAUSED- See Also:
-
PAUSE_PENDING
protected static final int PAUSE_PENDING- See Also:
-
PAUSED
protected static final int PAUSED- See Also:
-
RESUME_PENDING
protected static final int RESUME_PENDING- See Also:
-
pause
protected int pause
-
-
Constructor Details
-
JavaSoundMixer
-
-
Method Details
-
getTotalChannels
public int getTotalChannels()Query total number of channels available for sound rendering for this audio device. Overridden method from AudioEngine.- Specified by:
getTotalChannels
in interfaceAudioDevice
- Overrides:
getTotalChannels
in classAudioEngine
- Returns:
- number of maximum voices play simultaneously on JavaSound Mixer.
-
initialize
public boolean initialize()Code to initialize the device New interface to mixer/engine specific methods- Specified by:
initialize
in interfaceAudioDevice
- Specified by:
initialize
in classAudioEngine
- Returns:
- flag: true is initialized sucessfully, false if error
-
close
public boolean close()Code to close the device. New interface to mixer/engine specific methods- Specified by:
close
in interfaceAudioDevice
- Specified by:
close
in classAudioEngine
- Returns:
- flag: true is closed sucessfully, false if error
-
prepareSound
Code to load sound data into a channel of device mixer. Load sound as one or mores sample into the Java Sound Mixer: a) as either a STREAM or CLIP based on whether cached is enabled b) positional and directional sounds use three samples per sound Overriden method from AudioEngine3D. Sound type determines if this is a Background, Point or Cone sound source and thus the JSXxxxSample object type Call JSXxxxxSample.loadSample() If no error Get the next free index in the samples list. Store a reference to JSXxxxSample object in samples list.- Specified by:
prepareSound
in interfaceAudioDevice3D
- Overrides:
prepareSound
in classAudioEngine3D
- Parameters:
soundType
- denotes type of sound: Background, Point or ConesoundData
- descrition of sound source data- Returns:
- index to the sample in samples list.
-
clearSound
public void clearSound(int index) Clears the fields associated with sample data for this sound. Overriden method from AudioEngine3D.- Specified by:
clearSound
in interfaceAudioDevice3D
- Specified by:
clearSound
in classAudioEngine3D
- Parameters:
index
- device specific reference number to device driver sample
-
setVworldXfrm
Save a reference to the local to virtual world coordinate space Overriden method from AudioEngine3D.- Specified by:
setVworldXfrm
in interfaceAudioDevice3D
- Overrides:
setVworldXfrm
in classAudioEngine3D
- Parameters:
index
- device specific reference number to device driver sampletrans
- is a reference to virtual world composite transform
-
setPosition
public void setPosition(int index, javax.vecmath.Point3d position) Description copied from class:AudioEngine3D
Set location of sample.- Specified by:
setPosition
in interfaceAudioDevice3D
- Overrides:
setPosition
in classAudioEngine3D
- Parameters:
index
- device specific reference number to device driver sampleposition
- point location in virtual world coordinate of sample- See Also:
-
setDirection
public void setDirection(int index, javax.vecmath.Vector3d direction) Description copied from class:AudioEngine3D
Set direction vector of sample.- Specified by:
setDirection
in interfaceAudioDevice3D
- Overrides:
setDirection
in classAudioEngine3D
- Parameters:
index
- device specific reference number to device driver sampledirection
- vector in virtual world coordinate.- See Also:
-
setReflectionCoefficient
public void setReflectionCoefficient(float coefficient) Description copied from class:AudioEngine3D
Set reverberation surface reflection coefficient value for current aural attribute applied to all samples.- Specified by:
setReflectionCoefficient
in interfaceAudioDevice3D
- Overrides:
setReflectionCoefficient
in classAudioEngine3D
- Parameters:
coefficient
- applied to amplitude of reverbation added at each iteration of reverb processing.- See Also:
-
setReverbDelay
public void setReverbDelay(float reverbDelay) Description copied from class:AudioEngine3D
Set reverberation delay time for current aural attribute applied to all samples.- Specified by:
setReverbDelay
in interfaceAudioDevice3D
- Overrides:
setReverbDelay
in classAudioEngine3D
- Parameters:
reverbDelay
- amount of time in millisecond between each iteration of reverb processing.- See Also:
-
setReverbOrder
public void setReverbOrder(int reverbOrder) Description copied from class:AudioEngine3D
Set reverberation order for current aural attribute applied to all samples.- Specified by:
setReverbOrder
in interfaceAudioDevice3D
- Overrides:
setReverbOrder
in classAudioEngine3D
- Parameters:
reverbOrder
- number of times reverb process loop is iterated.- See Also:
-
startSample
public int startSample(int index) Description copied from class:AudioEngine3D
Start sample playing on audio device- Specified by:
startSample
in interfaceAudioDevice3D
- Specified by:
startSample
in classAudioEngine3D
- Parameters:
index
- device specific reference number to device driver sample- Returns:
- status: invalid input: '<' 0 denotes an error
-
stopSample
public int stopSample(int index) Description copied from class:AudioEngine3D
Stop sample playing on audio device- Specified by:
stopSample
in interfaceAudioDevice3D
- Specified by:
stopSample
in classAudioEngine3D
- Parameters:
index
- device specific reference number to device driver sample- Returns:
- status: invalid input: '<' 0 denotes an error
-
pauseSample
public void pauseSample(int index) Description copied from class:AudioEngine3D
Pause sample.- Specified by:
pauseSample
in interfaceAudioDevice3D
- Specified by:
pauseSample
in classAudioEngine3D
- Parameters:
index
- device specific reference number to device driver sample
-
unpauseSample
public void unpauseSample(int index) Description copied from class:AudioEngine3D
Unpause sample.- Specified by:
unpauseSample
in interfaceAudioDevice3D
- Specified by:
unpauseSample
in classAudioEngine3D
- Parameters:
index
- device specific reference number to device driver sample
-
updateSample
public void updateSample(int index) Description copied from class:AudioEngine3D
Update sample. Implies that some parameters affecting rendering have been modified.- Specified by:
updateSample
in interfaceAudioDevice3D
- Specified by:
updateSample
in classAudioEngine3D
- Parameters:
index
- device specific reference number to device driver sample
-
muteSample
public void muteSample(int index) Description copied from class:AudioEngine3D
Mute sample.- Specified by:
muteSample
in interfaceAudioDevice3D
- Specified by:
muteSample
in classAudioEngine3D
- Parameters:
index
- device specific reference number to device driver sample
-
unmuteSample
public void unmuteSample(int index) Description copied from class:AudioEngine3D
Unmute sample.- Specified by:
unmuteSample
in interfaceAudioDevice3D
- Specified by:
unmuteSample
in classAudioEngine3D
- Parameters:
index
- device specific reference number to device driver sample
-
getSampleDuration
public long getSampleDuration(int index) Description copied from class:AudioEngine3D
Get length of time a sample would play if allowed to play to completion.- Specified by:
getSampleDuration
in interfaceAudioDevice3D
- Overrides:
getSampleDuration
in classAudioEngine3D
- Parameters:
index
- device specific reference number to device driver sample- Returns:
- length of sample in milliseconds
-
getNumberOfChannelsUsed
public int getNumberOfChannelsUsed(int index) Description copied from class:AudioEngine3D
Get number of channels used by a particular sample on the audio device.- Specified by:
getNumberOfChannelsUsed
in interfaceAudioDevice3D
- Overrides:
getNumberOfChannelsUsed
in classAudioEngine3D
- Parameters:
index
- device specific reference number to device driver sample- Returns:
- number of channels currently being used by this sample.
-
getNumberOfChannelsUsed
public int getNumberOfChannelsUsed(int index, boolean muted) Overriden method from AudioEngine3D.- Specified by:
getNumberOfChannelsUsed
in interfaceAudioDevice3D
- Overrides:
getNumberOfChannelsUsed
in classAudioEngine3D
- Parameters:
index
- device specific reference number to device driver samplemuted
- denotes the mute state to assume while executing this query. This mute value does not have to match the current mute state of the sample.- Returns:
- number of channels that would be used by this sample if it were playing.
-
getStartTime
public long getStartTime(int index) Description copied from class:AudioEngine3D
Get time this sample begun playing on the audio device.- Specified by:
getStartTime
in interfaceAudioDevice3D
- Overrides:
getStartTime
in classAudioEngine3D
- Parameters:
index
- device specific reference number to device driver sample- Returns:
- system clock time sample started
-
setLoop
public void setLoop(int index, int count) Description copied from class:AudioEngine3D
Set number of times sample is looped.- Specified by:
setLoop
in interfaceAudioDevice3D
- Overrides:
setLoop
in classAudioEngine3D
- Parameters:
index
- device specific reference number to device driver samplecount
- number of times sample is repeated- See Also:
-
setGain
public void setGain(float scaleFactor) Description copied from class:AudioEngine3DL2
Set overall gain control of all sounds playing on the audio device.- Specified by:
setGain
in interfaceAudioDevice3DL2
- Specified by:
setGain
in classAudioEngine3DL2
- Parameters:
scaleFactor
- scale factor applied to calculated amplitudes for all sounds playing on this device
-
setRateScaleFactor
public void setRateScaleFactor(int index, float rateScaleFactor) Description copied from class:AudioEngine3DL2
Set scale factor applied to sample playback rate for a particular sound associated with the audio device. Changing the device sample rate affects both the pitch and speed. This scale factor is applied to ALL sound types. Changes (scales) the playback rate of a sound independent of Doppler rate changes.- Specified by:
setRateScaleFactor
in interfaceAudioDevice3DL2
- Overrides:
setRateScaleFactor
in classAudioEngine3DL2
- Parameters:
index
- device specific reference to device driver samplerateScaleFactor
- non-negative factor applied to calculated amplitudes for all sounds playing on this device- See Also:
-
pause
public void pause()Pauses audio device engine without closing the device and associated threads. Causes all cached sounds to be paused and all streaming sounds to be stopped.- Specified by:
pause
in interfaceAudioDevice3DL2
- Specified by:
pause
in classAudioEngine3DL2
-
resume
public void resume()Resumes audio device engine (if previously paused) without reinitializing * the device. Causes all paused cached sounds to be resumed and all streaming sounds restarted.- Specified by:
resume
in interfaceAudioDevice3DL2
- Specified by:
resume
in classAudioEngine3DL2
-