/* */ package com.sun.j3d.audioengines.headspace;
/* */
/* */ import com.sun.j3d.audioengines.AudioEngine3DL2;
/* */ import com.sun.j3d.audioengines.AuralParameters;
/* */ import java.io.InputStream;
/* */ import java.net.URL;
/* */ import java.util.ArrayList;
/* */ import javax.media.j3d.MediaContainer;
/* */ import javax.media.j3d.PhysicalEnvironment;
/* */ import javax.media.j3d.Transform3D;
/* */ import javax.vecmath.Point3d;
/* */ import javax.vecmath.Vector3d;
/* */
/* */ public class HeadspaceMixer extends AudioEngine3DL2
/* */ {
/* */ static final boolean debugFlag = false;
/* */ static final boolean internalErrors = false;
/* */ static final int ADD_TO_LIST = 1;
/* */ static final int SET_INTO_LIST = 2;
/* 64 */ static int REFLECTION_COEFF_CHANGED = 1;
/* 65 */ static int REVERB_DELAY_CHANGED = 2;
/* 66 */ static int REVERB_ORDER_CHANGED = 4;
/* */
/* 68 */ int reverbDirty = 65535;
/* 69 */ boolean reverbOn = false;
/* 70 */ int reverbType = 1;
/* */
/* 74 */ HeadspaceThread thread = null;
/* */
/* 79 */ protected float deviceGain = 1.0F;
/* */ protected static final int NOT_PAUSED = 0;
/* */ protected static final int PAUSE_PENDING = 1;
/* */ protected static final int PAUSED = 2;
/* */ protected static final int RESUME_PENDING = 3;
/* 85 */ protected int pause = 0;
/* */
/* */ void debugPrint(String message) {
/* */ }
/* */
/* */ void debugPrintln(String message) {
/* */ }
/* */
/* */ public HeadspaceMixer(PhysicalEnvironment physicalEnvironment) {
/* 94 */ super(physicalEnvironment);
/* 95 */ this.thread = new HeadspaceThread(Thread.currentThread().getThreadGroup(), this);
/* */ }
/* */
/* */ public int getTotalChannels()
/* */ {
/* 109 */ return J3DHaeStream.getTotalChannels();
/* */ }
/* */
/* */ public boolean initialize()
/* */ {
/* 120 */ if (!J3DHaeStream.initialize())
/* */ {
/* 125 */ return false;
/* */ }
/* */
/* 128 */ this.thread.initialize();
/* */
/* 131 */ return true;
/* */ }
/* */
/* */ public boolean close()
/* */ {
/* 139 */ if (J3DHaeStream.close())
/* */ {
/* 142 */ return true;
/* */ }
/* */
/* 147 */ return false;
/* */ }
/* */
/* */ int loadSound(MediaContainer soundData)
/* */ {
/* 154 */ int index = -1;
/* */
/* 156 */ int dataType = -1;
/* */
/* 160 */ String path = soundData.getURLString();
/* 161 */ URL url = soundData.getURLObject();
/* 162 */ InputStream inputStream = soundData.getInputStream();
/* 163 */ boolean cacheFlag = soundData.getCacheEnable();
/* 164 */ if (url != null) {
/* 165 */ index = J3DHaeStream.initAudioContainer(url, cacheFlag);
/* */ }
/* 168 */ else if (path != null)
/* */ {
/* */ try
/* */ {
/* 174 */ url = new URL(path);
/* */ }
/* */ catch (Exception e)
/* */ {
/* 180 */ return -1;
/* */ }
/* 182 */ index = J3DHaeStream.initAudioContainer(url, cacheFlag);
/* */ }
/* 185 */ else if (inputStream != null) {
/* 186 */ index = J3DHaeStream.initAudioContainer(inputStream, cacheFlag);
/* */ }
/* */
/* 190 */ if (index == -1)
/* */ {
/* 193 */ return -1;
/* */ }
/* */
/* 196 */ if (index < 0)
/* */ {
/* 200 */ return -1;
/* */ }
/* 202 */ dataType = J3DHaeStream.getDataType(index);
/* 203 */ if (dataType == -1)
/* */ {
/* 207 */ return -1;
/* */ }
/* */ int error;
/* */ int error;
/* 209 */ if (dataType == 2)
/* */ {
/* */ int error;
/* 214 */ if (inputStream != null)
/* 215 */ error = J3DHaeClip.loadSample(inputStream, index);
/* */ else
/* 217 */ error = J3DHaeClip.loadSample(url, index);
/* */ }
/* */ else
/* */ {
/* */ int error;
/* 219 */ if (dataType == 1)
/* */ {
/* */ int error;
/* 224 */ if (inputStream != null)
/* 225 */ error = J3DHaeStream.loadSample(inputStream, index);
/* */ else
/* 227 */ error = J3DHaeStream.loadSample(url, index);
/* */ }
/* */ else
/* */ {
/* */ int error;
/* 234 */ if (inputStream != null)
/* 235 */ error = -1;
/* */ else
/* 237 */ error = J3DHaeMidi.loadSample(url, index);
/* */ }
/* */ }
/* 239 */ if (error < 0)
/* */ {
/* 244 */ return -1;
/* */ }
/* */
/* 250 */ return index;
/* */ }
/* */
/* */ public int prepareSound(int soundType, MediaContainer soundData)
/* */ {
/* 269 */ int index = -1;
/* 270 */ if (soundData == null) {
/* 271 */ index = loadSound(null);
/* 272 */ return index;
/* */ }
/* */
/* 275 */ HAESample sample = null;
/* 276 */ HAEPositionalSample posSample = null;
/* 277 */ HAEDirectionalSample dirSample = null;
/* 278 */ int methodType = 1;
/* 279 */ index = loadSound(soundData);
/* */
/* 281 */ int dataType = J3DHaeStream.getDataType(index);
/* 282 */ if (dataType == -1)
/* */ {
/* 285 */ return -1;
/* */ }
/* */
/* 291 */ synchronized (this.samples) {
/* 292 */ int samplesSize = this.samples.size();
/* 293 */ if (index >= samplesSize) {
/* 294 */ this.samples.ensureCapacity(index + 1);
/* 295 */ methodType = 1;
/* */
/* 300 */ for (int i = samplesSize; i < index; i++)
/* */ {
/* 303 */ this.samples.add(i, null);
/* */ }
/* */ }
/* */ else {
/* 307 */ methodType = 2;
/* */ }
/* */
/* 313 */ if (soundType == 3)
/* */ {
/* 316 */ dirSample = new HAEDirectionalSample();
/* 317 */ if (methodType == 2)
/* 318 */ this.samples.set(index, dirSample);
/* */ else
/* 320 */ this.samples.add(index, dirSample);
/* 321 */ sample = dirSample;
/* 322 */ posSample = dirSample;
/* */ }
/* 325 */ else if (soundType == 2)
/* */ {
/* 328 */ posSample = new HAEPositionalSample();
/* 329 */ if (methodType == 2)
/* 330 */ this.samples.set(index, posSample);
/* */ else
/* 332 */ this.samples.add(index, posSample);
/* 333 */ sample = posSample;
/* */ }
/* */ else
/* */ {
/* 338 */ sample = new HAESample();
/* 339 */ if (methodType == 2)
/* 340 */ this.samples.set(index, sample);
/* */ else {
/* 342 */ this.samples.add(index, sample);
/* */ }
/* */
/* */ }
/* */
/* 353 */ if ((posSample != null) && (dataType != 3) && (dataType != 3))
/* */ {
/* 357 */ int secondIndex = -1;
/* 358 */ int reverbIndex = -1;
/* */
/* 361 */ secondIndex = loadSound(soundData);
/* 362 */ reverbIndex = loadSound(soundData);
/* 363 */ if ((secondIndex == -1) || (reverbIndex == -1))
/* */ {
/* 372 */ clearSound(index);
/* 373 */ if (secondIndex != -1)
/* 374 */ clearSound(secondIndex);
/* 375 */ this.samples.set(index, null);
/* 376 */ return -1;
/* */ }
/* */
/* 385 */ int highestIndex = -1;
/* 386 */ if (secondIndex < reverbIndex)
/* 387 */ highestIndex = reverbIndex;
/* */ else
/* 389 */ highestIndex = secondIndex;
/* 390 */ int oldSamplesSize = this.samples.size();
/* 391 */ if (highestIndex >= oldSamplesSize)
/* */ {
/* 395 */ this.samples.ensureCapacity(highestIndex + 1);
/* */ }
/* */
/* 398 */ if (secondIndex >= oldSamplesSize) {
/* 399 */ methodType = 1;
/* */
/* 403 */ this.samples.add(secondIndex, sample);
/* */ }
/* */ else {
/* 406 */ methodType = 2;
/* */
/* 410 */ this.samples.set(secondIndex, sample);
/* */ }
/* 412 */ posSample.setSecondIndex(secondIndex);
/* */
/* 414 */ if (reverbIndex >= oldSamplesSize) {
/* 415 */ methodType = 1;
/* */
/* 419 */ this.samples.add(reverbIndex, sample);
/* */ }
/* */ else {
/* 422 */ methodType = 2;
/* */
/* 426 */ this.samples.set(reverbIndex, sample);
/* */ }
/* 428 */ posSample.setReverbIndex(reverbIndex);
/* */ }
/* */
/* */ }
/* */
/* 437 */ sample.setDirtyFlags(65535);
/* 438 */ sample.setSoundType(soundType);
/* 439 */ sample.setSoundData(soundData);
/* */
/* 441 */ int rate = J3DHaeStream.getSampleRate(index);
/* */
/* 443 */ sample.setRate(rate);
/* */
/* 445 */ sample.setDataType(dataType);
/* */
/* 450 */ return index;
/* */ }
/* */
/* */ public void clearSound(int index)
/* */ {
/* 458 */ HAESample sample = null;
/* 459 */ if ((sample = (HAESample)getSample(index)) == null)
/* 460 */ return;
/* 461 */ sample.clear();
/* 462 */ synchronized (this.samples) {
/* 463 */ this.samples.set(index, null);
/* */ }
/* */ }
/* */
/* */ public void setVworldXfrm(int index, Transform3D trans)
/* */ {
/* 473 */ super.setVworldXfrm(index, trans);
/* */
/* 487 */ HAESample sample = null;
/* 488 */ if ((sample = (HAESample)getSample(index)) == null)
/* 489 */ return;
/* 490 */ int soundType = sample.getSoundType();
/* */
/* 492 */ if (soundType == 3) {
/* 493 */ HAEDirectionalSample dirSample = null;
/* 494 */ if ((dirSample = (HAEDirectionalSample)getSample(index)) == null)
/* 495 */ return;
/* 496 */ dirSample.setXformedDirection();
/* 497 */ dirSample.setXformedPosition();
/* */
/* 499 */ dirSample.setVWrldXfrmFlag(true);
/* */ }
/* 501 */ else if (soundType == 2) {
/* 502 */ HAEPositionalSample posSample = null;
/* 503 */ if ((posSample = (HAEPositionalSample)getSample(index)) == null)
/* 504 */ return;
/* 505 */ posSample.setXformedPosition();
/* */
/* 507 */ posSample.setVWrldXfrmFlag(true);
/* */ }
/* */ }
/* */
/* */ public void setPosition(int index, Point3d position)
/* */ {
/* 515 */ super.setPosition(index, position);
/* 516 */ HAEPositionalSample posSample = null;
/* 517 */ if ((posSample = (HAEPositionalSample)getSample(index)) == null)
/* 518 */ return;
/* 519 */ int soundType = posSample.getSoundType();
/* 520 */ if ((soundType == 2) || (soundType == 3))
/* */ {
/* 522 */ posSample.setXformedPosition();
/* */ }
/* */ }
/* */
/* */ public void setDirection(int index, Vector3d direction)
/* */ {
/* 530 */ super.setDirection(index, direction);
/* 531 */ HAEDirectionalSample dirSample = null;
/* 532 */ if ((dirSample = (HAEDirectionalSample)getSample(index)) == null)
/* 533 */ return;
/* 534 */ int soundType = dirSample.getSoundType();
/* 535 */ if (soundType == 3)
/* 536 */ dirSample.setXformedDirection();
/* */ }
/* */
/* */ public void setReflectionCoefficient(float coefficient)
/* */ {
/* 542 */ super.setReflectionCoefficient(coefficient);
/* 543 */ this.reverbDirty |= REFLECTION_COEFF_CHANGED;
/* */ }
/* */
/* */ public void setReverbDelay(float reverbDelay)
/* */ {
/* 548 */ super.setReverbDelay(reverbDelay);
/* 549 */ this.reverbDirty |= REVERB_DELAY_CHANGED;
/* */ }
/* */
/* */ public void setReverbOrder(int reverbOrder)
/* */ {
/* 554 */ super.setReverbOrder(reverbOrder);
/* 555 */ this.reverbDirty |= REVERB_ORDER_CHANGED;
/* */ }
/* */
/* */ public int startSample(int index)
/* */ {
/* 571 */ int returnValue = -1;
/* 572 */ HAESample sample = null;
/* 573 */ if (((sample = (HAESample)getSample(index)) == null) || (this.thread == null))
/* */ {
/* 575 */ return -1;
/* */ }
/* 577 */ AuralParameters attribs = getAuralParameters();
/* 578 */ int soundType = sample.getSoundType();
/* 579 */ boolean muted = sample.getMuteFlag();
/* 580 */ if (muted)
/* */ {
/* 583 */ sample.setLoopCount(0);
/* 584 */ sample.leftGain = 0.0F;
/* 585 */ sample.rightGain = 0.0F;
/* 586 */ sample.leftDelay = 0;
/* 587 */ sample.rightDelay = 0;
/* 588 */ if (soundType != 1)
/* 589 */ setFilter(index, false, -1.0F);
/* */ }
/* */ else {
/* 592 */ sample.render(sample.getDirtyFlags(), getView(), attribs);
/* */
/* 594 */ if (soundType != 1) {
/* 595 */ setFilter(index, sample.getFilterFlag(), sample.getFilterFreq());
/* */ }
/* */ }
/* 598 */ int dataType = sample.getDataType();
/* 599 */ int loopCount = sample.getLoopCount();
/* 600 */ float leftGain = sample.leftGain;
/* 601 */ float rightGain = sample.rightGain;
/* 602 */ int leftDelay = (int)(sample.leftDelay * attribs.rolloff);
/* 603 */ int rightDelay = (int)(sample.rightDelay * attribs.rolloff);
/* 604 */ if (dataType == 1) {
/* 605 */ if (soundType == 1) {
/* 606 */ returnValue = J3DHaeStream.startSample(index, loopCount, leftGain);
/* */
/* 609 */ scaleSampleRate(index, true);
/* */ }
/* */ else
/* */ {
/* 616 */ int secondIndex = ((HAEPositionalSample)sample).getSecondIndex();
/* 617 */ returnValue = J3DHaeStream.startSamples(index, secondIndex, loopCount, leftGain, rightGain, leftDelay, rightDelay);
/* */
/* 620 */ scaleSampleRate(index, true);
/* 621 */ scaleSampleRate(secondIndex, true);
/* */
/* 625 */ float reverbGain = 0.0F;
/* 626 */ if ((!muted) && (this.reverbOn)) {
/* 627 */ reverbGain = sample.getGain() * attribs.reflectionCoefficient;
/* */ }
/* 629 */ int reverbIndex = ((HAEPositionalSample)sample).getReverbIndex();
/* 630 */ int reverbRtrnVal = J3DHaeStream.startSample(reverbIndex, loopCount, reverbGain);
/* */
/* 632 */ scaleSampleRate(reverbIndex, true);
/* */ }
/* */
/* */ }
/* 639 */ else if (dataType == 2) {
/* 640 */ if (soundType == 1) {
/* 641 */ returnValue = J3DHaeClip.startSample(index, loopCount, leftGain);
/* */
/* 644 */ scaleSampleRate(index, true);
/* */ }
/* */ else
/* */ {
/* 651 */ int secondIndex = ((HAEPositionalSample)sample).getSecondIndex();
/* 652 */ returnValue = J3DHaeClip.startSamples(index, secondIndex, loopCount, leftGain, rightGain, leftDelay, rightDelay);
/* */
/* 655 */ scaleSampleRate(index, true);
/* 656 */ scaleSampleRate(secondIndex, true);
/* */
/* 660 */ float reverbGain = 0.0F;
/* 661 */ if ((!muted) && (this.reverbOn)) {
/* 662 */ reverbGain = sample.getGain() * attribs.reflectionCoefficient;
/* */ }
/* 664 */ int reverbIndex = ((HAEPositionalSample)sample).getReverbIndex();
/* 665 */ int reverbRtrnVal = J3DHaeClip.startSample(reverbIndex, loopCount, reverbGain);
/* */
/* 668 */ scaleSampleRate(reverbIndex, true);
/* */ }
/* */
/* */ }
/* 675 */ else if ((dataType == 3) || (dataType == 3))
/* */ {
/* 677 */ if (soundType == 1) {
/* 678 */ returnValue = J3DHaeMidi.startSample(index, loopCount, leftGain);
/* */
/* 681 */ scaleSampleRate(index, true);
/* */ }
/* */ else
/* */ {
/* 688 */ int secondIndex = ((HAEPositionalSample)sample).getSecondIndex();
/* 689 */ returnValue = J3DHaeMidi.startSamples(index, secondIndex, loopCount, leftGain, rightGain, leftDelay, rightDelay);
/* */
/* 692 */ scaleSampleRate(index, true);
/* 693 */ scaleSampleRate(secondIndex, true);
/* */ }
/* */
/* */ }
/* */ else
/* */ {
/* 722 */ return -1;
/* */ }
/* */
/* 725 */ if (returnValue < 0)
/* */ {
/* 730 */ return -1;
/* */ }
/* */
/* 737 */ if (!muted) {
/* 738 */ if (this.reverbDirty > 0) {
/* 739 */ calcReverb(attribs);
/* */ }
/* */
/* 743 */ setReverb(index);
/* */ }
/* 745 */ return returnValue;
/* */ }
/* */
/* */ public int stopSample(int index)
/* */ {
/* 752 */ HAESample sample = null;
/* 753 */ if ((sample = (HAESample)getSample(index)) == null) {
/* 754 */ return -1;
/* */ }
/* 756 */ int dataType = sample.getDataType();
/* 757 */ int soundType = sample.getSoundType();
/* */
/* 759 */ int returnValue = 0;
/* 760 */ if (dataType == 1) {
/* 761 */ if ((soundType == 3) || (soundType == 2))
/* */ {
/* 763 */ returnValue = J3DHaeStream.stopSamples(index, ((HAEPositionalSample)sample).getSecondIndex());
/* */
/* 765 */ returnValue = J3DHaeStream.stopSample(((HAEPositionalSample)sample).getReverbIndex());
/* */ }
/* */ else
/* */ {
/* 769 */ returnValue = J3DHaeStream.stopSample(index);
/* */ }
/* 771 */ } else if (dataType == 2) {
/* 772 */ if ((soundType == 3) || (soundType == 2))
/* */ {
/* 774 */ returnValue = J3DHaeClip.stopSamples(index, ((HAEPositionalSample)sample).getSecondIndex());
/* */
/* 776 */ returnValue = J3DHaeClip.stopSample(((HAEPositionalSample)sample).getReverbIndex());
/* */ }
/* */ else
/* */ {
/* 780 */ returnValue = J3DHaeClip.stopSample(index);
/* */ }
/* 782 */ } else if ((dataType == 3) || (dataType == 3))
/* */ {
/* 796 */ returnValue = J3DHaeMidi.stopSample(index);
/* */ }
/* */ else
/* */ {
/* 802 */ return -1;
/* */ }
/* */
/* 805 */ if (returnValue < 0)
/* */ {
/* 809 */ return -1;
/* */ }
/* */
/* 813 */ sample.reset();
/* */
/* 817 */ return 0;
/* */ }
/* */
/* */ public void pauseSample(int index)
/* */ {
/* 824 */ HAESample sample = null;
/* 825 */ if ((sample = (HAESample)getSample(index)) == null) {
/* 826 */ return;
/* */ }
/* 828 */ int dataType = sample.getDataType();
/* 829 */ int soundType = sample.getSoundType();
/* 830 */ int returnValue = 0;
/* 831 */ if (dataType == 1) {
/* 832 */ if ((soundType == 3) || (soundType == 2))
/* */ {
/* 834 */ returnValue = J3DHaeStream.pauseSamples(index, ((HAEPositionalSample)sample).getSecondIndex());
/* */
/* 836 */ returnValue = J3DHaeStream.pauseSample(((HAEPositionalSample)sample).getReverbIndex());
/* */ }
/* */ else
/* */ {
/* 840 */ returnValue = J3DHaeStream.pauseSample(index);
/* */ }
/* 842 */ } else if (dataType == 2) {
/* 843 */ if ((soundType == 3) || (soundType == 2))
/* */ {
/* 845 */ returnValue = J3DHaeClip.pauseSamples(index, ((HAEPositionalSample)sample).getSecondIndex());
/* */
/* 847 */ returnValue = J3DHaeClip.pauseSample(((HAEPositionalSample)sample).getReverbIndex());
/* */ }
/* */ else
/* */ {
/* 851 */ returnValue = J3DHaeClip.pauseSample(index);
/* */ }
/* 853 */ } else if ((dataType == 3) || (dataType == 3))
/* */ {
/* 865 */ returnValue = J3DHaeMidi.pauseSample(index);
/* */ }
/* */
/* 873 */ if (returnValue < 0);
/* */ }
/* */
/* */ public void unpauseSample(int index)
/* */ {
/* 884 */ HAESample sample = null;
/* 885 */ if ((sample = (HAESample)getSample(index)) == null) {
/* 886 */ return;
/* */ }
/* 888 */ int dataType = sample.getDataType();
/* 889 */ int soundType = sample.getSoundType();
/* 890 */ int returnValue = 0;
/* 891 */ if (dataType == 1) {
/* 892 */ if ((soundType == 3) || (soundType == 2))
/* */ {
/* 894 */ returnValue = J3DHaeStream.unpauseSamples(index, ((HAEPositionalSample)sample).getSecondIndex());
/* */
/* 896 */ returnValue = J3DHaeStream.unpauseSample(((HAEPositionalSample)sample).getReverbIndex());
/* */ }
/* */ else
/* */ {
/* 900 */ returnValue = J3DHaeStream.unpauseSample(index);
/* */ }
/* 902 */ } else if (dataType == 2) {
/* 903 */ if ((soundType == 3) || (soundType == 2))
/* */ {
/* 905 */ returnValue = J3DHaeClip.unpauseSamples(index, ((HAEPositionalSample)sample).getSecondIndex());
/* */
/* 907 */ returnValue = J3DHaeClip.unpauseSample(((HAEPositionalSample)sample).getReverbIndex());
/* */ }
/* */ else
/* */ {
/* 911 */ returnValue = J3DHaeClip.unpauseSample(index);
/* */ }
/* 913 */ } else if ((dataType == 3) || (dataType == 3))
/* */ {
/* 926 */ returnValue = J3DHaeMidi.unpauseSample(index);
/* */ }
/* */
/* 934 */ if (returnValue < 0);
/* */ }
/* */
/* */ public void updateSample(int index)
/* */ {
/* 945 */ HAESample sample = null;
/* 946 */ if (((sample = (HAESample)getSample(index)) == null) || (this.thread == null))
/* */ {
/* 948 */ return;
/* */ }
/* 950 */ int loopCount = sample.getLoopCount();
/* */
/* 955 */ int soundType = sample.getSoundType();
/* 956 */ boolean muted = sample.getMuteFlag();
/* */
/* 958 */ if (muted) {
/* 959 */ float leftGain = sample.leftGain;
/* 960 */ float rightGain = sample.rightGain;
/* 961 */ if ((leftGain != 0.0F) || (rightGain != 0.0F))
/* */ {
/* 970 */ sample.leftGain = (sample.rightGain = 0.0F);
/* 971 */ setStereoGain(index, 0.0F, 0.0F);
/* */ }
/* 973 */ if (soundType != 1)
/* 974 */ setFilter(index, false, -1.0F);
/* */ }
/* */ else
/* */ {
/* 978 */ AuralParameters attribs = getAuralParameters();
/* 979 */ if (this.reverbDirty > 0) {
/* 980 */ calcReverb(attribs);
/* */ }
/* */
/* 983 */ setReverb(index);
/* 984 */ sample.render(sample.getDirtyFlags(), getView(), attribs);
/* */
/* 986 */ scaleSampleRate(index, false);
/* */
/* 991 */ if (soundType != 1) {
/* 992 */ setFilter(index, sample.getFilterFlag(), sample.getFilterFreq());
/* */ }
/* 994 */ float leftGain = sample.leftGain;
/* 995 */ float rightGain = sample.rightGain;
/* 996 */ int leftDelay = (int)(sample.leftDelay * attribs.rolloff);
/* 997 */ int rightDelay = (int)(sample.rightDelay * attribs.rolloff);
/* */
/* 1007 */ setStereoGain(index, leftGain, rightGain);
/* 1008 */ setStereoDelay(index, leftDelay, rightDelay);
/* */ }
/* */ }
/* */
/* */ public void muteSample(int index)
/* */ {
/* 1014 */ HAESample sample = null;
/* 1015 */ if ((sample = (HAESample)getSample(index)) == null) {
/* 1016 */ return;
/* */ }
/* */
/* 1020 */ sample.setMuteFlag(true);
/* */ }
/* */
/* */ public void unmuteSample(int index)
/* */ {
/* 1025 */ HAESample sample = null;
/* 1026 */ if ((sample = (HAESample)getSample(index)) == null) {
/* 1027 */ return;
/* */ }
/* */
/* 1031 */ sample.setMuteFlag(false);
/* */
/* 1035 */ this.reverbDirty = 65535;
/* 1036 */ sample.setDirtyFlags(65535);
/* */ }
/* */
/* */ public long getSampleDuration(int index)
/* */ {
/* 1045 */ HAESample sample = null;
/* 1046 */ if ((sample = (HAESample)getSample(index)) == null)
/* 1047 */ return -1L;
/* 1048 */ int dataType = sample.getDataType();
/* 1049 */ int soundType = sample.getSoundType();
/* */ long duration;
/* 1055 */ if (dataType == 1) {
/* 1056 */ duration = J3DHaeStream.getSampleDuration(index);
/* */ }
/* */ else
/* */ {
/* */ long duration;
/* 1058 */ if (dataType == 2) {
/* 1059 */ duration = J3DHaeClip.getSampleDuration(index);
/* */ }
/* */ else
/* */ {
/* */ long duration;
/* 1060 */ if ((dataType == 3) || (dataType == 3))
/* */ {
/* 1062 */ duration = J3DHaeMidi.getSampleDuration(index);
/* */ }
/* */ else
/* */ {
/* 1068 */ return -1L;
/* */ }
/* */ }
/* */ }
/* */ long duration;
/* 1072 */ return duration;
/* */ }
/* */
/* */ public int getNumberOfChannelsUsed(int index)
/* */ {
/* 1081 */ HAESample sample = null;
/* 1082 */ if ((sample = (HAESample)getSample(index)) == null) {
/* 1083 */ return 0;
/* */ }
/* 1085 */ return getNumberOfChannelsUsed(index, sample.getMuteFlag());
/* */ }
/* */
/* */ public int getNumberOfChannelsUsed(int index, boolean muted)
/* */ {
/* 1099 */ HAESample sample = null;
/* 1100 */ if ((sample = (HAESample)getSample(index)) == null) {
/* 1101 */ return 0;
/* */ }
/* 1103 */ int soundType = sample.getSoundType();
/* 1104 */ int dataType = sample.getDataType();
/* */
/* 1107 */ if ((dataType == 3) || (dataType == 3))
/* */ {
/* 1109 */ return 1;
/* */ }
/* 1111 */ if (soundType == 1) {
/* 1112 */ return 1;
/* */ }
/* 1114 */ return 3;
/* */ }
/* */
/* */ public long getStartTime(int index) {
/* 1118 */ HAESample sample = null;
/* 1119 */ if ((sample = (HAESample)getSample(index)) == null) {
/* 1120 */ return 0L;
/* */ }
/* 1122 */ int dataType = sample.getDataType();
/* 1123 */ int soundType = sample.getSoundType();
/* */
/* 1125 */ if (dataType == 1)
/* 1126 */ return J3DHaeStream.getStartTime(index);
/* 1127 */ if (dataType == 2)
/* 1128 */ return J3DHaeClip.getStartTime(index);
/* 1129 */ if ((dataType == 3) || (dataType == 3))
/* */ {
/* 1131 */ return J3DHaeMidi.getStartTime(index);
/* */ }
/* */
/* 1137 */ return 0L;
/* */ }
/* */
/* */ void setStereoGain(int index, float leftGain, float rightGain)
/* */ {
/* 1145 */ HAESample sample = null;
/* 1146 */ if (((sample = (HAESample)getSample(index)) == null) || (this.thread == null))
/* */ {
/* 1148 */ return;
/* */ }
/* 1150 */ AuralParameters attribs = getAuralParameters();
/* 1151 */ int dataType = sample.getDataType();
/* 1152 */ int soundType = sample.getSoundType();
/* 1153 */ boolean muted = sample.getMuteFlag();
/* */
/* 1162 */ float reverbGain = 0.0F;
/* 1163 */ if ((!muted) && (this.reverbOn)) {
/* 1164 */ reverbGain = sample.getGain() * attribs.reflectionCoefficient;
/* */ }
/* 1166 */ if ((dataType == 1) || (dataType == 2))
/* */ {
/* 1168 */ this.thread.setTargetGain(index, leftGain);
/* 1169 */ if ((soundType == 3) || (soundType == 2))
/* */ {
/* 1171 */ this.thread.setTargetGain(((HAEPositionalSample)sample).getSecondIndex(), rightGain);
/* */
/* 1173 */ this.thread.setTargetGain(((HAEPositionalSample)sample).getReverbIndex(), reverbGain);
/* */ }
/* */
/* */ }
/* 1178 */ else if ((dataType == 3) || (dataType == 3))
/* */ {
/* 1181 */ this.thread.setTargetGain(index, leftGain + rightGain);
/* */ }
/* */ else;
/* */ }
/* */
/* */ void setStereoDelay(int index, int leftDelay, int rightDelay)
/* */ {
/* 1206 */ HAESample sample = null;
/* 1207 */ if ((sample = (HAESample)getSample(index)) == null) {
/* 1208 */ return;
/* */ }
/* 1210 */ int dataType = sample.getDataType();
/* 1211 */ int soundType = sample.getSoundType();
/* */
/* 1215 */ if (dataType == 1) {
/* 1216 */ if ((soundType == 3) || (soundType == 2))
/* */ {
/* 1218 */ J3DHaeStream.setSampleDelay(index, leftDelay);
/* */
/* 1220 */ J3DHaeStream.setSampleDelay(((HAEPositionalSample)sample).getSecondIndex(), rightDelay);
/* */ }
/* */ else
/* */ {
/* 1224 */ J3DHaeStream.setSampleDelay(index, 0);
/* */ }
/* 1226 */ } else if (dataType == 2) {
/* 1227 */ if ((soundType == 3) || (soundType == 2))
/* */ {
/* 1229 */ J3DHaeClip.setSampleDelay(index, leftDelay);
/* */
/* 1231 */ J3DHaeClip.setSampleDelay(((HAEPositionalSample)sample).getSecondIndex(), rightDelay);
/* */ }
/* */ else
/* */ {
/* 1235 */ J3DHaeClip.setSampleDelay(index, 0);
/* */ }
/* 1237 */ } else if ((dataType == 3) || (dataType == 3))
/* */ {
/* 1249 */ J3DHaeMidi.setSampleDelay(index, 0);
/* */ }
/* */ else;
/* */ }
/* */
/* */ void scaleSampleRate(int index, boolean forceRateChange)
/* */ {
/* 1262 */ HAESample sample = null;
/* 1263 */ if (((sample = (HAESample)getSample(index)) == null) || (this.thread == null))
/* */ {
/* 1265 */ return;
/* 1266 */ }float scaleFactor = sample.getTargetRateRatio();
/* 1267 */ int dataType = sample.getDataType();
/* */
/* 1272 */ int soundType = sample.getSoundType();
/* */
/* 1274 */ if ((dataType == 1) || (dataType == 2))
/* */ {
/* 1276 */ if (forceRateChange)
/* 1277 */ this.thread.setRate(index, scaleFactor);
/* */ else {
/* 1279 */ this.thread.setTargetRate(index, scaleFactor);
/* */ }
/* 1281 */ if (soundType != 1) {
/* 1282 */ if (forceRateChange) {
/* 1283 */ this.thread.setRate(((HAEPositionalSample)sample).getSecondIndex(), scaleFactor);
/* */
/* 1286 */ this.thread.setRate(((HAEPositionalSample)sample).getReverbIndex(), scaleFactor);
/* */ }
/* */ else
/* */ {
/* 1291 */ this.thread.setTargetRate(((HAEPositionalSample)sample).getSecondIndex(), scaleFactor);
/* */
/* 1294 */ this.thread.setTargetRate(((HAEPositionalSample)sample).getReverbIndex(), scaleFactor);
/* */ }
/* */
/* */ }
/* */
/* */ }
/* 1300 */ else if ((dataType == 3) || (dataType == 3))
/* */ {
/* 1302 */ if (forceRateChange)
/* 1303 */ this.thread.setRate(index, scaleFactor);
/* */ else
/* 1305 */ this.thread.setTargetRate(index, scaleFactor);
/* */ }
/* */ }
/* */
/* */ void calcReverb(AuralParameters attribs)
/* */ {
/* 1377 */ float decay = attribs.decayTime;
/* 1378 */ float delay = attribs.reverbDelay * attribs.rolloff;
/* 1379 */ int order = attribs.reverbOrder;
/* */
/* 1385 */ if ((attribs.reflectionCoefficient == 0.0F) || (attribs.reverbCoefficient == 0.0F))
/* */ {
/* 1387 */ this.reverbOn = false;
/* */ }
/* */ else
/* */ {
/* 1398 */ this.reverbOn = true;
/* */
/* 1404 */ if (order > 0)
/* */ {
/* 1406 */ float clampedTime = order * delay;
/* 1407 */ if (clampedTime < decay)
/* 1408 */ decay = clampedTime;
/* */ }
/* 1410 */ if (delay < 100.0F)
/* */ {
/* 1412 */ if (decay <= 1500.0F)
/* 1413 */ this.reverbType = 2;
/* */ else
/* 1415 */ this.reverbType = 4;
/* */ }
/* 1417 */ else if (delay < 500.0F)
/* */ {
/* 1419 */ if (decay <= 1500.0F)
/* 1420 */ this.reverbType = 3;
/* */ else {
/* 1422 */ this.reverbType = 6;
/* */ }
/* */
/* */ }
/* 1426 */ else if (decay <= 1500.0F)
/* 1427 */ this.reverbType = 6;
/* */ else {
/* 1429 */ this.reverbType = 5;
/* */ }
/* */
/* */ }
/* */
/* 1437 */ this.reverbDirty = 0;
/* */ }
/* */
/* */ void setReverb(int index)
/* */ {
/* 1447 */ HAESample sample = null;
/* 1448 */ if ((sample = (HAESample)getSample(index)) == null) {
/* 1449 */ return;
/* */ }
/* 1451 */ int soundType = sample.getSoundType();
/* 1452 */ int dataType = sample.getDataType();
/* */
/* 1455 */ if ((soundType == 3) || (soundType == 2))
/* */ {
/* 1460 */ HAEPositionalSample posSample = null;
/* 1461 */ if ((posSample = (HAEPositionalSample)getSample(index)) == null) {
/* 1462 */ return;
/* */ }
/* 1464 */ int reverbIndex = posSample.getReverbIndex();
/* 1465 */ if (dataType == 1) {
/* 1466 */ J3DHaeStream.setReverb(reverbIndex, this.reverbType, this.reverbOn);
/* */ }
/* 1468 */ else if (dataType == 2) {
/* 1469 */ J3DHaeClip.setReverb(reverbIndex, this.reverbType, this.reverbOn);
/* */ }
/* 1471 */ else if ((dataType == 3) || (dataType == 3))
/* */ {
/* 1473 */ J3DHaeMidi.setReverb(reverbIndex, this.reverbType, this.reverbOn);
/* */ }
/* */ }
/* */ }
/* */
/* */ public void setLoop(int index, int count)
/* */ {
/* 1485 */ HAESample sample = null;
/* 1486 */ if ((sample = (HAESample)getSample(index)) == null)
/* 1487 */ return;
/* 1488 */ int dataType = sample.getDataType();
/* */
/* 1493 */ if ((dataType == 1) || (dataType == 2))
/* */ {
/* 1495 */ if (count == -1)
/* */ {
/* 1497 */ count = 134217727;
/* */ }
/* */ }
/* 1500 */ super.setLoop(index, count);
/* */ }
/* */
/* */ void setFilter(int index, boolean filterFlag, float filterFreq)
/* */ {
/* 1510 */ HAEPositionalSample posSample = null;
/* 1511 */ if ((posSample = (HAEPositionalSample)getSample(index)) == null)
/* 1512 */ return;
/* 1513 */ int dataType = posSample.getDataType();
/* */
/* 1516 */ if ((dataType == 3) || (dataType == 3))
/* */ {
/* 1518 */ return;
/* */ }
/* */
/* 1521 */ int secondIndex = posSample.getSecondIndex();
/* 1522 */ if (dataType == 2) {
/* 1523 */ J3DHaeClip.setFiltering(index, filterFlag, filterFreq);
/* 1524 */ J3DHaeClip.setFiltering(secondIndex, filterFlag, filterFreq);
/* */ }
/* */ else
/* */ {
/* 1528 */ J3DHaeStream.setFiltering(index, filterFlag, filterFreq);
/* 1529 */ J3DHaeStream.setFiltering(secondIndex, filterFlag, filterFreq);
/* */ }
/* */ }
/* */
/* */ public void setGain(float scaleFactor)
/* */ {
/* 1546 */ float oldDeviceGain = this.deviceGain;
/* 1547 */ float gainFactor = scaleFactor / oldDeviceGain;
/* */
/* 1549 */ this.deviceGain = scaleFactor;
/* */ }
/* */
/* */ public void pause()
/* */ {
/* 1560 */ this.pause = 1;
/* */ }
/* */
/* */ public void resume()
/* */ {
/* 1570 */ this.pause = 3;
/* */ }
/* */
/* */ public void setRateScaleFactor(int index, float rateScaleFactor)
/* */ {
/* 1581 */ HAESample sample = null;
/* 1582 */ if ((sample = (HAESample)getSample(index)) == null)
/* 1583 */ return;
/* 1584 */ sample.setRateScaleFactor(rateScaleFactor);
/* 1585 */ scaleSampleRate(index, true);
/* */ }
/* */
/* */ public void setRolloff(float rolloff)
/* */ {
/* 1596 */ super.setRolloff(rolloff);
/* 1597 */ int nSamples = getSampleListSize();
/* 1598 */ for (int index = 0; index < nSamples; index++)
/* 1599 */ scaleSampleRate(index, true);
/* */ }
/* */
/* */ public void setFrequencyScaleFactor(float scaleFactor)
/* */ {
/* 1611 */ super.setFrequencyScaleFactor(scaleFactor);
/* 1612 */ int nSamples = getSampleListSize();
/* 1613 */ for (int index = 0; index < nSamples; index++)
/* 1614 */ scaleSampleRate(index, true);
/* */ }
/* */
/* */ public void setVelocityScaleFactor(float scaleFactor)
/* */ {
/* 1626 */ super.setVelocityScaleFactor(scaleFactor);
/* 1627 */ int nSamples = getSampleListSize();
/* 1628 */ for (int index = 0; index < nSamples; index++)
/* 1629 */ scaleSampleRate(index, true);
/* */ }
/* */ }
/* Location: Z:\System\Library\Java\Extensions\j3daudio.jar
* Qualified Name: com.sun.j3d.audioengines.headspace.HeadspaceMixer
* JD-Core Version: 0.6.2
*/