com.sun.j3d.audioengines.javasound
Class JSPositionalSample

java.lang.Object
  extended by com.sun.j3d.audioengines.Sample
      extended by com.sun.j3d.audioengines.javasound.JSSample
          extended by com.sun.j3d.audioengines.javasound.JSPositionalSample
Direct Known Subclasses:
JSDirectionalSample

 class JSPositionalSample
extends JSSample

The PostionalSample Class defines the data and methods associated with a PointSound sample played thru the AudioDevice.


Field Summary
(package private)  boolean averageDistances
           
(package private) static int AWAY
           
(package private)  Point3f[] centerEars
           
(package private)  int currentIndex
           
(package private)  long deltaTime
           
protected static boolean dopplerFlag
           
(package private)  boolean filterFlag
           
(package private)  float filterFreq
           
(package private)  int firstIndex
           
(package private)  double headPositionChange
           
(package private)  double lastActualDopplerRateRatio
           
(package private)  int lastIndex
           
(package private)  double lastRequestedDopplerRateRatio
           
(package private)  int leftDelay
           
(package private)  float leftGain
           
(package private) static int MAX_DISTANCES
           
(package private) static double maxRatio
           
(package private) static int NO_CHANGE
           
(package private)  int numDistances
           
(package private)  Point3f[] positions
           
(package private)  int reverbIndex
          A third sample for control of reverb of the stream/clip is openned and maintained for all directional/positional sounds.
(package private)  int rightDelay
           
(package private)  float rightGain
           
(package private)  int secondIndex
          For positional and directional sounds, TWO Hae streams or clips are allocated, one each for the left and right channels, played at a different (delayed) time and with a different gain value.
(package private)  double sourcePositionChange
           
(package private)  Vector3f sourceToCenterEar
          Save vectors from source source position to transformed ear parameters
(package private)  Vector3f sourceToLeftEar
           
(package private)  Vector3f sourceToRightEar
           
(package private)  long[] times
           
(package private) static int TOWARDS
           
(package private)  Vector3f xformHeadZAxis
           
(package private)  Point3f xformLeftEar
          Save ear positions transformed into VirtualWorld coords from Head coords These default positions are used when the real values cannot queried
(package private)  Point3f xformRightEar
           
 
Fields inherited from class com.sun.j3d.audioengines.javasound.JSSample
attackLength, BUFFERED_AUDIO_DATA, BUFFERED_MIDI_DATA, channel, currentRateRatio, dataOffset, dataType, loopLength, loopStartOffset, NULL_SAMPLE, positionDeactivated, rampRateFlag, rateRatio, releaseLength, sampleLength, STREAMING_AUDIO_DATA, STREAMING_MIDI_DATA, targetRateRatio, timeDeactivated, UNSUPPORTED_DATA_TYPE
 
Fields inherited from class com.sun.j3d.audioengines.Sample
angularDistance, angularFilterCutoff, angularFilterType, angularGain, attenuationDistance, attenuationGain, backAttenuationDistance, backAttenuationGain, debugFlag, direction, dirtyFlags, duration, DURATION_UNKNOWN, gain, internalErrors, loopCount, LOW_PASS, mute, NO_FILTERING, numberOfChannels, obstructionFilterCutoff, obstructionFilterType, obstructionGain, occlusionFilterCutoff, occlusionFilterType, occlusionGain, position, rateScaleFactor, soundData, soundType, vworldXfrm, vwXfrmFlag
 
Constructor Summary
JSPositionalSample()
           
 
Method Summary
(package private)  float calculateAngularGain()
           
(package private)  float calculateDistanceAttenuation(float distance)
          CalculateDistanceAttenuation Simply calls generic (for PointSound) 'findFactor()' with a single set of attenuation distance and gain scale factor arrays.
(package private)  float calculateDoppler(AuralParameters attribs)
          Set Doppler effect Rate Calculate the rate of change in for the head and sound between the two time stamps (last two times position or VirtualWorld transform was updated).
(package private)  void calculateFilter(float distance, AuralParameters attribs)
           
(package private)  boolean calculateNewEar(int dirtyFlags, View view, Point3f xformCenterEar)
           
 void clear()
          Clears the fields associated with sample data for this sound, and frees any device specific data associated with this sample.
(package private)  float findFactor(double distance, double[] distanceArray, float[] factorArray)
           
(package private)  boolean getFilterFlag()
           
(package private)  float getFilterFreq()
           
(package private)  void incrementIndices()
           
(package private)  void panSample(AuralParameters attribs)
           
 void render(int dirtyFlags, View view, AuralParameters attribs)
          Render this sample Calculate the audiodevice parameters necessary to spatially play this sound.
(package private)  void reset()
          Reset time and count based fields associated with sample data for this sound
(package private)  void setXformedPosition()
           
(package private)  void updateEar(int dirtyFlags, View view)
           
 
Methods inherited from class com.sun.j3d.audioengines.javasound.JSSample
getCurrentRateRatio, getDataType, getRampRateFlag, getTargetRateRatio, load, setCurrentRateRatio, setDataType, setRampRateFlag, setTargetRateRatio
 
Methods inherited from class com.sun.j3d.audioengines.Sample
debugPrint, debugPrintln, getDirtyFlags, getDuration, getGain, getLoopCount, getMuteFlag, getNumberOfChannelsUsed, getObstructionGain, getOcclusionGain, getRateScaleFactor, getSoundData, getSoundType, getStartTime, getVWrldXfrmFlag, setAngularAttenuation, setDirection, setDirtyFlags, setDistanceGain, setGain, setLoopCount, setMuteFlag, setObstructionFilter, setObstructionGain, setOcclusionFilter, setOcclusionGain, setPosition, setRateScaleFactor, setSoundData, setSoundType, setVWrldXfrmFlag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

leftGain

float leftGain

rightGain

float rightGain

leftDelay

int leftDelay

rightDelay

int rightDelay

dopplerFlag

protected static final boolean dopplerFlag
See Also:
Constant Field Values

secondIndex

int secondIndex
For positional and directional sounds, TWO Hae streams or clips are allocated, one each for the left and right channels, played at a different (delayed) time and with a different gain value.


reverbIndex

int reverbIndex
A third sample for control of reverb of the stream/clip is openned and maintained for all directional/positional sounds. For now, even if no aural attributes (using reverb) are active, a reverb channel is always started with the other two. A sound could be started without reverb and then reverb added later, but since there is no way to offset properly into all sounds (considering non-cached and nconsistent rate-changes during playing) this third sound is always allocated and started.


xformLeftEar

Point3f xformLeftEar
Save ear positions transformed into VirtualWorld coords from Head coords These default positions are used when the real values cannot queried


xformRightEar

Point3f xformRightEar

xformHeadZAxis

Vector3f xformHeadZAxis

sourceToCenterEar

Vector3f sourceToCenterEar
Save vectors from source source position to transformed ear parameters


sourceToRightEar

Vector3f sourceToRightEar

sourceToLeftEar

Vector3f sourceToLeftEar

averageDistances

boolean averageDistances

deltaTime

long deltaTime

sourcePositionChange

double sourcePositionChange

headPositionChange

double headPositionChange

MAX_DISTANCES

static int MAX_DISTANCES

numDistances

int numDistances

times

long[] times

positions

Point3f[] positions

centerEars

Point3f[] centerEars

firstIndex

int firstIndex

lastIndex

int lastIndex

currentIndex

int currentIndex

lastRequestedDopplerRateRatio

double lastRequestedDopplerRateRatio

lastActualDopplerRateRatio

double lastActualDopplerRateRatio

maxRatio

static double maxRatio

TOWARDS

static int TOWARDS

NO_CHANGE

static int NO_CHANGE

AWAY

static int AWAY

filterFlag

boolean filterFlag

filterFreq

float filterFreq
Constructor Detail

JSPositionalSample

public JSPositionalSample()
Method Detail

getFilterFlag

boolean getFilterFlag()
Overrides:
getFilterFlag in class JSSample

getFilterFreq

float getFilterFreq()
Overrides:
getFilterFreq in class JSSample

clear

public void clear()
Clears the fields associated with sample data for this sound, and frees any device specific data associated with this sample.

Overrides:
clear in class JSSample

reset

void reset()
Reset time and count based fields associated with sample data for this sound

Overrides:
reset in class JSSample

incrementIndices

void incrementIndices()

setXformedPosition

void setXformedPosition()

calculateDoppler

float calculateDoppler(AuralParameters attribs)
Set Doppler effect Rate Calculate the rate of change in for the head and sound between the two time stamps (last two times position or VirtualWorld transform was updated). First determine if the head and sound source are moving towards each other (distance between them is decreasing), moving away from each other (distance between them is increasing), or no change (distance is the same, not moving or moving the same speed/direction). The following equation is used for determining the change in frequency - If there has been a change in the distance between the head and sound: f' = f * frequencyScaleFactor * velocityRatio For no change in the distance bewteen head and sound, velocityRatio is 1: f' = f For head and sound moving towards each other, velocityRatio (> 1.0) is: | speedOfSound*rollOff + velocityOfHead*velocityScaleFactor | | ------------------------------------------------------------- | | speedOfSound*rollOff - velocityOfSource*velocityScaleFactor | For head and sound moving away from each other, velocityRatio (< 1.0) is: | speedOfSound*rollOff - velocityOfHead*velocityScaleFactor | | ------------------------------------------------------------- | | speedOfSound*rollOff + velocityOfSource*velocityScaleFactor | where frequencyScaleFactor, rollOff, velocityScaleFactor all come from the active AuralAttributes parameters. The following special cases must be test for AuralAttribute parameters: rolloff Value MUST be > zero for any sound to be heard! If value is zero, all sounds affected by AuralAttribute region are silent. velocityScaleFactor Value MUST be > zero for any sound to be heard! If value is zero, all sounds affected by AuralAttribute region are paused. frequencyScaleFactor Value of zero disables Doppler calculations: Sfreq' = Sfreq * frequencyScaleFactor This rate is passed to device drive as a change to playback sample rate, in this case the frequency need not be known. Return value of zero denotes no change Return value of -1 denotes ERROR


updateEar

void updateEar(int dirtyFlags,
               View view)

calculateNewEar

boolean calculateNewEar(int dirtyFlags,
                        View view,
                        Point3f xformCenterEar)

render

public void render(int dirtyFlags,
                   View view,
                   AuralParameters attribs)
Render this sample Calculate the audiodevice parameters necessary to spatially play this sound.

Overrides:
render in class JSSample

calculateAngularGain

float calculateAngularGain()

calculateFilter

void calculateFilter(float distance,
                     AuralParameters attribs)

findFactor

float findFactor(double distance,
                 double[] distanceArray,
                 float[] factorArray)

calculateDistanceAttenuation

float calculateDistanceAttenuation(float distance)
CalculateDistanceAttenuation Simply calls generic (for PointSound) 'findFactor()' with a single set of attenuation distance and gain scale factor arrays.


panSample

void panSample(AuralParameters attribs)


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