/* */ package com.sun.j3d.audioengines.headspace;
/* */
/* */ import com.sun.j3d.audioengines.AuralParameters;
/* */ import java.util.NoSuchElementException;
/* */ import javax.media.j3d.PhysicalBody;
/* */ import javax.media.j3d.RestrictedAccessException;
/* */ import javax.media.j3d.Transform3D;
/* */ import javax.media.j3d.View;
/* */ import javax.vecmath.Point3d;
/* */ import javax.vecmath.Point3f;
/* */ import javax.vecmath.Vector3f;
/* */
/* */ class HAEPositionalSample extends HAESample
/* */ {
/* */ protected static final boolean dopplerFlag = true;
/* 39 */ int secondIndex = -1;
/* */
/* 50 */ int reverbIndex = -1;
/* */
/* 56 */ Point3f xformLeftEar = new Point3f(-0.09F, -0.03F, 0.095F);
/* 57 */ Point3f xformRightEar = new Point3f(0.09F, -0.03F, 0.095F);
/* */
/* 59 */ Vector3f xformHeadZAxis = new Vector3f(0.0F, 0.0F, -1.0F);
/* */
/* 64 */ Vector3f sourceToCenterEar = new Vector3f();
/* 65 */ Vector3f sourceToRightEar = new Vector3f();
/* 66 */ Vector3f sourceToLeftEar = new Vector3f();
/* */
/* 68 */ boolean averageDistances = false;
/* 69 */ long deltaTime = 0L;
/* 70 */ double sourcePositionChange = -1.0D;
/* 71 */ double headPositionChange = -1.0D;
/* */
/* 78 */ static int MAX_DISTANCES = 4;
/* 79 */ int numDistances = 0;
/* */
/* 84 */ long[] times = new long[MAX_DISTANCES];
/* 85 */ Point3f[] positions = new Point3f[MAX_DISTANCES];
/* 86 */ Point3f[] centerEars = new Point3f[MAX_DISTANCES];
/* */
/* 91 */ int firstIndex = 0;
/* 92 */ int lastIndex = 0;
/* 93 */ int currentIndex = 0;
/* */
/* 103 */ double lastRequestedDopplerRateRatio = -1.0D;
/* 104 */ double lastActualDopplerRateRatio = -1.0D;
/* */
/* 108 */ static int TOWARDS = 1;
/* 109 */ static int NO_CHANGE = 0;
/* 110 */ static int AWAY = -1;
/* */
/* 115 */ boolean filterFlag = false;
/* 116 */ float filterFreq = -1.0F;
/* */
/* */ HAEPositionalSample()
/* */ {
/* 126 */ for (int i = 0; i < MAX_DISTANCES; i++) {
/* 127 */ this.positions[i] = new Point3f();
/* 128 */ this.centerEars[i] = new Point3f(0.09F, -0.03F, 0.095F);
/* */ }
/* 130 */ clear();
/* */ }
/* */
/* */ void setSecondIndex(int index) {
/* 134 */ this.secondIndex = index;
/* */ }
/* */
/* */ int getSecondIndex() {
/* 138 */ return this.secondIndex;
/* */ }
/* */
/* */ void setReverbIndex(int index) {
/* 142 */ this.reverbIndex = index;
/* */ }
/* */
/* */ int getReverbIndex() {
/* 146 */ return this.reverbIndex;
/* */ }
/* */
/* */ boolean getFilterFlag()
/* */ {
/* 153 */ return this.filterFlag;
/* */ }
/* */ float getFilterFreq() {
/* 156 */ return this.filterFreq;
/* */ }
/* */
/* */ public void clear()
/* */ {
/* 167 */ super.clear();
/* 168 */ this.xformLeftEar.set(-0.09F, -0.03F, 0.095F);
/* 169 */ this.xformRightEar.set(0.09F, -0.03F, 0.095F);
/* */
/* 171 */ this.xformHeadZAxis.set(0.0F, 0.0F, -1.0F);
/* 172 */ this.sourceToCenterEar.set(0.0F, 0.0F, 0.0F);
/* 173 */ this.sourceToRightEar.set(0.0F, 0.0F, 0.0F);
/* 174 */ this.sourceToLeftEar.set(0.0F, 0.0F, 0.0F);
/* 175 */ reset();
/* */ }
/* */
/* */ void reset()
/* */ {
/* 187 */ super.reset();
/* 188 */ this.averageDistances = false;
/* 189 */ this.deltaTime = 0L;
/* 190 */ this.sourcePositionChange = -1.0D;
/* 191 */ this.headPositionChange = -1.0D;
/* 192 */ this.numDistances = 0;
/* 193 */ this.averageDistances = false;
/* */ }
/* */
/* */ void incrementIndices()
/* */ {
/* 200 */ int maxIndex = MAX_DISTANCES - 1;
/* 201 */ if (this.numDistances < maxIndex) {
/* 202 */ this.averageDistances = false;
/* 203 */ this.currentIndex = this.numDistances;
/* 204 */ this.lastIndex = (this.currentIndex - 1);
/* 205 */ this.firstIndex = 0;
/* 206 */ this.numDistances += 1;
/* */ }
/* 208 */ else if (this.numDistances == maxIndex)
/* */ {
/* 211 */ this.averageDistances = true;
/* 212 */ this.currentIndex = maxIndex;
/* 213 */ this.lastIndex = (this.currentIndex - 1);
/* 214 */ this.firstIndex = 0;
/* 215 */ this.numDistances += 1;
/* */ }
/* 217 */ else if (this.numDistances > maxIndex)
/* */ {
/* 219 */ this.averageDistances = true;
/* 220 */ this.currentIndex += 1;
/* 221 */ this.lastIndex += 1;
/* 222 */ this.firstIndex += 1;
/* 223 */ this.currentIndex %= MAX_DISTANCES;
/* 224 */ this.lastIndex %= MAX_DISTANCES;
/* 225 */ this.firstIndex %= MAX_DISTANCES;
/* */ }
/* */ }
/* */
/* */ void setXformedPosition()
/* */ {
/* 237 */ Point3f newPosition = new Point3f();
/* */
/* 241 */ if (getVWrldXfrmFlag())
/* */ {
/* 244 */ this.vworldXfrm.transform(this.position, newPosition);
/* */ }
/* */ else
/* */ {
/* 249 */ newPosition.set(this.position);
/* */ }
/* */
/* 252 */ if ((newPosition.x == this.positions[this.currentIndex].x) && (newPosition.y == this.positions[this.currentIndex].y) && (newPosition.z == this.positions[this.currentIndex].z))
/* */ {
/* 257 */ return;
/* */ }
/* */
/* 260 */ incrementIndices();
/* */
/* 262 */ this.times[this.currentIndex] = System.currentTimeMillis();
/* 263 */ this.positions[this.currentIndex].set(newPosition);
/* */
/* 273 */ if (this.numDistances > 1)
/* 274 */ this.centerEars[this.currentIndex].set(this.centerEars[this.lastIndex]);
/* */ }
/* */
/* */ float calculateDoppler(AuralParameters attribs)
/* */ {
/* 330 */ double sampleRateRatio = 1.0D;
/* 331 */ double headVelocity = 0.0D;
/* 332 */ double soundVelocity = 0.0D;
/* 333 */ double distanceSourceToHead = 0.0D;
/* 334 */ double lastDistanceSourceToHead = 0.0D;
/* 335 */ float speedOfSound = 0.344F;
/* 336 */ double numerator = 1.0D;
/* 337 */ double denominator = 1.0D;
/* 338 */ int direction = NO_CHANGE;
/* */
/* 344 */ float averagedSoundDistances = 0.0F;
/* 345 */ float averagedEarsDistances = 0.0F;
/* */
/* 351 */ if (!this.averageDistances)
/* */ {
/* 354 */ debugPrint("HAEPositionalSample.calculateDoppler - not enough distance data collected, dopplerRatio set to zero");
/* */
/* 358 */ return 0.0F;
/* */ }
/* */
/* 361 */ Point3f lastXformPosition = this.positions[this.lastIndex];
/* 362 */ Point3f lastXformCenterEar = this.centerEars[this.lastIndex];
/* 363 */ Point3f xformPosition = this.positions[this.currentIndex];
/* 364 */ Point3f xformCenterEar = this.centerEars[this.currentIndex];
/* 365 */ distanceSourceToHead = xformPosition.distance(xformCenterEar);
/* 366 */ lastDistanceSourceToHead = lastXformPosition.distance(lastXformCenterEar);
/* */
/* 368 */ debugPrint("HAEPositionalSample.calculateDoppler - distances: current,last = " + distanceSourceToHead + ", " + lastDistanceSourceToHead);
/* */
/* 371 */ debugPrint(" current position = " + xformPosition.x + ", " + xformPosition.y + ", " + xformPosition.z);
/* */
/* 375 */ debugPrint(" current ear = " + xformCenterEar.x + ", " + xformCenterEar.y + ", " + xformCenterEar.z);
/* */
/* 379 */ debugPrint(" last position = " + lastXformPosition.x + ", " + lastXformPosition.y + ", " + lastXformPosition.z);
/* */
/* 383 */ debugPrint(" last ear = " + lastXformCenterEar.x + ", " + lastXformCenterEar.y + ", " + lastXformCenterEar.z);
/* */
/* 388 */ if (distanceSourceToHead == lastDistanceSourceToHead)
/* */ {
/* 391 */ debugPrint("HAEPositionalSample.calculateDoppler - distance diff = 0, dopplerRatio set to zero");
/* */
/* 394 */ return 0.0F;
/* */ }
/* */
/* 397 */ this.deltaTime = (this.times[this.currentIndex] - this.times[this.firstIndex]);
/* 398 */ for (int i = 0; i < MAX_DISTANCES - 1; i++) {
/* 399 */ averagedSoundDistances += this.positions[(i + 1)].distance(this.positions[i]);
/* 400 */ averagedEarsDistances += this.centerEars[(i + 1)].distance(this.centerEars[i]);
/* */ }
/* 402 */ averagedSoundDistances /= (MAX_DISTANCES - 1);
/* 403 */ averagedEarsDistances /= (MAX_DISTANCES - 1);
/* 404 */ soundVelocity = averagedSoundDistances / (float)this.deltaTime;
/* 405 */ headVelocity = averagedEarsDistances / (float)this.deltaTime;
/* */
/* 407 */ debugPrint(" delta time = " + this.deltaTime);
/* */
/* 409 */ debugPrint(" soundPosition delta = " + xformPosition.distance(lastXformPosition));
/* */
/* 412 */ debugPrint(" soundVelocity = " + soundVelocity);
/* */
/* 414 */ debugPrint(" headPosition delta = " + xformCenterEar.distance(lastXformCenterEar));
/* */
/* 417 */ debugPrint(" headVelocity = " + headVelocity);
/* */
/* 420 */ if (attribs != null)
/* */ {
/* 422 */ float rolloff = attribs.rolloff;
/* 423 */ float velocityScaleFactor = attribs.velocityScaleFactor;
/* 424 */ if (rolloff != 1.0F) {
/* 425 */ speedOfSound *= rolloff;
/* */
/* 427 */ debugPrint(" attrib rollof = " + rolloff);
/* */ }
/* */
/* 430 */ if (velocityScaleFactor != 1.0F) {
/* 431 */ soundVelocity *= velocityScaleFactor;
/* 432 */ headVelocity *= velocityScaleFactor;
/* */
/* 434 */ debugPrint(" attrib velocity scale factor = " + velocityScaleFactor);
/* */
/* 437 */ debugPrint(" new soundVelocity = " + soundVelocity);
/* */
/* 439 */ debugPrint(" new headVelocity = " + headVelocity);
/* */ }
/* */
/* */ }
/* */
/* 444 */ if (distanceSourceToHead < lastDistanceSourceToHead)
/* */ {
/* 447 */ debugPrint(" moving towards...");
/* */
/* 449 */ direction = TOWARDS;
/* 450 */ numerator = speedOfSound + headVelocity;
/* 451 */ denominator = speedOfSound - soundVelocity;
/* */ }
/* */ else
/* */ {
/* 457 */ debugPrint(" moving away...");
/* */
/* 459 */ direction = AWAY;
/* 460 */ numerator = speedOfSound - headVelocity;
/* 461 */ denominator = speedOfSound + soundVelocity;
/* */ }
/* 463 */ if (numerator <= 0.0D)
/* */ {
/* 465 */ debugPrint("HAEPositionalSample.calculateDoppler: BOOM!! - velocity of head > speed of sound");
/* */
/* 467 */ return -1.0F;
/* */ }
/* 469 */ if (denominator <= 0.0D)
/* */ {
/* 471 */ debugPrint("HAEPositionalSample.calculateDoppler: BOOM!! - velocity of sound source negative");
/* */
/* 473 */ return -1.0F;
/* */ }
/* */
/* 477 */ debugPrint("HAEPositionalSample.calculateDoppler: numerator = " + numerator + ", denominator = " + denominator);
/* */
/* 480 */ sampleRateRatio = numerator / denominator;
/* */
/* 482 */ return (float)sampleRateRatio;
/* */ }
/* */
/* */ void updateEar(int dirtyFlags, View view)
/* */ {
/* 489 */ Point3f xformCenterEar = new Point3f();
/* 490 */ if (!calculateNewEar(dirtyFlags, view, xformCenterEar))
/* */ {
/* 493 */ return;
/* */ }
/* */
/* 496 */ if ((xformCenterEar.x == this.centerEars[this.currentIndex].x) && (xformCenterEar.y == this.centerEars[this.currentIndex].y) && (xformCenterEar.z == this.centerEars[this.currentIndex].z))
/* */ {
/* 501 */ return;
/* */ }
/* */
/* 504 */ incrementIndices();
/* 505 */ this.times[this.currentIndex] = System.currentTimeMillis();
/* 506 */ this.centerEars[this.currentIndex].set(xformCenterEar);
/* */
/* 509 */ if (this.numDistances > 1)
/* 510 */ this.positions[this.currentIndex].set(this.positions[this.lastIndex]);
/* */ }
/* */
/* */ boolean calculateNewEar(int dirtyFlags, View view, Point3f xformCenterEar)
/* */ {
/* 517 */ Point3d earPosition = new Point3d();
/* */
/* 521 */ boolean earsXformed = false;
/* 522 */ if ((!earsXformed) &&
/* 523 */ (view != null)) {
/* 524 */ PhysicalBody body = view.getPhysicalBody();
/* 525 */ if (body != null)
/* */ {
/* 530 */ Transform3D headToVwrld = new Transform3D();
/* */ try {
/* 532 */ view.getUserHeadToVworld(headToVwrld);
/* */ }
/* */ catch (NoSuchElementException e)
/* */ {
/* */ }
/* */ catch (RestrictedAccessException e2)
/* */ {
/* */ }
/* */
/* 556 */ body.getLeftEarPosition(earPosition);
/* 557 */ this.xformLeftEar.x = ((float)earPosition.x);
/* 558 */ this.xformLeftEar.y = ((float)earPosition.y);
/* 559 */ this.xformLeftEar.z = ((float)earPosition.z);
/* 560 */ body.getRightEarPosition(earPosition);
/* 561 */ this.xformRightEar.x = ((float)earPosition.x);
/* 562 */ this.xformRightEar.y = ((float)earPosition.y);
/* 563 */ this.xformRightEar.z = ((float)earPosition.z);
/* 564 */ headToVwrld.transform(this.xformRightEar);
/* 565 */ headToVwrld.transform(this.xformLeftEar);
/* */
/* 567 */ this.xformHeadZAxis.set(0.0F, 0.0F, -1.0F);
/* 568 */ headToVwrld.transform(this.xformHeadZAxis);
/* */
/* 572 */ xformCenterEar.x = (this.xformLeftEar.x + (this.xformRightEar.x - this.xformLeftEar.x) * 0.5F);
/* */
/* 574 */ xformCenterEar.y = (this.xformLeftEar.y + (this.xformRightEar.y - this.xformLeftEar.y) * 0.5F);
/* */
/* 576 */ xformCenterEar.z = (this.xformLeftEar.z + (this.xformRightEar.z - this.xformLeftEar.z) * 0.5F);
/* */
/* 587 */ earsXformed = true;
/* */ }
/* */
/* */ }
/* */
/* 595 */ if (!earsXformed);
/* 600 */ return earsXformed;
/* */ }
/* */
/* */ public void render(int dirtyFlags, View view, AuralParameters attribs)
/* */ {
/* 612 */ updateEar(dirtyFlags, view);
/* */
/* 628 */ float dopplerRatio = 1.0F;
/* 629 */ if (attribs != null) {
/* 630 */ float rolloff = attribs.rolloff;
/* 631 */ float frequencyScaleFactor = attribs.frequencyScaleFactor;
/* 632 */ float velocityScaleFactor = attribs.velocityScaleFactor;
/* */
/* 634 */ debugPrint("HAEPositionalSample: attribs NOT null");
/* 635 */ if (rolloff > 0.0F)
/* */ {
/* 641 */ if (frequencyScaleFactor > 0.0F)
/* */ {
/* 648 */ if (velocityScaleFactor > 0.0F)
/* */ {
/* 650 */ debugPrint(" velocityScaleFactor = " + velocityScaleFactor);
/* */
/* 657 */ dopplerRatio = calculateDoppler(attribs);
/* */
/* 659 */ if (dopplerRatio != 0.0F)
/* */ {
/* 667 */ if (dopplerRatio != -1.0F)
/* */ {
/* 677 */ if (dopplerRatio > 0.0F)
/* */ {
/* 679 */ setTargetRateRatio(dopplerRatio * frequencyScaleFactor * this.rateScaleFactor);
/* */ }
/* */
/* */ }
/* */
/* */ }
/* */
/* */ }
/* */ else
/* */ {
/* 696 */ setTargetRateRatio(frequencyScaleFactor * this.rateScaleFactor);
/* */ }
/* */ }
/* */
/* */ }
/* */
/* */ }
/* */ else
/* */ {
/* 705 */ debugPrint("HAEPositionalSample: attribs null");
/* 706 */ setTargetRateRatio(this.rateScaleFactor);
/* */ }
/* */
/* 709 */ panSample(attribs);
/* */ }
/* */
/* */ float calculateAngularGain()
/* */ {
/* 725 */ return 1.0F;
/* */ }
/* */
/* */ void calculateFilter(float distance, AuralParameters attribs)
/* */ {
/* 747 */ float distanceFilter = 44100.0F;
/* 748 */ float angularFilter = 44100.0F;
/* 749 */ int arrayLength = attribs.getDistanceFilterLength();
/* 750 */ int filterType = attribs.getDistanceFilterType();
/* 751 */ boolean distanceFilterFound = false;
/* 752 */ boolean angularFilterFound = false;
/* 753 */ if ((filterType != -1) && (arrayLength > 0)) {
/* 754 */ double[] distanceArray = new double[arrayLength];
/* 755 */ float[] cutoffArray = new float[arrayLength];
/* 756 */ attribs.getDistanceFilter(distanceArray, cutoffArray);
/* */
/* 763 */ distanceFilter = findFactor(distance, distanceArray, cutoffArray);
/* */
/* 765 */ if (distanceFilter < 0.0F)
/* 766 */ distanceFilterFound = false;
/* */ else
/* 768 */ distanceFilterFound = true;
/* */ }
/* */ else {
/* 771 */ distanceFilterFound = false;
/* 772 */ distanceFilter = -1.0F;
/* */ }
/* */
/* 779 */ angularFilterFound = false;
/* 780 */ angularFilter = -1.0F;
/* */
/* 782 */ this.filterFlag = ((distanceFilterFound) || (angularFilterFound));
/* 783 */ this.filterFreq = distanceFilter;
/* */ }
/* */
/* */ float findFactor(double distance, double[] distanceArray, float[] factorArray)
/* */ {
/* 818 */ if ((distanceArray == null) || (factorArray == null))
/* */ {
/* 821 */ return -1.0F;
/* */ }
/* 823 */ int arrayLength = distanceArray.length;
/* 824 */ if (arrayLength < 2)
/* */ {
/* 827 */ return -1.0F;
/* */ }
/* 829 */ int largestIndex = arrayLength - 1;
/* */
/* 834 */ if (distance >= distanceArray[largestIndex])
/* */ {
/* 840 */ return factorArray[largestIndex];
/* */ }
/* 842 */ if (distance <= distanceArray[0])
/* */ {
/* 846 */ return factorArray[0];
/* */ }
/* */
/* 853 */ int lowIndex = 0;
/* 854 */ int highIndex = largestIndex;
/* */
/* 857 */ while (lowIndex < highIndex - 1)
/* */ {
/* 871 */ if (distanceArray[lowIndex] >= distance) {
/* 872 */ if (distance < distanceArray[lowIndex]);
/* 884 */ return factorArray[lowIndex];
/* */ }
/* 886 */ if (distanceArray[highIndex] <= distance) {
/* 887 */ if (distance > distanceArray[highIndex]);
/* 899 */ return factorArray[highIndex];
/* */ }
/* 901 */ if ((distance > distanceArray[lowIndex]) && (distance < distanceArray[highIndex]))
/* */ {
/* 903 */ int indexMid = lowIndex + (highIndex - lowIndex) / 2;
/* 904 */ if (distance <= distanceArray[indexMid])
/* */ {
/* 906 */ highIndex = indexMid;
/* */ }
/* 908 */ else lowIndex = indexMid;
/* */
/* */ }
/* */
/* */ }
/* */
/* 927 */ float outputFactor = (float)((distance - distanceArray[lowIndex]) / (distanceArray[highIndex] - distanceArray[lowIndex])) * (factorArray[highIndex] - factorArray[lowIndex]) + factorArray[lowIndex];
/* */
/* 934 */ return outputFactor;
/* */ }
/* */
/* */ float calculateDistanceAttenuation(float distance)
/* */ {
/* 945 */ float factor = 1.0F;
/* 946 */ factor = findFactor(distance, this.attenuationDistance, this.attenuationGain);
/* */
/* 948 */ if (factor >= 0.0D) {
/* 949 */ return factor;
/* */ }
/* 951 */ return 1.0F;
/* */ }
/* */
/* */ void panSample(AuralParameters attribs)
/* */ {
/* 964 */ int quadrant = 1;
/* 965 */ float intensityHigh = 1.0F;
/* 966 */ float intensityLow = 0.125F;
/* 967 */ float intensityDifference = intensityHigh - intensityLow;
/* */
/* 978 */ float nearZero = 1.0E-006F;
/* 979 */ float nearOne = 0.999999F;
/* 980 */ float nearNegativeOne = -nearOne;
/* 981 */ float halfPi = 1.570796F;
/* */
/* 986 */ float distanceSourceToCenterEar = 0.0F;
/* 987 */ float lastDistanceSourceToCenterEar = 0.0F;
/* 988 */ float distanceSourceToRightEar = 0.0F;
/* 989 */ float distanceSourceToLeftEar = 0.0F;
/* 990 */ float distanceBetweenEars = 0.18F;
/* 991 */ float radiusOfHead = 0.0F;
/* 992 */ float radiusOverDistanceToSource = 0.0F;
/* */
/* 994 */ float alpha = 0.0F;
/* 995 */ float sinAlpha = 0.0F;
/* 996 */ float gamma = 0.0F;
/* */
/* 999 */ float speedOfSound = 0.344F;
/* 1000 */ float invSpeedOfSound = 1.0F / 0.344F;
/* */
/* 1002 */ float sampleRate = 44.099998F;
/* */
/* 1004 */ boolean rightEarClosest = false;
/* 1005 */ boolean soundFromBehind = false;
/* */
/* 1007 */ float distanceGain = 1.0F;
/* 1008 */ float allGains = this.gain;
/* */
/* 1010 */ Point3f workingPosition = new Point3f();
/* 1011 */ Point3f workingCenterEar = new Point3f();
/* */
/* 1015 */ Vector3f mixScale = new Vector3f();
/* */
/* 1018 */ workingPosition.set(this.positions[this.currentIndex]);
/* 1019 */ workingCenterEar.set(this.centerEars[this.currentIndex]);
/* */
/* 1037 */ this.sourceToCenterEar.x = (workingCenterEar.x - workingPosition.x);
/* 1038 */ this.sourceToCenterEar.y = (workingCenterEar.y - workingPosition.y);
/* 1039 */ this.sourceToCenterEar.z = (workingCenterEar.z - workingPosition.z);
/* 1040 */ this.sourceToRightEar.x = (this.xformRightEar.x - workingPosition.x);
/* 1041 */ this.sourceToRightEar.y = (this.xformRightEar.y - workingPosition.y);
/* 1042 */ this.sourceToRightEar.z = (this.xformRightEar.z - workingPosition.z);
/* 1043 */ this.sourceToLeftEar.x = (this.xformLeftEar.x - workingPosition.x);
/* 1044 */ this.sourceToLeftEar.y = (this.xformLeftEar.y - workingPosition.y);
/* 1045 */ this.sourceToLeftEar.z = (this.xformLeftEar.z - workingPosition.z);
/* */
/* 1053 */ distanceSourceToCenterEar = workingPosition.distance(workingCenterEar);
/* 1054 */ distanceSourceToRightEar = workingPosition.distance(this.xformRightEar);
/* 1055 */ distanceSourceToLeftEar = workingPosition.distance(this.xformLeftEar);
/* 1056 */ distanceBetweenEars = this.xformRightEar.distance(this.xformLeftEar);
/* */
/* 1061 */ radiusOfHead = distanceBetweenEars * 0.5F;
/* */
/* 1064 */ radiusOverDistanceToSource = radiusOfHead / distanceSourceToCenterEar;
/* */
/* 1082 */ double dotProduct = this.sourceToCenterEar.dot(this.xformHeadZAxis) / (this.sourceToCenterEar.length() * this.xformHeadZAxis.length());
/* */
/* 1087 */ alpha = (float)Math.acos(dotProduct);
/* */
/* 1091 */ if (alpha > halfPi)
/* */ {
/* 1094 */ soundFromBehind = true;
/* 1095 */ alpha = 3.141593F - alpha;
/* */ }
/* */ else
/* */ {
/* 1100 */ soundFromBehind = false;
/* */ }
/* */
/* 1105 */ gamma = (float)Math.acos(radiusOverDistanceToSource);
/* */
/* 1109 */ rightEarClosest = distanceSourceToRightEar <= distanceSourceToLeftEar;
/* */
/* 1114 */ if (rightEarClosest)
/* */ {
/* 1117 */ if (soundFromBehind)
/* 1118 */ quadrant = 4;
/* */ else {
/* 1120 */ quadrant = 1;
/* */ }
/* */
/* */ }
/* 1125 */ else if (soundFromBehind)
/* 1126 */ quadrant = 3;
/* */ else {
/* 1128 */ quadrant = 2;
/* */ }
/* 1130 */ sinAlpha = (float)Math.sin(alpha);
/* 1131 */ if (sinAlpha < 0.0D) sinAlpha = -sinAlpha;
/* */
/* 1140 */ float DISTANCE = (float)Math.sqrt(distanceSourceToCenterEar * distanceSourceToCenterEar + radiusOfHead * radiusOfHead);
/* */
/* 1146 */ if (rightEarClosest) {
/* 1147 */ distanceSourceToLeftEar = DISTANCE + radiusOfHead * (halfPi + alpha - gamma);
/* */ }
/* */ else
/* */ {
/* 1154 */ distanceSourceToRightEar = DISTANCE + radiusOfHead * (halfPi + alpha - gamma);
/* */ }
/* */
/* 1166 */ if (sinAlpha < radiusOverDistanceToSource)
/* */ {
/* 1171 */ if (rightEarClosest) {
/* 1172 */ distanceSourceToRightEar = DISTANCE + radiusOfHead * (halfPi - alpha - gamma);
/* */ }
/* */ else
/* */ {
/* 1179 */ distanceSourceToLeftEar = DISTANCE + radiusOfHead * (halfPi - alpha - gamma);
/* */ }
/* */
/* */ }
/* 1189 */ else if (!rightEarClosest);
/* 1210 */ sampleRate = this.rate * 0.001F;
/* 1211 */ if (rightEarClosest) {
/* 1212 */ this.rightDelay = 0;
/* 1213 */ this.leftDelay = ((int)((distanceSourceToLeftEar - distanceSourceToRightEar) * invSpeedOfSound * sampleRate));
/* */ }
/* */ else
/* */ {
/* 1217 */ this.leftDelay = 0;
/* 1218 */ this.rightDelay = ((int)((distanceSourceToRightEar - distanceSourceToLeftEar) * invSpeedOfSound * sampleRate));
/* */ }
/* */
/* 1231 */ workingPosition.sub(workingCenterEar);
/* */
/* 1233 */ workingPosition.scale(1.0F / distanceSourceToCenterEar);
/* */
/* 1244 */ distanceGain = calculateDistanceAttenuation(distanceSourceToCenterEar);
/* */
/* 1246 */ allGains *= distanceGain;
/* */
/* 1254 */ allGains *= calculateAngularGain();
/* */
/* 1258 */ float halfX = workingPosition.x / 2.0F;
/* */ float intensityOffset;
/* */ float intensityOffset;
/* 1259 */ if (halfX >= 0.0F)
/* 1260 */ intensityOffset = intensityDifference * (0.5F - halfX);
/* */ else {
/* 1262 */ intensityOffset = intensityDifference * (0.5F + halfX);
/* */ }
/* */
/* 1269 */ switch (quadrant)
/* */ {
/* */ case 1:
/* */ case 4:
/* 1274 */ this.rightGain = (allGains * (intensityHigh - intensityOffset));
/* 1275 */ this.leftGain = (allGains * (intensityLow + intensityOffset));
/* 1276 */ break;
/* */ case 2:
/* */ case 3:
/* 1282 */ this.leftGain = (allGains * (intensityHigh - intensityOffset));
/* 1283 */ this.rightGain = (allGains * (intensityLow + intensityOffset));
/* */ }
/* */
/* 1292 */ calculateFilter(distanceSourceToCenterEar, attribs);
/* */ }
/* */ }
/* Location: Z:\System\Library\Java\Extensions\j3daudio.jar
* Qualified Name: com.sun.j3d.audioengines.headspace.HAEPositionalSample
* JD-Core Version: 0.6.2
*/