com.sun.j3d.audioengines.javasound

## 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

      public class JavaSoundMixer
      extends AudioEngine3DL2

  The JavaSoundMixer Class defines an audio output device that accesses JavaSound functionality stream data.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected float` | `deviceGain`
    `protected static int` | `NOT_PAUSED`
    `protected int` | `pause`
    `protected static int` | `PAUSE_PENDING`
    `protected static int` | `PAUSED`
    `protected static int` | `RESUME_PENDING`

    - ### Fields inherited from class com.sun.j3d.audioengines.AudioEngine3D

      `attribs, currentView, samples`

    - ### Fields inherited from interface javax.media.j3d.AudioDevice3D

      `BACKGROUND_SOUND, BUFFERED_AUDIO_DATA, CONE_SOUND, POINT_SOUND, STREAMING_AUDIO_DATA`

    - ### Fields inherited from interface javax.media.j3d.AudioDevice

      `HEADPHONES, MONO_SPEAKER, STEREO_SPEAKERS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JavaSoundMixer(PhysicalEnvironment physicalEnvironment)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `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` | `getTotalChannels()` Query total number of channels available for sound rendering for this audio device.
    `boolean` | `initialize()` Code to initialize the device New interface to mixer/engine specific methods
    `void` | `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, 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, 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 device
    `int` | `stopSample(int index)` Stop sample playing on audio device
    `void` | `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.AudioDevice3D

      `setAngularAttenuation, setDistanceFilter, setDistanceGain, setFrequencyScaleFactor, setRolloff, setSampleGain, setVelocityScaleFactor, setView`

    - ### Methods inherited from interface javax.media.j3d.AudioDevice

      `getAngleOffsetToSpeaker, getAudioPlaybackType, getCenterEarToSpeaker, getChannelsAvailable, getChannelsUsedForSound, setAngleOffsetToSpeaker, setAudioPlaybackType, setCenterEarToSpeaker`

- - ### Field Detail

    - #### deviceGain

          protected float deviceGain

    - #### NOT_PAUSED

          protected static final int NOT_PAUSED

      See Also:
        Constant Field Values

    - #### PAUSE_PENDING

          protected static final int PAUSE_PENDING

      See Also:
        Constant Field Values

    - #### PAUSED

          protected static final int PAUSED

      See Also:
        Constant Field Values

    - #### RESUME_PENDING

          protected static final int RESUME_PENDING

      See Also:
        Constant Field Values

    - #### pause

          protected int pause

  - ### Constructor Detail

    - #### JavaSoundMixer

          public JavaSoundMixer(PhysicalEnvironment physicalEnvironment)

  - ### Method Detail

    - #### 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 interface `AudioDevice`
      Overrides:
        `getTotalChannels` in class `AudioEngine`
      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 interface `AudioDevice`
      Specified by:
        `initialize` in class `AudioEngine`
      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 interface `AudioDevice`
      Specified by:
        `close` in class `AudioEngine`
      Returns:
        flag: true is closed sucessfully, false if error

    - #### prepareSound

          public int prepareSound(int soundType,
                         MediaContainer soundData)

      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 interface `AudioDevice3D`
      Overrides:
        `prepareSound` in class `AudioEngine3D`
      Parameters:
        `soundType` - denotes type of sound: Background, Point or Cone
        `soundData` - 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 interface `AudioDevice3D`
      Specified by:
        `clearSound` in class `AudioEngine3D`
      Parameters:
        `index` - device specific reference number to device driver sample

    - #### setVworldXfrm

          public void setVworldXfrm(int index,
                           Transform3D trans)

      Save a reference to the local to virtual world coordinate space Overriden method from AudioEngine3D.
      Specified by:
        `setVworldXfrm` in interface `AudioDevice3D`
      Overrides:
        `setVworldXfrm` in class `AudioEngine3D`
      Parameters:
        `index` - device specific reference number to device driver sample
        `trans` - is a reference to virtual world composite transform

    - #### setPosition

          public void setPosition(int index,
                         Point3d position)

      Description copied from class: `AudioEngine3D`
      Set location of sample.
      Specified by:
        `setPosition` in interface `AudioDevice3D`
      Overrides:
        `setPosition` in class `AudioEngine3D`
      Parameters:
        `index` - device specific reference number to device driver sample
        `position` - point location in virtual world coordinate of sample
      See Also:
        `PointSound.setPosition(float x, float y, float z)`, `PointSound.setPosition(Point3f position)`

    - #### setDirection

          public void setDirection(int index,
                          Vector3d direction)

      Description copied from class: `AudioEngine3D`
      Set direction vector of sample.
      Specified by:
        `setDirection` in interface `AudioDevice3D`
      Overrides:
        `setDirection` in class `AudioEngine3D`
      Parameters:
        `index` - device specific reference number to device driver sample
        `direction` - vector in virtual world coordinate.
      See Also:
        `ConeSound.setDirection(float x, float y, float z)`, `ConeSound.setDirection(Vector3f direction)`

    - #### 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 interface `AudioDevice3D`
      Overrides:
        `setReflectionCoefficient` in class `AudioEngine3D`
      Parameters:
        `coefficient` - applied to amplitude of reverbation added at each iteration of reverb processing.
      See Also:
        `AuralAttributes.setReflectionCoefficient(float)`

    - #### 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 interface `AudioDevice3D`
      Overrides:
        `setReverbDelay` in class `AudioEngine3D`
      Parameters:
        `reverbDelay` - amount of time in millisecond between each iteration of reverb processing.
      See Also:
        `AuralAttributes.setReverbDelay(float reverbDelay)`

    - #### 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 interface `AudioDevice3D`
      Overrides:
        `setReverbOrder` in class `AudioEngine3D`
      Parameters:
        `reverbOrder` - number of times reverb process loop is iterated.
      See Also:
        `AuralAttributes.setReverbOrder(int)`

    - #### startSample

          public int startSample(int index)

      Description copied from class: `AudioEngine3D`
      Start sample playing on audio device
      Specified by:
        `startSample` in interface `AudioDevice3D`
      Specified by:
        `startSample` in class `AudioEngine3D`
      Parameters:
        `index` - device specific reference number to device driver sample
      Returns:
        status: < 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 interface `AudioDevice3D`
      Specified by:
        `stopSample` in class `AudioEngine3D`
      Parameters:
        `index` - device specific reference number to device driver sample
      Returns:
        status: < 0 denotes an error

    - #### pauseSample

          public void pauseSample(int index)

      Description copied from class: `AudioEngine3D`
      Pause sample.
      Specified by:
        `pauseSample` in interface `AudioDevice3D`
      Specified by:
        `pauseSample` in class `AudioEngine3D`
      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 interface `AudioDevice3D`
      Specified by:
        `unpauseSample` in class `AudioEngine3D`
      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 interface `AudioDevice3D`
      Specified by:
        `updateSample` in class `AudioEngine3D`
      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 interface `AudioDevice3D`
      Specified by:
        `muteSample` in class `AudioEngine3D`
      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 interface `AudioDevice3D`
      Specified by:
        `unmuteSample` in class `AudioEngine3D`
      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 interface `AudioDevice3D`
      Overrides:
        `getSampleDuration` in class `AudioEngine3D`
      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 interface `AudioDevice3D`
      Overrides:
        `getNumberOfChannelsUsed` in class `AudioEngine3D`
      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 interface `AudioDevice3D`
      Overrides:
        `getNumberOfChannelsUsed` in class `AudioEngine3D`
      Parameters:
        `index` - device specific reference number to device driver sample
        `muted` - 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 interface `AudioDevice3D`
      Overrides:
        `getStartTime` in class `AudioEngine3D`
      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 interface `AudioDevice3D`
      Overrides:
        `setLoop` in class `AudioEngine3D`
      Parameters:
        `index` - device specific reference number to device driver sample
        `count` - number of times sample is repeated
      See Also:
        `Sound.setLoop(int)`

    - #### 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 interface `AudioDevice3DL2`
      Specified by:
        `setGain` in class `AudioEngine3DL2`
      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 interface `AudioDevice3DL2`
      Overrides:
        `setRateScaleFactor` in class `AudioEngine3DL2`
      Parameters:
        `index` - device specific reference to device driver sample
        `rateScaleFactor` - non-negative factor applied to calculated amplitudes for all sounds playing on this device
      See Also:
        `Sound.setRateScaleFactor(float)`

    - #### 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 interface `AudioDevice3DL2`
      Specified by:
        `pause` in class `AudioEngine3DL2`

    - #### 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 interface `AudioDevice3DL2`
      Specified by:
        `resume` in class `AudioEngine3DL2`

Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.