diff options
Diffstat (limited to 'src/classes/share/com/sun/j3d/audioengines')
14 files changed, 480 insertions, 480 deletions
diff --git a/src/classes/share/com/sun/j3d/audioengines/AudioEngine.java b/src/classes/share/com/sun/j3d/audioengines/AudioEngine.java index 8f3b66a..431f2a5 100644 --- a/src/classes/share/com/sun/j3d/audioengines/AudioEngine.java +++ b/src/classes/share/com/sun/j3d/audioengines/AudioEngine.java @@ -67,7 +67,7 @@ public abstract class AudioEngine implements AudioDevice { * HEADPHONE, MONO_SPEAKER, STEREO_SPEAKERS */ int audioPlaybackType = HEADPHONES; - + /* * Distance from center ear (midpoint between ears) to physical speaker. * Default reflects distance for headphones. @@ -75,8 +75,8 @@ public abstract class AudioEngine implements AudioDevice { * distance from the listener and that */ float distanceToSpeaker = 0.0f; - - /* + + /* * Angle between the vector from center ear parallel to head coordiate * Z axis and the vector from the center ear to the speaker. * For two speakers it is assumed that the speakers are placed at the @@ -115,14 +115,14 @@ public abstract class AudioEngine implements AudioDevice { */ public abstract boolean close(); - /* + /* * Audio Playback Methods - */ + */ /** * Set Type of Audio Playback physical transducer(s) sound is output to. * Valid types are HEADPHONE, MONO_SPEAKER, STEREO_SPEAKERS * @param type of audio output device - */ + */ public void setAudioPlaybackType(int type) { audioPlaybackType = type; } @@ -130,7 +130,7 @@ public abstract class AudioEngine implements AudioDevice { /** * Get Type of Audio Playback Output Device * returns audio playback type to which sound is currently output - */ + */ public int getAudioPlaybackType() { return audioPlaybackType; } @@ -138,7 +138,7 @@ public abstract class AudioEngine implements AudioDevice { /** * Set Distance from the Center Ear to a Speaker * @param distance from the center ear and to the speaker - */ + */ public void setCenterEarToSpeaker(float distance) { distanceToSpeaker = distance; } @@ -146,32 +146,32 @@ public abstract class AudioEngine implements AudioDevice { /** * Get Distance from Ear to Speaker * returns value set as distance from listener's ear to speaker - */ + */ public float getCenterEarToSpeaker() { return distanceToSpeaker; } - + /** * Set Angle Offset To Speaker - * @param angle in radian between head coordinate Z axis and vector to speaker */ + * @param angle in radian between head coordinate Z axis and vector to speaker */ public void setAngleOffsetToSpeaker(float angle) { angleOffsetToSpeaker = angle; - } - + } + /** * Get Angle Offset To Speaker * returns value set as angle between vector to speaker and Z head axis - */ + */ public float getAngleOffsetToSpeaker() { return angleOffsetToSpeaker; - } + } /** * Query total number of channels available for sound rendering * for this audio device. * returns number of maximum sound channels you can run with this - * library/device-driver. - */ + * library/device-driver. + */ public int getTotalChannels() { // this method should be overridden by a device specific implementation return (totalChannels); @@ -181,7 +181,7 @@ public abstract class AudioEngine implements AudioDevice { * Query number of channels currently available for use by the * returns number of sound channels currently available (number * not being used by active sounds. - */ + */ public int getChannelsAvailable() { return (channelsAvailable); } @@ -192,7 +192,7 @@ public abstract class AudioEngine implements AudioDevice { * @param sound refenence to sound node that query to be performed on * returns number of sound channels used by a specific Sound node * @deprecated This method is now part of the Sound class - */ + */ public int getChannelsUsedForSound(Sound sound) { if (sound != null) return sound.getNumberOfChannelsUsed(); diff --git a/src/classes/share/com/sun/j3d/audioengines/AudioEngine3D.java b/src/classes/share/com/sun/j3d/audioengines/AudioEngine3D.java index 461a564..ce135af 100644 --- a/src/classes/share/com/sun/j3d/audioengines/AudioEngine3D.java +++ b/src/classes/share/com/sun/j3d/audioengines/AudioEngine3D.java @@ -51,11 +51,11 @@ import java.util.ArrayList; /** * The AudioEngine3D Class defines an audio output device that generates - * sound 'image' from high-level sound parameters passed to it during + * sound 'image' from high-level sound parameters passed to it during * scene graph. * * <P> - * The methods in this class are meant to be optionally overridden by an + * The methods in this class are meant to be optionally overridden by an * extended class. This extended class would provice device specific code. * * <P> @@ -72,12 +72,12 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D /* * Identifiers of sample associated with sound source * This array grows as the AudioDevice3D implementation requires it larger. - */ + */ protected ArrayList samples = new ArrayList(64); /** * Current View sound is being rendered - */ + */ protected View currentView = (View)null; /* @@ -89,14 +89,14 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D * Construct a new AudioEngine with the specified PhysicalEnvironment. * @param physicalEnvironment the physical environment object where we * want access to this device. - */ + */ public AudioEngine3D(PhysicalEnvironment physicalEnvironment ) { super(physicalEnvironment); } /* * - * Methods that affect AudioEngine3D fields that are NOT associated + * Methods that affect AudioEngine3D fields that are NOT associated * with a specific sound sample * */ @@ -131,7 +131,7 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D * @param soundType denotes type of sound: Background, Point or Cone * @param soundData descrition of sound source data * @return index into sample vector of Sample object for sound - */ + */ public int prepareSound(int soundType, MediaContainer soundData) { // This method must be overridden by device specific implementation return Sample.NULL_SAMPLE; @@ -141,7 +141,7 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D * Clear Sound. * Removes/clears associated sound data with this sound source node * @param index device specific reference number to device driver sample - */ + */ public abstract void clearSound(int index); /** @@ -170,7 +170,7 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D public abstract int stopSample(int index); /** - * Update sample. + * Update sample. * Implies that some parameters affecting rendering have been modified. * @param index device specific reference number to device driver sample */ @@ -178,29 +178,29 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D public abstract void updateSample(int index); /** - * Mute sample. + * Mute sample. * @param index device specific reference number to device driver sample */ public abstract void muteSample(int index); /** - * Unmute sample. + * Unmute sample. * @param index device specific reference number to device driver sample */ public abstract void unmuteSample(int index); /** - * Pause sample. + * Pause sample. * @param index device specific reference number to device driver sample */ public abstract void pauseSample(int index); /** - * Unpause sample. + * Unpause sample. * @param index device specific reference number to device driver sample */ public abstract void unpauseSample(int index); - + /* * * Methods that affect fields associated with the sound sample @@ -208,25 +208,25 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D * */ /** - * Set gain scale factor applied to sample. + * Set gain scale factor applied to sample. * @param index device specific reference number to device driver sample * @param scaleFactor floating point multiplier applied to sample amplitude */ public void setSampleGain(int index, float scaleFactor) { Sample sample = (Sample)getSample(index); - if (sample != null) + if (sample != null) sample.setGain(scaleFactor); return; } - /** + /** * Set number of times sample is looped. * @param index device specific reference number to device driver sample * @param count number of times sample is repeated */ public void setLoop(int index, int count) { Sample sample = (Sample)getSample(index); - if (sample != null) + if (sample != null) sample.setLoopCount(count); return; } @@ -238,7 +238,7 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D */ public void setPosition(int index, Point3d position) { Sample sample = (Sample)getSample(index); - if (sample != null) + if (sample != null) sample.setPosition(position); return; } @@ -252,12 +252,12 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D * thru which ellipses pass * @param backAttenuationScaleFactor gain scale factors */ - public void setDistanceGain(int index, + public void setDistanceGain(int index, double[] frontDistance, float[] frontAttenuationScaleFactor, double[] backDistance, float[] backAttenuationScaleFactor) { Sample sample = (Sample)getSample(index); - if (sample != null) - sample.setDistanceGain(frontDistance, frontAttenuationScaleFactor, + if (sample != null) + sample.setDistanceGain(frontDistance, frontAttenuationScaleFactor, backDistance, backAttenuationScaleFactor); return; } @@ -269,7 +269,7 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D */ public void setDirection(int index, Vector3d direction) { Sample sample = (Sample)getSample(index); - if (sample != null) + if (sample != null) sample.setDirection(direction); return; } @@ -285,11 +285,11 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D * @param filterCutoff array containing filter cutoff frequencies. * The filter values for each tuples can be set to Sound.NO_FILTER. */ - public void setAngularAttenuation(int index, int filterType, + public void setAngularAttenuation(int index, int filterType, double[] angle, float[] attenuationScaleFactor, float[] filterCutoff) { Sample sample = (Sample)getSample(index); - if (sample != null) - sample.setAngularAttenuation(filterType, angle, + if (sample != null) + sample.setAngularAttenuation(filterType, angle, attenuationScaleFactor, filterCutoff); return; } @@ -315,7 +315,7 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D } /** - * Set reverberation delay time for current aural attribute applied to + * Set reverberation delay time for current aural attribute applied to * all samples. * @param reverbDelay amount of time in millisecond between each * iteration of reverb processing. @@ -326,7 +326,7 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D } /** - * Set reverberation order for current aural attribute applied to all + * Set reverberation order for current aural attribute applied to all * samples. * @param reverbOrder number of times reverb process loop is iterated. */ @@ -341,14 +341,14 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D * to all sample based on distance between listener and sound. * @param dist is an attenuation array of distance and low-pass filter values. */ - public void setDistanceFilter(int filterType, + public void setDistanceFilter(int filterType, double[] dist, float[] filterCutoff) { attribs.setDistanceFilter(filterType, dist, filterCutoff); return; } /** - * Set frequency scale factor for current aural attribute applied to all + * Set frequency scale factor for current aural attribute applied to all * samples. * @param scaleFactor frequency scale factor applied to samples normal * playback rate. @@ -358,7 +358,7 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D return; } /** - * Set velocity scale factor for current aural attribute applied to all + * Set velocity scale factor for current aural attribute applied to all * samples when Doppler is calculated. * @param scaleFactor scale factor applied to postional samples' * listener-to-soundSource velocity. @@ -377,7 +377,7 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D public int getNumberOfChannelsUsed(int index) { // This method must be overridden by device specific implementation Sample sample = (Sample)getSample(index); - if (sample != null) + if (sample != null) return (sample.getNumberOfChannelsUsed()); else return 0; @@ -396,7 +396,7 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D public int getNumberOfChannelsUsed(int index, boolean muteFlag) { // This method must be overridden by device specific implementation Sample sample = (Sample)getSample(index); - if (sample != null) + if (sample != null) return (sample.getNumberOfChannelsUsed()); else return 0; @@ -409,7 +409,7 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D */ public long getSampleDuration(int index) { Sample sample = (Sample)getSample(index); - if (sample != null) + if (sample != null) return (sample.getDuration()); else return 0L; @@ -422,7 +422,7 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D */ public long getStartTime(int index) { Sample sample = (Sample)getSample(index); - if (sample != null) + if (sample != null) return (sample.getStartTime()); else return 0L; @@ -450,7 +450,7 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D * @return reference to sample; returns null if index out of range. * * @since Java 3D 1.2.1 - */ + */ public Sample getSample(int index) { synchronized(samples) { if ((index >= 0) && (index < samples.size())) { diff --git a/src/classes/share/com/sun/j3d/audioengines/AudioEngine3DL2.java b/src/classes/share/com/sun/j3d/audioengines/AudioEngine3DL2.java index 2e847c0..33e84f0 100644 --- a/src/classes/share/com/sun/j3d/audioengines/AudioEngine3DL2.java +++ b/src/classes/share/com/sun/j3d/audioengines/AudioEngine3DL2.java @@ -51,11 +51,11 @@ import java.util.ArrayList; /** * The AudioEngine3DL2 Class defines an audio output device that generates - * sound 'image' from high-level sound parameters passed to it during + * sound 'image' from high-level sound parameters passed to it during * scene graph. * * <P> - * The methods in this class are meant to be optionally overridden by an + * The methods in this class are meant to be optionally overridden by an * extended class. This extended class would provice device specific code. * * <P> @@ -73,14 +73,14 @@ public abstract class AudioEngine3DL2 extends AudioEngine3D implements AudioDevi * Construct a new AudioEngine3DL2 with the specified PhysicalEnvironment. * @param physicalEnvironment the physical environment object where we * want access to this device. - */ + */ public AudioEngine3DL2(PhysicalEnvironment physicalEnvironment ) { super(physicalEnvironment); } /* * - * Methods that affect AudioEngine3DLD fields that are NOT associated + * Methods that affect AudioEngine3DLD fields that are NOT associated * with a specific sound sample * */ @@ -105,7 +105,7 @@ public abstract class AudioEngine3DL2 extends AudioEngine3D implements AudioDevi * Set overall gain control of all sounds playing on the audio device. * @param scaleFactor scale factor applied to calculated amplitudes for * all sounds playing on this device - */ + */ public abstract void setGain(float scaleFactor); /* @@ -123,7 +123,7 @@ public abstract class AudioEngine3DL2 extends AudioEngine3D implements AudioDevi * Changes (scales) the playback rate of a sound independent of * Doppler rate changes. * @param index device specific reference to device driver sample - * @param scaleFactor non-negative factor applied to calculated + * @param scaleFactor non-negative factor applied to calculated * amplitudes for all sounds playing on this device * @see Sound#setRateScaleFactor */ @@ -151,7 +151,7 @@ public abstract class AudioEngine3DL2 extends AudioEngine3D implements AudioDevi * This parameter, along with the early reflection coefficient, defines * the reflective/absorptive characteristic of the surfaces in the * current listening region. - * @param coefficient late reflection attenuation factor + * @param coefficient late reflection attenuation factor * @see AuralAttributes#setReverbCoefficient */ public void setReverbCoefficient(float coefficient) { @@ -160,14 +160,14 @@ public abstract class AudioEngine3DL2 extends AudioEngine3D implements AudioDevi } - /** + /** * Sets the early reflection delay time. * In this form, the parameter specifies the delay time between each order * of reflection (while reverberation is being rendered) explicitly given - * in milliseconds. + * in milliseconds. * @param reflectionDelay time between each order of early reflection * @see AuralAttributes#setReflectionDelay - */ + */ public void setReflectionDelay(float reflectionDelay) { attribs.reflectionDelay = reflectionDelay; return; @@ -188,7 +188,7 @@ public abstract class AudioEngine3DL2 extends AudioEngine3D implements AudioDevi * Set reverb decay filter. * This provides for frequencies above the given cutoff frequency to be * attenuated during reverb decay at a different rate than frequencies - * below this value. Thus, defining a different reverb decay curve for + * below this value. Thus, defining a different reverb decay curve for * frequencies above the cutoff value. * @param frequencyCutoff value of frequencies in Hertz above which a * low-pass filter is applied. @@ -204,7 +204,7 @@ public abstract class AudioEngine3DL2 extends AudioEngine3D implements AudioDevi * This defines the echo dispersement (also referred to as 'echo density'). * The value of this reverb parameter is expressed as a percent of the * audio device's minimum-to-maximum values. - * @param diffusion percentage expressed within the range of 0.0 and 1.0 + * @param diffusion percentage expressed within the range of 0.0 and 1.0 * @see AuralAttributes#setDiffusion */ public void setDiffusion(float diffusion) { @@ -214,12 +214,12 @@ public abstract class AudioEngine3DL2 extends AudioEngine3D implements AudioDevi /** * Set reverb density. - * This defines the modal density (also referred to as 'spectral + * This defines the modal density (also referred to as 'spectral * coloration'). * The value of this parameter is expressed as a percent of the audio * device's minimum-to-maximum values for this reverb parameter. * @param density reverb density expressed as a percentage, - * within the range of 0.0 and 1.0 + * within the range of 0.0 and 1.0 * @see AuralAttributes#setDensity */ public void setDensity(float density) { @@ -253,7 +253,7 @@ public abstract class AudioEngine3DL2 extends AudioEngine3D implements AudioDevi * There is no corresponding Core AuralAttributes method at this time. * @param index device specific reference to device driver sample * @param frequencyCutoff value of frequencies in Hertz above which a - * low-pass filter is applied. + * low-pass filter is applied. */ public void setObstructionFilter(int index, float frequencyCutoff) { @@ -288,7 +288,7 @@ public abstract class AudioEngine3DL2 extends AudioEngine3D implements AudioDevi * There is no corresponding Core AuralAttributes method at this time. * @param index device specific reference to device driver sample * @param frequencyCutoff value of frequencies in Hertz above which a - * low-pass filter is applied. + * low-pass filter is applied. */ public void setOcclusionFilter(int index, float frequencyCutoff) { Sample sample = (Sample)getSample(index); diff --git a/src/classes/share/com/sun/j3d/audioengines/AudioEngineThread.java b/src/classes/share/com/sun/j3d/audioengines/AudioEngineThread.java index a8dc4bd..2c8c899 100644 --- a/src/classes/share/com/sun/j3d/audioengines/AudioEngineThread.java +++ b/src/classes/share/com/sun/j3d/audioengines/AudioEngineThread.java @@ -52,7 +52,7 @@ import javax.media.j3d.*; /** * The Thread Class extended for Audio Device engines that must process - * calls dynamically, in 'real-time" to asynchronously change engine + * calls dynamically, in 'real-time" to asynchronously change engine * parameters. * * <p> @@ -69,9 +69,9 @@ public class AudioEngineThread extends Thread { if (debugFlag) System.out.println(message); } - + /** - * The classification types. + * The classification types. */ protected static final int WORK_THREAD = 0x01; protected static final int UPDATE_THREAD = 0x02; @@ -82,13 +82,13 @@ public class AudioEngineThread extends Thread { protected static final int WAIT = 0; /** - * This runMonitor action notifies MasterControl that this thread + * This runMonitor action notifies MasterControl that this thread * has completed and wait. */ protected static final int NOTIFY_AND_WAIT = 1; /** - * This runMonitor action tells the thread to run N number of + * This runMonitor action tells the thread to run N number of * iterations. */ protected static final int RUN = 2; @@ -199,7 +199,7 @@ public class AudioEngineThread extends Thread { } } - /** + /** * This causes the threads run method to exit. */ public void finish() { @@ -259,7 +259,7 @@ public class AudioEngineThread extends Thread { public void shutdown() { } - + // default resource clean up method public void cleanup() { active = false; @@ -270,6 +270,6 @@ public class AudioEngineThread extends Thread { args = null; userStop = false; referenceTime = 0; - + } } diff --git a/src/classes/share/com/sun/j3d/audioengines/AuralParameters.java b/src/classes/share/com/sun/j3d/audioengines/AuralParameters.java index 38efbc6..75aa190 100644 --- a/src/classes/share/com/sun/j3d/audioengines/AuralParameters.java +++ b/src/classes/share/com/sun/j3d/audioengines/AuralParameters.java @@ -76,8 +76,8 @@ public class AuralParameters /* * @since Java 3D 1.3 */ - public float reverbCoefficient = 1.0f; - public float reflectionDelay = 20.0f; + public float reverbCoefficient = 1.0f; + public float reflectionDelay = 20.0f; public float decayTime = 1000.0f; public float decayFrequencyCutoff = 5000.0f; public float diffusion = 1.0f; // 100% @@ -85,7 +85,7 @@ public class AuralParameters /** * Construct a new AuralParameters object - */ + */ public AuralParameters() { frequencyScaleFactor = 1.0f; velocityScaleFactor = 0.0f; @@ -104,20 +104,20 @@ public class AuralParameters density = 1.0f; // 100% } - public void setDistanceFilter(int filterType, double[] distance, + public void setDistanceFilter(int filterType, double[] distance, float[] filterCutoff) { boolean error = false; boolean allocate = false; int attenuationLength = 0; if (distance == null || filterCutoff == null) { error = true; - } + } else { attenuationLength = distance.length; if (attenuationLength == 0 || filterType == NO_FILTERING) { error = true; } - } + } if (error) { this.filterType = NO_FILTERING; this.filterDistance = null; @@ -141,10 +141,10 @@ public class AuralParameters this.filterDistance = new double[attenuationLength]; this.filterCutoff = new float[attenuationLength]; } - System.arraycopy(distance, 0, this.filterDistance, 0, - attenuationLength); - System.arraycopy(filterCutoff, 0, this.filterCutoff, 0, - attenuationLength); + System.arraycopy(distance, 0, this.filterDistance, 0, + attenuationLength); + System.arraycopy(filterCutoff, 0, this.filterCutoff, 0, + attenuationLength); if (debugFlag) { debugPrint("setDistanceFilter arrays = "); @@ -176,9 +176,9 @@ public class AuralParameters if (attenuationLength > filterDistance.length) attenuationLength = filterDistance.length; System.arraycopy(this.filterDistance, 0, distance, 0, - attenuationLength); + attenuationLength); System.arraycopy(this.filterCutoff, 0, filterCutoff, 0, - attenuationLength); + attenuationLength); return; } @@ -188,10 +188,10 @@ public class AuralParameters /** * Debug print method for Sound nodes - */ + */ protected void debugPrint(String message) { if (debugFlag) System.out.println(message); } - + } diff --git a/src/classes/share/com/sun/j3d/audioengines/Sample.java b/src/classes/share/com/sun/j3d/audioengines/Sample.java index e0dc0ea..3cd092b 100644 --- a/src/classes/share/com/sun/j3d/audioengines/Sample.java +++ b/src/classes/share/com/sun/j3d/audioengines/Sample.java @@ -76,28 +76,28 @@ public class Sample { /** * sound data associated with sound source - */ + */ protected MediaContainer soundData = null; /** * sound data associated with sound source - */ + */ protected int soundType = -1; /** * Overall Scale Factor applied to sound gain. - */ + */ protected float gain = 1.0f; // Valid values are >= 0.0. /** * Overall Scale Factor applied to sound. * @since Java 3D 1.3 - */ + */ protected float rateScaleFactor = 1.0f; // Valid values are >= 0.0. /** * Number of times sound is looped/repeated during play - */ + */ protected int loopCount = 0; // Range from 0 to POSITIVE_INFINITY(-1) @@ -131,13 +131,13 @@ public class Sample { /* * Pairs of distances and gain scale factors that define piecewise linear * gain attenuation between each pair. - */ - protected double[] attenuationDistance = null; + */ + protected double[] attenuationDistance = null; protected float[] attenuationGain = null;; /** * dirty flags denoting what has changed since last rendering - */ + */ protected int dirtyFlags = 0xFFFF; /* @@ -154,7 +154,7 @@ public class Sample { * Pairs of distances and gain scale factors that define piecewise linear * gain BACK attenuation between each pair. * These are used for defining elliptical attenuation regions. - */ + */ protected double[] backAttenuationDistance = null; protected float[] backAttenuationGain = null; @@ -173,10 +173,10 @@ public class Sample { * Distance Filter * Each sound source is attenuated by a filter based on it's distance * from the listener. - * For now the only supported filterType will be LOW_PASS frequency + * For now the only supported filterType will be LOW_PASS frequency * cutoff. * At some time full FIR filtering will be supported. - */ + */ public static final int NO_FILTERING = -1; public static final int LOW_PASS = 1; @@ -188,22 +188,22 @@ public class Sample { * For now the only type of filtering supported is a low-pass filter * defined by a frequency cutoff value. * @since Java 3D 1.3 - */ + */ protected float obstructionGain = 1.0f; // scale factor protected int obstructionFilterType = NO_FILTERING; protected float obstructionFilterCutoff = Sound.NO_FILTER; protected float occlusionGain = 1.0f; // scale factor protected int occlusionFilterType = NO_FILTERING; - protected float occlusionFilterCutoff = Sound.NO_FILTER; + protected float occlusionFilterCutoff = Sound.NO_FILTER; /* * Construct a new audio device Sample object - */ + */ public Sample() { if (debugFlag) debugPrintln("Sample constructor"); } - + public long getDuration() { return 0; } @@ -266,11 +266,11 @@ public class Sample { } public void setLoopCount(int count) { - loopCount = count; + loopCount = count; } public int getLoopCount() { - return loopCount; + return loopCount; } @@ -283,7 +283,7 @@ public class Sample { public void setDistanceGain( - double[] frontDistance, float[] frontAttenuationScaleFactor, + double[] frontDistance, float[] frontAttenuationScaleFactor, double[] backDistance, float[] backAttenuationScaleFactor) { if (frontDistance != null) { int size = frontDistance.length; @@ -325,7 +325,7 @@ public class Sample { // TODO: no get method for Direction - public void setAngularAttenuation(int filterType, double[] angle, + public void setAngularAttenuation(int filterType, double[] angle, float[] attenuationScaleFactor, float[] filterCutoff) { if (angle != null) { int size = angle.length; @@ -357,7 +357,7 @@ public class Sample { /* * Set Rate ScaleFactor * @since Java 3D 1.3 - */ + */ public void setRateScaleFactor(float scaleFactor) { rateScaleFactor = scaleFactor; } @@ -365,7 +365,7 @@ public class Sample { /* * Get Rate ScaleFactor * @since Java 3D 1.3 - */ + */ public float getRateScaleFactor() { return rateScaleFactor; } @@ -374,7 +374,7 @@ public class Sample { /* * Set Obstruction Gain * @since Java 3D 1.3 - */ + */ public void setObstructionGain(float scaleFactor) { obstructionGain = scaleFactor; } @@ -382,7 +382,7 @@ public class Sample { /* * Get Obstruction Gain * @since Java 3D 1.3 - */ + */ public float getObstructionGain() { return obstructionGain; } @@ -390,7 +390,7 @@ public class Sample { /* * Set Obstruction Filter Cutoff Frequency * @since Java 3D 1.3 - */ + */ public void setObstructionFilter(float cutoffFrequency) { obstructionFilterType = LOW_PASS; obstructionFilterCutoff = cutoffFrequency; @@ -402,7 +402,7 @@ public class Sample { /* * Set Occlusion Gain * @since Java 3D 1.3 - */ + */ public void setOcclusionGain(float scaleFactor) { occlusionGain = scaleFactor; } @@ -410,7 +410,7 @@ public class Sample { /* * Get Occlusion Gain * @since Java 3D 1.3 - */ + */ public float getOcclusionGain() { return occlusionGain; } @@ -418,7 +418,7 @@ public class Sample { /* * Set Occlusion Filter Cutoff Frequency * @since Java 3D 1.3 - */ + */ public void setOcclusionFilter(float cutoffFrequency) { occlusionFilterType = LOW_PASS; occlusionFilterCutoff = cutoffFrequency; @@ -431,14 +431,14 @@ public class Sample { * Clears/re-initialize fields associated with sample data * for this sound, * and frees any device specific data associated with this sample. - */ + */ public void clear() { if (debugFlag) debugPrintln("Sample.clear() entered"); soundData = (MediaContainer)null; soundType = NULL_SAMPLE; gain = 1.0f; - loopCount = 0; + loopCount = 0; duration = DURATION_UNKNOWN; numberOfChannels = 0; vworldXfrm.setIdentity(); @@ -462,7 +462,7 @@ public class Sample { angularFilterCutoff[0] = Sound.NO_FILTER; angularFilterCutoff[1] = Sound.NO_FILTER; } - obstructionGain = 1.0f; + obstructionGain = 1.0f; obstructionFilterType = NO_FILTERING; obstructionFilterCutoff = Sound.NO_FILTER; occlusionGain = 1.0f; diff --git a/src/classes/share/com/sun/j3d/audioengines/javasound/JSAuralParameters.java b/src/classes/share/com/sun/j3d/audioengines/javasound/JSAuralParameters.java index 8f56c82..7d16146 100755 --- a/src/classes/share/com/sun/j3d/audioengines/javasound/JSAuralParameters.java +++ b/src/classes/share/com/sun/j3d/audioengines/javasound/JSAuralParameters.java @@ -56,13 +56,13 @@ public class JSAuralParameters extends com.sun.j3d.audioengines.AuralParameters /** * Reverb Parameters - * + * * dirty flag checked and cleared by render() - */ + */ static int REFLECTION_COEFF_CHANGED = 1; static int REVERB_DELAY_CHANGED = 2; static int REVERB_ORDER_CHANGED = 4; - + int reverbDirty = 0xFFFF; int lastReverbSpeed = 0; // TODO: NOT used yet boolean reverbFlag = false; // previously refered to as reverbOn diff --git a/src/classes/share/com/sun/j3d/audioengines/javasound/JSChannel.java b/src/classes/share/com/sun/j3d/audioengines/javasound/JSChannel.java index af3b6f8..2f07e40 100644 --- a/src/classes/share/com/sun/j3d/audioengines/javasound/JSChannel.java +++ b/src/classes/share/com/sun/j3d/audioengines/javasound/JSChannel.java @@ -81,7 +81,7 @@ class JSChannel { /** * Debug print mechanism for Sound nodes - */ + */ static final boolean debugFlag = false; static void debugPrint(String message) { @@ -113,7 +113,7 @@ class JSChannel { if (debugFlag) { debugPrint("JSChannel: Internal Error initAudioInputStream "); debugPrintln("input stream given is null"); - } + } this.inputStream = null; return null; } @@ -140,7 +140,7 @@ class JSChannel { /****** // QUESTION: HOW do I figure out the data type of the file/url/inputStream???? if (ais instanceof AudioMidiInputStream || - ais instanceof AudioRmfInputStream ) + ais instanceof AudioRmfInputStream ) // QUESTION: can non-cached MIDI files ever be supported ? *******/ return ais; @@ -156,7 +156,7 @@ class JSChannel { if (debugFlag) { debugPrint("JSChannel: Internal Error initAudioInputStream "); debugPrintln("URL given is null"); - } + } this.url = null; return null; } @@ -179,7 +179,7 @@ class JSChannel { inputStream = null; return ais; } // initAudioInputStream - + AudioInputStream reinitAudioInputStream(URL path) { /***** @@ -187,7 +187,7 @@ class JSChannel { if (debugFlag) { debugPrint("JSChannel: Internal Error reinitAudioInputStream "); debugPrintln("URL given is null"); - } + } return null; } try { @@ -199,7 +199,7 @@ class JSChannel { if (debugFlag) { debugPrint("JSChannel: Internal Error reinitAudioInputStream "); debugPrintln("get stream failed"); - } + } e.printStackTrace(); return null; } @@ -217,7 +217,7 @@ class JSChannel { if (debugFlag) { debugPrint("JSChannel: Internal Error reinitAudioInputStream "); debugPrintln("InputStream given is null"); - } + } return null; } try { @@ -234,7 +234,7 @@ class JSChannel { if (debugFlag) { debugPrint("JSChannel: Internal Error reinitAudioInputStream "); debugPrintln("get stream failed"); - } + } e.printStackTrace(); return null; } @@ -259,11 +259,11 @@ class JSChannel { if (debugFlag) debugPrintln("JSChannel:getDuration"); - if (ais == null || audioFormat == null ) { - if (debugFlag) - debugPrintln("JSChannel: Internal Error getDuration"); + if (ais == null || audioFormat == null ) { + if (debugFlag) + debugPrintln("JSChannel: Internal Error getDuration"); return (long)Sample.DURATION_UNKNOWN; - } + } // Otherwise we'll assume that we can calculate this duration // get "duration" of audio stream (wave file) @@ -280,7 +280,7 @@ class JSChannel { debugPrintln(" rate in Frames = " + rateInFrames); if (numFrames <= 0) return (long)Sample.DURATION_UNKNOWN; - long duration = (long)((float)numFrames/rateInFrames); + long duration = (long)((float)numFrames/rateInFrames); if (debugFlag) debugPrintln(" duration(based on ais) = " + duration); return duration; @@ -289,7 +289,7 @@ class JSChannel { /** * Start TWO Samples */ - boolean startSamples(int loopCount, float leftGain, float rightGain, + boolean startSamples(int loopCount, float leftGain, float rightGain, int leftDelay, int rightDelay) { if (debugFlag) debugPrint("JSChannel: startSamples must be overridden"); @@ -354,10 +354,10 @@ class JSChannel { void scaleSampleRate(float scaleFactor) { /** * Change rate for Doppler affect or pitch shifting. - * Engine maximum sample rate is 48kHz so clamp to that + * Engine maximum sample rate is 48kHz so clamp to that * max value. */ - if (debugFlag) + if (debugFlag) debugPrintln("JSChannel: scaleSampleRate"); if (ais == null) { if (debugFlag) { @@ -366,7 +366,7 @@ class JSChannel { } return; } - + AudioFormat audioFormat = ais.getFormat(); float rate = audioFormat.getSampleRate(); @@ -380,7 +380,7 @@ class JSChannel { // need to set FloatControl.Type(SAMPLE_RATE) to new value somehow... if (debugFlag) { - debugPrintln("JSChannel: scaleSampleRate: new rate = " + + debugPrintln("JSChannel: scaleSampleRate: new rate = " + rate * scaleFactor); debugPrintln(" >>>>>>>>>>>>>>> using scaleFactor = " + scaleFactor); @@ -397,14 +397,14 @@ class JSChannel { } int pauseSample() { - /** + /** * Pause playing a sample - */ + */ // TODO: Notify thread return 0; - } + } - int unpauseSamples() { + int unpauseSamples() { /** * Resume playing samples */ @@ -412,10 +412,10 @@ class JSChannel { return 0; } - int unpauseSample() { - /** + int unpauseSample() { + /** * Resume playing a sample - */ + */ // TODO: Notify thread return 0; } diff --git a/src/classes/share/com/sun/j3d/audioengines/javasound/JSClip.java b/src/classes/share/com/sun/j3d/audioengines/javasound/JSClip.java index 740c0b1..b533592 100755 --- a/src/classes/share/com/sun/j3d/audioengines/javasound/JSClip.java +++ b/src/classes/share/com/sun/j3d/audioengines/javasound/JSClip.java @@ -56,7 +56,7 @@ import java.net.*; import java.io.*; import java.io.InputStream; import javax.sound.sampled.*; - + /** * The JSClip Class defines an audio output methods that call JavaSound * Hae mixer methods. @@ -86,7 +86,7 @@ class JSClip extends JSChannel { debugPrintln("JSClip: initDataLine(" + ais + ")"); try { - if (debugFlag) + if (debugFlag) debugPrintln("JSClip: loadSample - try getting new line "); /* * From the AudioInputStream fetch information about the format @@ -104,7 +104,7 @@ class JSClip extends JSChannel { AudioFormat tmp = new AudioFormat( - AudioFormat.Encoding.PCM_SIGNED, + AudioFormat.Encoding.PCM_SIGNED, audioFormat.getSampleRate(), audioFormat.getSampleSizeInBits() * 2, audioFormat.getChannels(), @@ -115,7 +115,7 @@ class JSClip extends JSChannel { audioFormat = tmp; } - /* + /* * ask JavaSound for outline with a format suitable for our * AudioInputStream. In order to ask for a line, a Info object * with the desired properties must be constructed. @@ -134,7 +134,7 @@ class JSClip extends JSChannel { // TODO: JSClip can't be a listener (do we need to do this in the thread?) if (debugFlag) debugPrintln("JSClip: addLineListener for clip"); - line.addLineListener(this); + line.addLineListener(this); ******/ if (debugFlag) @@ -169,7 +169,7 @@ class JSClip extends JSChannel { * actual Java Sound start methods called are as immediate (without * delay between as possible. */ - boolean startSamples(int loopCount, float leftGain, float rightGain, + boolean startSamples(int loopCount, float leftGain, float rightGain, int leftDelay, int rightDelay) { // loop count is ignored for Stream and MIDI // TODO: loop count isn't implemented for MIDI yet @@ -178,10 +178,10 @@ class JSClip extends JSChannel { if (debugFlag) { debugPrint("JSClip: startSamples "); debugPrintln("start stream for Left called with "); - debugPrintln(" gain = " + leftGain + + debugPrintln(" gain = " + leftGain + " delay = " + leftDelay); debugPrintln("start stream for Right called with "); - debugPrintln(" gain = " + rightGain + + debugPrintln(" gain = " + rightGain + " delay = " + rightDelay); } @@ -218,7 +218,7 @@ for now just care about the left return false; } ************/ - + // we know that were processing TWO channels double ZERO_EPS = 0.0039; // approx 1/256 - twice MIDI precision double leftVolume = (double)leftGain; @@ -226,10 +226,10 @@ for now just care about the left // TODO: if not reading/writing done for Clips then I can't do // stereo trick (reading mono file and write to stereo buffer) - // Save time sound started, only in left + // Save time sound started, only in left startTime = System.currentTimeMillis(); if (debugFlag) - debugPrintln("*****start Stream with new start time " + + debugPrintln("*****start Stream with new start time " + startTime); try { // QUESTION: Offset clip is done how??? @@ -242,7 +242,7 @@ set reverb boolean reverbLeft = false; // off; reverb has it own channel boolean reverbRight = reverbLeft; - if (leftDelay < rightDelay) { + if (leftDelay < rightDelay) { XXXX audioLeftStream.start(leftVolume, panLeft, reverbLeft); XXXX audioRightStream.start(rightVolume, panRight, reverbRight); } @@ -265,7 +265,7 @@ XXXX audioLeftStream.start(leftVolume, panLeft, reverbLeft); return false; } - if (debugFlag) + if (debugFlag) debugPrintln("JSClip: startSamples returns"); return true; } // end of startSamples @@ -275,7 +275,7 @@ XXXX audioLeftStream.start(leftVolume, panLeft, reverbLeft); * This method is called specifically for BackgroundSounds. * There is exactly ONE sample (mono or stereo) associated with * this type of sound. Consequently, delay is not applicable. - * Since the sound has no auralAttributes applied to it reverb + * Since the sound has no auralAttributes applied to it reverb * is not applied to the sample. */ boolean startSample(int loopCount, float gain, int delay) { diff --git a/src/classes/share/com/sun/j3d/audioengines/javasound/JSDirectionalSample.java b/src/classes/share/com/sun/j3d/audioengines/javasound/JSDirectionalSample.java index 9191bba..276cd57 100755 --- a/src/classes/share/com/sun/j3d/audioengines/javasound/JSDirectionalSample.java +++ b/src/classes/share/com/sun/j3d/audioengines/javasound/JSDirectionalSample.java @@ -56,7 +56,7 @@ import com.sun.j3d.audioengines.*; import javax.vecmath.*; /** - * The PostionalSample Class defines the data and methods associated with a + * The PostionalSample Class defines the data and methods associated with a * PointSound sample played through the AudioDevice. */ @@ -67,7 +67,7 @@ class JSDirectionalSample extends JSPositionalSample public JSDirectionalSample() { super(); - if (debugFlag) + if (debugFlag) debugPrintln("JSDirectionalSample constructor"); } @@ -91,21 +91,21 @@ class JSDirectionalSample extends JSPositionalSample /* *********************************** - * + * * Intersect ray to head with Ellipse - * + * * ***********************************/ /* * An ellipse is defined using: * (1) the ConeSound's direction vector as the major axis of the ellipse; * (2) the max parameter (a front distance attenuation value) along the - * cone's position axis; and + * cone's position axis; and * (3) the min parameter (a back distance attenuation value) along the * cone's negative axis - * This method calculates the distance from the sound source to the + * This method calculates the distance from the sound source to the * Intersection of the Ellipse with the ray from the sound source to the * listener's head. - * This method returns the resulting distance. + * This method returns the resulting distance. * If an error occurs, -1.0 is returned. * * A calculation are done in 'Cone' space: @@ -121,7 +121,7 @@ class JSDirectionalSample extends JSPositionalSample * H'(x,y) = (cos @, sin @) * | H | * where @ is the angle between the X-axis and the ray to H. * Using the equation of the line thru the origin and H', and the - * equation of ellipse defined with min and max, find the + * equation of ellipse defined with min and max, find the * intersection by solving for x and then y. * * (I) The equation of the line thru the origin and H', and the @@ -164,9 +164,9 @@ class JSDirectionalSample extends JSPositionalSample * x**2 | -------------- + -------------------------------- | = 1 * | [(max+min)]**2 min*max | * - * | | + * | | * | 1 | - * | | + * | | * x**2 = | --------------------------------------- | * | | 4 [sin @/cos @]**2 | | * | | -------------- + ---------------- | | @@ -177,7 +177,7 @@ class JSDirectionalSample extends JSPositionalSample * * Then solve for y by plugging x into Eq.(I). * - * Return the distance from the origin in Cone space to this intersection + * Return the distance from the origin in Cone space to this intersection * point: square_root(x**2 + y**2). * */ @@ -226,9 +226,9 @@ class JSDirectionalSample extends JSPositionalSample debugPrint( " X = " + x ); /* * Solve for y, given the result for x: - * | H'(y) | | sin @ | + * | H'(y) | | sin @ | * y = | ----- | x = | ----- | x - * | H'(x) | | cos @ | + * | H'(x) | | cos @ | */ double y = tangent * x; if (debugFlag) @@ -245,13 +245,13 @@ class JSDirectionalSample extends JSPositionalSample } /* ***************** - * + * * Find Factor - * + * * *****************/ /* * Interpolates the correct attenuation scale factor given a 'distance' - * value. This version used both front and back attenuation distance + * value. This version used both front and back attenuation distance * and scale factor arrays (if non-null) in its calculation of the * the distance attenuation. * If the back attenuation arrays are null then this executes the @@ -259,13 +259,13 @@ class JSDirectionalSample extends JSPositionalSample * This method finds the intesection of the ray from the sound source * to the center-ear, with the ellipses defined by the two sets (front * and back) of distance attenuation arrays. - * This method looks at pairs of intersection distance values to find + * This method looks at pairs of intersection distance values to find * which pair the input distance argument is between: * [intersectionDistance[index] and intersectionDistance[index+1] * The index is used to get factorArray[index] and factorArray[index+1]. * Then the ratio of the 'distance' between this pair of intersection * values is used to scale the two found factorArray values proportionally. - */ + */ float findFactor(double distanceToHead, double[] maxDistanceArray, float[] maxFactorArray, double[] minDistanceArray, float[] minFactorArray) { @@ -311,12 +311,12 @@ class JSDirectionalSample extends JSPositionalSample */ if (distanceToHead >= maxDistanceArray[largestIndex]) { if (debugFlag) - debugPrint(" findFactor: distance > " + + debugPrint(" findFactor: distance > " + maxDistanceArray[largestIndex]); if (debugFlag) - debugPrint(" maxDistanceArray length = " + + debugPrint(" maxDistanceArray length = " + maxDistanceArray.length); - if (debugFlag) + if (debugFlag) debugPrint(" findFactor returns ****** " + maxFactorArray[largestIndex] + " ******"); return maxFactorArray[largestIndex]; @@ -330,12 +330,12 @@ class JSDirectionalSample extends JSPositionalSample if (debugFlag) debugPrint(" findFactor: distance < " + maxDistanceArray[0]); - if (debugFlag) + if (debugFlag) debugPrint(" findFactor returns ****** " + minFactorArray[0] + " ******"); return minFactorArray[0]; } - + /* * distanceToHead is between points within attenuation arrays. * Use binary halfing of distance attenuation arrays. @@ -350,11 +350,11 @@ class JSDirectionalSample extends JSPositionalSample boolean intersectionOnEllipse = false; int factorIndex = -1; - /* + /* * Using binary halving to find the two index values in the - * front and back distance arrays that the distanceToHead + * front and back distance arrays that the distanceToHead * parameter (from sound source position to head) fails between. - * Changing the the current low and high index values + * Changing the the current low and high index values * calculate the intesection of ellipses (defined by this * min/max distance values) with the ray (sound source to * head). Put the resulting value into the distanceArray. @@ -388,12 +388,12 @@ class JSDirectionalSample extends JSPositionalSample * Error in ellipse intersection calculation. Use * average of max/min difference for intersection value. */ - distanceArray[lowIndex] = (minDistanceArray[lowIndex] + + distanceArray[lowIndex] = (minDistanceArray[lowIndex] + maxDistanceArray[lowIndex])*0.5; if (internalErrors) debugPrint( "Internal Error in intersectEllipse; use " + - distanceArray[lowIndex] + + distanceArray[lowIndex] + " for intersection value " ); // Rather than aborting, just use average and go on... intersectionCalculated[lowIndex] = true; @@ -416,7 +416,7 @@ class JSDirectionalSample extends JSPositionalSample if (internalErrors) debugPrint( "Internal Error in intersectEllipse; use " + - distanceArray[highIndex] + + distanceArray[highIndex] + " for intersection value " ); // Rather than aborting, just use average and go on... intersectionCalculated[highIndex] = true; @@ -429,10 +429,10 @@ class JSDirectionalSample extends JSPositionalSample * return factor value directly from array */ if (distanceArray[lowIndex] >= distanceToHead) { - if ((lowIndex != 0) && + if ((lowIndex != 0) && (distanceToHead < distanceArray[lowIndex])) { if (internalErrors) - debugPrint( + debugPrint( "Internal Error: binary halving in " + "findFactor failed; distance < low " + "index value"); @@ -447,7 +447,7 @@ class JSDirectionalSample extends JSPositionalSample break; } else if (distanceArray[highIndex] <= distanceToHead) { - if ((highIndex != largestIndex) && + if ((highIndex != largestIndex) && (distanceToHead > distanceArray[highIndex])) { if (internalErrors) debugPrint( @@ -479,31 +479,31 @@ class JSDirectionalSample extends JSPositionalSample /* * First check to see if distanceToHead is beyond min or max * ellipses, or on an ellipse. - * If so, factor is calculated using the distance Ratio + * If so, factor is calculated using the distance Ratio * (distanceToHead - min) / (max-min) - * where max = maxDistanceArray[factorIndex], and + * where max = maxDistanceArray[factorIndex], and * min = minDistanceArray[factorIndex] */ if (intersectionOnEllipse && factorIndex >= 0) { - if (debugFlag) { + if (debugFlag) { debugPrint( " ratio calculated using factorIndex " + factorIndex); debugPrint( " d.A. max pair for factorIndex " + - maxDistanceArray[factorIndex] + ", " + + maxDistanceArray[factorIndex] + ", " + maxFactorArray[factorIndex]); debugPrint( " d.A. min pair for lowIndex " + - minDistanceArray[factorIndex] + ", " + + minDistanceArray[factorIndex] + ", " + minFactorArray[factorIndex]); } returnValue = ( - ( (distanceArray[factorIndex] - + ( (distanceArray[factorIndex] - minDistanceArray[factorIndex]) / - (maxDistanceArray[factorIndex] - + (maxDistanceArray[factorIndex] - minDistanceArray[factorIndex]) ) * - (maxFactorArray[factorIndex] - + (maxFactorArray[factorIndex] - minFactorArray[factorIndex]) ) + minFactorArray[factorIndex] ; - if (debugFlag) + if (debugFlag) debugPrint(" findFactor returns ****** " + returnValue + " ******"); return (float)returnValue; @@ -515,22 +515,22 @@ class JSDirectionalSample extends JSPositionalSample * the other by highIndex min/max factor arrays. Then the * distance Ratio (defined above) is applied, using these * two factor values, to get the final return value. - */ + */ double highFactorValue = 1.0; double lowFactorValue = 0.0; - highFactorValue = + highFactorValue = ( ((distanceArray[highIndex] - minDistanceArray[highIndex]) / (maxDistanceArray[highIndex]-minDistanceArray[highIndex])) * (maxFactorArray[highIndex] - minFactorArray[highIndex]) ) + minFactorArray[highIndex] ; - if (debugFlag) { + if (debugFlag) { debugPrint( " highFactorValue calculated w/ highIndex " + highIndex); debugPrint( " d.A. max pair for highIndex " + - maxDistanceArray[highIndex] + ", " + + maxDistanceArray[highIndex] + ", " + maxFactorArray[highIndex]); debugPrint( " d.A. min pair for lowIndex " + - minDistanceArray[highIndex] + ", " + + minDistanceArray[highIndex] + ", " + minFactorArray[highIndex]); debugPrint( " highFactorValue " + highFactorValue); } @@ -539,14 +539,14 @@ class JSDirectionalSample extends JSPositionalSample (maxDistanceArray[lowIndex] - minDistanceArray[lowIndex])) * (maxFactorArray[lowIndex] - minFactorArray[lowIndex]) ) + minFactorArray[lowIndex] ; - if (debugFlag) { + if (debugFlag) { debugPrint( " lowFactorValue calculated w/ lowIndex " + lowIndex); debugPrint( " d.A. max pair for lowIndex " + - maxDistanceArray[lowIndex] + ", " + + maxDistanceArray[lowIndex] + ", " + maxFactorArray[lowIndex]); debugPrint( " d.A. min pair for lowIndex " + - minDistanceArray[lowIndex] + ", " + + minDistanceArray[lowIndex] + ", " + minFactorArray[lowIndex]); debugPrint( " lowFactorValue " + lowFactorValue); } @@ -560,7 +560,7 @@ class JSDirectionalSample extends JSPositionalSample * attenuation value between lowIndex and highIndex * gives linearly interpolationed attenuation value */ - if (debugFlag) { + if (debugFlag) { debugPrint( " ratio calculated using distanceArray" + lowIndex + ", highIndex " + highIndex); debugPrint( " calculated pair for lowIndex " + @@ -568,27 +568,27 @@ class JSDirectionalSample extends JSPositionalSample debugPrint( " calculated pair for highIndex " + distanceArray[highIndex]+", "+ highFactorValue ); } - + returnValue = ( ( (distanceToHead - distanceArray[lowIndex]) / (distanceArray[highIndex] - distanceArray[lowIndex]) ) * (highFactorValue - lowFactorValue) ) + factorArray[lowIndex] ; - if (debugFlag) - debugPrint(" findFactor returns ******" + + if (debugFlag) + debugPrint(" findFactor returns ******" + returnValue + " ******"); return (float)returnValue; - } + } } /** - * CalculateDistanceAttenuation - * - * Simply calls ConeSound specific 'findFactor()' with + * CalculateDistanceAttenuation + * + * Simply calls ConeSound specific 'findFactor()' with * both front and back attenuation linear distance and gain scale factor - * arrays. - */ + * arrays. + */ float calculateDistanceAttenuation(float distance) { float factor = findFactor(distance, this.attenuationDistance, this.attenuationGain, this.backAttenuationDistance, @@ -599,11 +599,11 @@ class JSDirectionalSample extends JSPositionalSample return factor; } /** - * CalculateAngularGain - * - * Simply calls generic (for PointSound) 'findFactor()' with + * CalculateAngularGain + * + * Simply calls generic (for PointSound) 'findFactor()' with * a single set of angular attenuation distance and gain scalefactor arrays. - */ + */ float calculateAngularGain() { float angle = findAngularOffset(); float factor = findFactor(angle, this.angularDistance, this.angularGain); @@ -611,14 +611,14 @@ class JSDirectionalSample extends JSPositionalSample return 1.0f; else return factor; - } + } /* ***************** - * + * * Find Angular Offset - * + * * *****************/ - /* + /* * Calculates the angle from the sound's direction axis and the ray from * the sound origin to the listener'center ear. * For Cone Sounds this value is the arc cosine of dot-product between @@ -627,7 +627,7 @@ class JSDirectionalSample extends JSPositionalSample * Center ear position is in Virtual World coordinates. * Assumes that calculation done in VWorld Space... * Assumes that xformPosition is already calculated... - */ + */ float findAngularOffset() { Vector3f unitToEar = new Vector3f(); Vector3f unitDirection = new Vector3f(); @@ -635,10 +635,10 @@ class JSDirectionalSample extends JSPositionalSample Point3f xformCenterEar = centerEars[currentIndex]; float dotProduct; float angle; - /* + /* * TODO: (Question) is assumption that xformed values available O.K. * TODO: (Performance) save this angular offset and only recalculate - * if centerEar or sound position have changed. + * if centerEar or sound position have changed. */ unitToEar.x = xformCenterEar.x - xformPosition.x; unitToEar.y = xformCenterEar.y - xformPosition.y; @@ -653,11 +653,11 @@ class JSDirectionalSample extends JSPositionalSample } /************ - * + * * Calculate Filter - * + * * *****************/ - /* + /* * Calculates the low-pass cutoff frequency filter value applied to the * a sound based on both: * Distance Filter (from Aural Attributes) based on distance @@ -667,7 +667,7 @@ class JSDirectionalSample extends JSPositionalSample * vector between the sounds position and center ear. * The lowest of these two filter is used. * This filter value is stored into the sample's filterFreq field. - */ + */ void calculateFilter(float distance, AuralParameters attribs) { // setting filter cutoff freq to 44.1kHz which, in this // implementation, is the same as not performing filtering @@ -690,7 +690,7 @@ class JSDirectionalSample extends JSPositionalSample } // Calculate angle from direction axis towards listener - float angle = findAngularOffset(); + float angle = findAngularOffset(); distanceFilter = findFactor((double)angle, angularDistance, angularFilterCutoff); if (distanceFilter < 0.0f) @@ -702,10 +702,10 @@ class JSDirectionalSample extends JSPositionalSample distanceFilterFound = false; distanceFilter = -1.0f; } - + if (debugFlag) debugPrint(" calculateFilter arrayLength = " + arrayLength); - + // Angular filter of directional sound sources. arrayLength = angularDistance.length; filterType = angularFilterType; @@ -720,7 +720,7 @@ class JSDirectionalSample extends JSPositionalSample else { angularFilterFound = false; angularFilter = -1.0f; - } + } filterFlag = distanceFilterFound || angularFilterFound; if (distanceFilter < 0.0f) diff --git a/src/classes/share/com/sun/j3d/audioengines/javasound/JSPositionalSample.java b/src/classes/share/com/sun/j3d/audioengines/javasound/JSPositionalSample.java index 9bbc5ae..20a9682 100755 --- a/src/classes/share/com/sun/j3d/audioengines/javasound/JSPositionalSample.java +++ b/src/classes/share/com/sun/j3d/audioengines/javasound/JSPositionalSample.java @@ -56,12 +56,12 @@ import javax.vecmath.*; import com.sun.j3d.audioengines.*; /** - * The PostionalSample Class defines the data and methods associated with a + * The PostionalSample Class defines the data and methods associated with a * PointSound sample played thru the AudioDevice. */ class JSPositionalSample extends JSSample -{ +{ // maintain fields for stereo channel rendering float leftGain = 1.0f; // scale factor @@ -79,18 +79,18 @@ class JSPositionalSample extends JSSample * are allocated, one each for the left and right channels, played at * a different (delayed) time and with a different gain value. */ - int secondIndex = NULL_SAMPLE; + int secondIndex = NULL_SAMPLE; /** * 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 + * 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. */ - int reverbIndex = NULL_SAMPLE; + int reverbIndex = NULL_SAMPLE; /** * Save ear positions transformed into VirtualWorld coords from Head coords @@ -118,13 +118,13 @@ class JSPositionalSample extends JSSample * sound was last processed. * Process delta distance and time as part of Doppler calculations. */ - static int MAX_DISTANCES = 4; - int numDistances = 0; + static int MAX_DISTANCES = 4; + int numDistances = 0; // TODO: time is based on changes to position!!! only // TODO: must shap shot when either Position OR ear changes!!! // TODO: must grab all changes to VIEW parameters (could change ear)!!! // not just when pointer to View changes!! - long[] times = new long[MAX_DISTANCES]; + long[] times = new long[MAX_DISTANCES]; Point3f[] positions = new Point3f[MAX_DISTANCES]; // xformed sound source positions Point3f[] centerEars = new Point3f[MAX_DISTANCES]; // xformed center ear positions /* @@ -134,14 +134,14 @@ class JSPositionalSample extends JSSample int firstIndex = 0; int lastIndex = 0; int currentIndex = 0; - + /* * Allow changes in Doppler rate only small incremental values otherwise * you hear skips in the pitch of a sound during playback. * When playback is faster, allow delta changes: - * (diff in Factor for octave (1.0))/(12 1/2-steps))*(1/4) of half-step + * (diff in Factor for octave (1.0))/(12 1/2-steps))*(1/4) of half-step * When playback is slower, allow delta changes: - * (diff in Factor for octave (0.5))/(12 1/2-steps))*(1/4) of half-step + * (diff in Factor for octave (0.5))/(12 1/2-steps))*(1/4) of half-step */ double lastRequestedDopplerRateRatio = -1.0f; double lastActualDopplerRateRatio = -1.0f; @@ -155,13 +155,13 @@ class JSPositionalSample extends JSSample /* * Process request for Filtering fields - */ + */ boolean filterFlag = false; float filterFreq = -1.0f; /* * Construct a new audio device Sample object - */ + */ public JSPositionalSample() { super(); if (debugFlag) @@ -178,7 +178,7 @@ class JSPositionalSample extends JSSample // TODO: get/set reverbChannel to JSStream/Clip/MIDI /* * Process request for Filtering fields - */ + */ boolean getFilterFlag() { return filterFlag; } @@ -186,11 +186,11 @@ class JSPositionalSample extends JSSample return filterFreq; } - + /** - * Clears the fields associated with sample data for this sound, and + * Clears the fields associated with sample data for this sound, and * frees any device specific data associated with this sample. - */ + */ public void clear() { if (debugFlag) debugPrint("JSPositionalSample.clear() enter"); @@ -212,9 +212,9 @@ class JSPositionalSample extends JSSample } /** - * Reset time and count based fields associated with sample data + * Reset time and count based fields associated with sample data * for this sound - */ + */ void reset() { if (debugFlag) debugPrint("JSPositionalSample.reset() enter"); @@ -224,7 +224,7 @@ class JSPositionalSample extends JSSample sourcePositionChange = -1.0; headPositionChange = -1.0; rateRatio = 1.0f; - numDistances = 0; + numDistances = 0; averageDistances = false; if (debugFlag) debugPrint("JSPositionalSample.reset() exit"); @@ -258,7 +258,7 @@ class JSPositionalSample extends JSSample currentIndex %= MAX_DISTANCES; lastIndex %= MAX_DISTANCES; firstIndex %= MAX_DISTANCES; - } + } } // Not only do we transform position but delta time is calculated and @@ -272,7 +272,7 @@ class JSPositionalSample extends JSSample Point3f newPosition = new Point3f(); if (debugFlag) debugPrint("*** setXformedPosition"); - // xform Position + // xform Position if (getVWrldXfrmFlag()) { if (debugFlag) debugPrint(" Transform set so transform pos"); @@ -294,30 +294,30 @@ class JSPositionalSample extends JSSample incrementIndices(); // store new transformed position - times[currentIndex] = System.currentTimeMillis(); + times[currentIndex] = System.currentTimeMillis(); positions[currentIndex].set(newPosition); if (debugFlag) debugPrint(" xform(sound)Position -" + " positions[" + currentIndex + "] = (" + - positions[currentIndex].x + ", " + + positions[currentIndex].x + ", " + positions[currentIndex].y + ", " + positions[currentIndex].z + ")"); - + // since this is a change to the sound position and not the // head save the last head position into the current element if (numDistances > 1) centerEars[currentIndex].set(centerEars[lastIndex]); - } + } /** - * Set Doppler effect Rate + * 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), + * 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). @@ -335,9 +335,9 @@ class JSPositionalSample extends JSSample * | 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 | @@ -345,13 +345,13 @@ class JSPositionalSample extends JSSample * where frequencyScaleFactor, rollOff, velocityScaleFactor all come from * the active AuralAttributes parameters. * The following special cases must be test for AuralAttribute parameters: - * rolloff + * rolloff * Value MUST be > zero for any sound to be heard! * If value is zero, all sounds affected by AuralAttribute region are silent. - * velocityScaleFactor + * velocityScaleFactor * Value MUST be > zero for any sound to be heard! * If value is zero, all sounds affected by AuralAttribute region are paused. - * frequencyScaleFactor + * frequencyScaleFactor * Value of zero disables Doppler calculations: * Sfreq' = Sfreq * frequencyScaleFactor * @@ -378,7 +378,7 @@ class JSPositionalSample extends JSSample Point3f xformCenterEar; float averagedSoundDistances = 0.0f; float averagedEarsDistances = 0.0f; - + /* * Average the differences between the last MAX_DISTANCE * sound positions and head positions @@ -428,7 +428,7 @@ class JSPositionalSample extends JSSample // can't calculate change in direction return 0.0f; // sample rate ratio is zero } - + deltaTime = times[currentIndex] - times[firstIndex]; for (int i=0; i<(MAX_DISTANCES-1); i++) { averagedSoundDistances += positions[i+1].distance(positions[i]); @@ -442,12 +442,12 @@ class JSPositionalSample extends JSSample debugPrint(" " + "delta time = " + deltaTime ); debugPrint(" " + - "soundPosition delta = " + + "soundPosition delta = " + xformPosition.distance(lastXformPosition)); debugPrint(" " + "soundVelocity = " + soundVelocity); debugPrint(" " + - "headPosition delta = " + + "headPosition delta = " + xformCenterEar.distance(lastXformCenterEar)); debugPrint(" " + "headVelocity = " + headVelocity); @@ -467,7 +467,7 @@ class JSPositionalSample extends JSSample headVelocity *= velocityScaleFactor; if (dopplerFlag) { debugPrint(" " + - "attrib velocity scale factor = " + + "attrib velocity scale factor = " + velocityScaleFactor ); debugPrint(" " + "new soundVelocity = " + soundVelocity); @@ -485,7 +485,7 @@ class JSPositionalSample extends JSSample numerator = speedOfSound + headVelocity; denominator = speedOfSound - soundVelocity; } - else { + else { // sound and head moving away from each other // note: no change in distance case covered above if (dopplerFlag) @@ -503,7 +503,7 @@ class JSPositionalSample extends JSSample } else if (denominator <= 0.0) { if (dopplerFlag) - debugPrint("JSPositionalSample.calculateDoppler: " + + debugPrint("JSPositionalSample.calculateDoppler: " + "BOOM!! - velocity of sound source negative"); return -1.0f; } @@ -547,7 +547,7 @@ class JSPositionalSample extends JSSample debugPrint(" No change in ear, so don't reset"); return; } - // store xform Ear + // store xform Ear incrementIndices(); times[currentIndex] = System.currentTimeMillis(); centerEars[currentIndex].set(xformCenterEar); @@ -565,14 +565,14 @@ class JSPositionalSample extends JSSample // TODO: check dirty flags coming in // For now, recalculate ear positions by forcing earsXformed false - boolean earsXformed = false; - if (!earsXformed) { + boolean earsXformed = false; + if (!earsXformed) { if (view != null) { PhysicalBody body = view.getPhysicalBody(); if (body != null) { // Get Head Coord. to Virtual World transform - // TODO: re-enable this when userHeadToVworld is + // TODO: re-enable this when userHeadToVworld is // implemented correctly!!! Transform3D headToVwrld = new Transform3D(); view.getUserHeadToVworld(headToVwrld); @@ -608,20 +608,20 @@ class JSPositionalSample extends JSSample // calculate the new (current) mid-point between the ears // find the mid point between left and right ear positions - xformCenterEar.x = xformLeftEar.x + + xformCenterEar.x = xformLeftEar.x + ((xformRightEar.x - xformLeftEar.x)*0.5f); - xformCenterEar.y = xformLeftEar.y + + xformCenterEar.y = xformLeftEar.y + ((xformRightEar.y - xformLeftEar.y)*0.5f); - xformCenterEar.z = xformLeftEar.z + + xformCenterEar.z = xformLeftEar.z + ((xformRightEar.z - xformLeftEar.z)*0.5f); // TODO: when head changes earDirty should be set! // earDirty = false; if (debugFlag) { debugPrint(" earXformed CALCULATED"); - debugPrint(" xformCenterEar = " + + debugPrint(" xformCenterEar = " + xformCenterEar.x + " " + xformCenterEar.y + " " + - xformCenterEar.z ); + xformCenterEar.z ); } earsXformed = true; } // end of body NOT null @@ -635,19 +635,19 @@ class JSPositionalSample extends JSSample // uses the default head position of (0.0, -0.03, 0.095) if (debugFlag) debugPrint(" earXformed NOT calculated"); - } + } return earsXformed; } - /** + /** * Render this sample * * Calculate the audiodevice parameters necessary to spatially play this * sound. - */ + */ public void render(int dirtyFlags, View view, AuralParameters attribs) { if (debugFlag) - debugPrint("JSPositionalSample.render"); + debugPrint("JSPositionalSample.render"); updateEar(dirtyFlags, view); /* @@ -658,7 +658,7 @@ class JSPositionalSample extends JSSample * are silent. * FrequencyScaleFactor value MUST be > zero for any sound to be heard! * since Sfreq' = Sfreq * frequencyScaleFactor. - * If FrequencyScaleFactor is zero, all sounds affected by + * If FrequencyScaleFactor is zero, all sounds affected by * AuralAttribute region are paused. * VelocityScaleFactor value of zero disables Doppler calculations. * @@ -707,7 +707,7 @@ class JSPositionalSample extends JSSample // error returned by calculateDoppler if (debugFlag) { debugPrint("JSPositionalSample: render: " + - "dopplerRatio returned = " + + "dopplerRatio returned = " + dopplerRatio + "< 0"); } // TODO: Make sound silent @@ -732,10 +732,10 @@ class JSPositionalSample extends JSSample } else { // auralAttributes not null but velocityFactor <= 0 // Doppler is disabled - rateRatio = frequencyScaleFactor * getRateScaleFactor(); + rateRatio = frequencyScaleFactor * getRateScaleFactor(); } } - /* + /* * since aural attributes undefined, default values are used, * thus no Doppler calculated */ @@ -746,31 +746,31 @@ class JSPositionalSample extends JSSample } this.panSample(attribs); - } + } /* ***************** - * + * * Calculate Angular Gain - * + * * *****************/ - /* + /* * Calculates the Gain scale factor applied to the overall gain for * a sound based on angle between a sound's projected direction and the * vector between the sounds position and center ear. * * For Point Sounds this value is always 1.0f. - */ + */ float calculateAngularGain() { return(1.0f); } /* ***************** - * + * * Calculate Filter - * + * * *****************/ - /* - * Calculates the low-pass cutoff frequency filter value applied to the + /* + * Calculates the low-pass cutoff frequency filter value applied to the * a sound based on both: * Distance Filter (from Aural Attributes) based on distance * between the sound and the listeners position @@ -779,7 +779,7 @@ class JSPositionalSample extends JSSample * vector between the sounds position and center ear. * The lowest of these two filter is used. * This filter value is stored into the sample's filterFreq field. - */ + */ void calculateFilter(float distance, AuralParameters attribs) { // setting filter cutoff freq to 44.1kHz which, in this // implementation, is the same as not performing filtering @@ -799,7 +799,7 @@ class JSPositionalSample extends JSSample for (int i=0; i<arrayLength; i++) debugPrint((float)(distanceArray[i]) + ", " + cutoffArray[i]); } - distanceFilter = findFactor((double)distance, + distanceFilter = findFactor((double)distance, distanceArray, cutoffArray); if (distanceFilter < 0.0f) distanceFilterFound = false; @@ -820,15 +820,15 @@ class JSPositionalSample extends JSSample filterFlag = distanceFilterFound || angularFilterFound; filterFreq = distanceFilter; - if (debugFlag) + if (debugFlag) debugPrint(" calculateFilter flag,freq = " + filterFlag + "," + filterFreq ); } /* ***************** - * + * * Find Factor - * + * * *****************/ /* * Interpolates the correct output factor given a 'distance' value @@ -840,12 +840,12 @@ class JSPositionalSample extends JSSample * pair the input distance argument is between distanceArray[index] and * distanceArray[index+1]. * The index is used to get factorArray[index] and factorArray[index+1]. - * Then the ratio of the 'distance' between this pair of distanceArray + * Then the ratio of the 'distance' between this pair of distanceArray * values is used to scale the two found factorArray values proportionally. * The resulting factor is returned, unless there is an error, then -1.0 * is returned. - */ - float findFactor(double distance, + */ + float findFactor(double distance, double[] distanceArray, float[] factorArray) { int index, lowIndex, highIndex, indexMid; @@ -873,7 +873,7 @@ class JSPositionalSample extends JSSample */ if (distance >= distanceArray[largestIndex]) { if (debugFlag) { - debugPrint(" findFactor: distance > " + + debugPrint(" findFactor: distance > " + distanceArray[largestIndex]); debugPrint(" distanceArray length = "+ arrayLength); } @@ -884,7 +884,7 @@ class JSPositionalSample extends JSSample debugPrint(" findFactor: distance < " + distanceArray[0]); return factorArray[0]; - } + } /* * Distance between points within attenuation array. * Use binary halfing of distance array @@ -896,11 +896,11 @@ class JSPositionalSample extends JSSample debugPrint(" while loop to find index: "); while (lowIndex < (highIndex-1)) { if (debugFlag) { - debugPrint(" lowIndex " + lowIndex + + debugPrint(" lowIndex " + lowIndex + ", highIndex " + highIndex); - debugPrint(" d.A. pair for lowIndex " + + debugPrint(" d.A. pair for lowIndex " + distanceArray[lowIndex] + ", " + factorArray[lowIndex] ); - debugPrint(" d.A. pair for highIndex " + + debugPrint(" d.A. pair for highIndex " + distanceArray[highIndex] + ", " + factorArray[highIndex] ); } /* @@ -917,7 +917,7 @@ class JSPositionalSample extends JSSample if (debugFlag) { debugPrint( " index == distanceGain " + lowIndex); - debugPrint(" findFactor returns [LOW=" + + debugPrint(" findFactor returns [LOW=" + lowIndex + "] " + factorArray[lowIndex]); } // take value of scale factor directly from factorArray @@ -932,13 +932,13 @@ class JSPositionalSample extends JSSample if (debugFlag) { debugPrint( " index == distanceGain " + highIndex); - debugPrint(" findFactor returns [HIGH=" + + debugPrint(" findFactor returns [HIGH=" + highIndex + "] " + factorArray[highIndex]); } // take value of scale factor directly from factorArray return factorArray[highIndex]; } - if (distance > distanceArray[lowIndex] && + if (distance > distanceArray[lowIndex] && distance < distanceArray[highIndex] ) { indexMid = lowIndex + ((highIndex - lowIndex) / 2); if (distance <= distanceArray[indexMid]) @@ -950,7 +950,7 @@ class JSPositionalSample extends JSSample } /* of while */ /* - * ratio: distance from listener to sound source + * ratio: distance from listener to sound source * between lowIndex and highIndex times * attenuation value between lowIndex and highIndex * gives linearly interpolationed attenuation value @@ -958,27 +958,27 @@ class JSPositionalSample extends JSSample if (debugFlag) { debugPrint( " ratio calculated using lowIndex " + lowIndex + ", highIndex " + highIndex); - debugPrint( " d.A. pair for lowIndex " + + debugPrint( " d.A. pair for lowIndex " + distanceArray[lowIndex]+", "+factorArray[lowIndex] ); - debugPrint( " d.A. pair for highIndex " + + debugPrint( " d.A. pair for highIndex " + distanceArray[highIndex]+", "+factorArray[highIndex] ); } - float outputFactor = + float outputFactor = ((float)(((distance - distanceArray[lowIndex])/ (distanceArray[highIndex] - distanceArray[lowIndex]) ) ) * (factorArray[highIndex] - factorArray[lowIndex]) ) + - factorArray[lowIndex] ; + factorArray[lowIndex] ; if (debugFlag) debugPrint(" findFactor returns " + outputFactor); return outputFactor; - } + } } /** * CalculateDistanceAttenuation * - * Simply calls generic (for PointSound) 'findFactor()' with + * Simply calls generic (for PointSound) 'findFactor()' with * a single set of attenuation distance and gain scale factor arrays. */ float calculateDistanceAttenuation(float distance) { @@ -992,11 +992,11 @@ class JSPositionalSample extends JSSample } /* ****************** - * + * * Pan Sample - * + * * ******************/ - /* + /* * Sets pan and delay for a single sample associated with this Sound. * Front and Back quadrants are treated the same. */ @@ -1046,7 +1046,7 @@ class JSPositionalSample extends JSSample float distanceGain = 1.0f; float allGains = this.gain; // product of gain scale factors - + Point3f workingPosition = new Point3f(); Point3f workingCenterEar = new Point3f(); @@ -1085,7 +1085,7 @@ class JSPositionalSample extends JSSample sourceToLeftEar.z = xformLeftEar.z - workingPosition.z; /* - * get distances from SoundSource to + * get distances from SoundSource to * (i) head origin * (ii) right ear * (iii) left ear @@ -1118,7 +1118,7 @@ class JSPositionalSample extends JSSample xformHeadZAxis.length()); } - // Dot Product + // Dot Product double dotProduct = (double)( (sourceToCenterEar.dot(xformHeadZAxis))/ (sourceToCenterEar.length() * xformHeadZAxis.length())); @@ -1146,10 +1146,10 @@ class JSPositionalSample extends JSSample if (debugFlag) debugPrint( " gamma " + gamma ); - rightEarClosest = + rightEarClosest = (distanceSourceToRightEar>distanceSourceToLeftEar) ? false : true ; /* - * Determine the quadrant sound is in + * Determine the quadrant sound is in */ if (rightEarClosest) { if (debugFlag) @@ -1184,14 +1184,14 @@ class JSPositionalSample extends JSSample debugPrint( " partial distance from edge of head to source = " + distanceSourceToCenterEar); if (rightEarClosest) { - distanceSourceToLeftEar = + distanceSourceToLeftEar = DISTANCE + radiusOfHead * (halfPi+alpha-gamma); if (debugFlag) debugPrint(" new distance from left ear to source = " + distanceSourceToLeftEar); - } + } else { - distanceSourceToRightEar = + distanceSourceToRightEar = DISTANCE + radiusOfHead * (halfPi+alpha-gamma); if (debugFlag) debugPrint(" new distance from right ear to source = " @@ -1207,16 +1207,16 @@ class JSPositionalSample extends JSSample if (debugFlag) debugPrint(" closest path is also indirect "); // Path of sound to closest ear is indirect - + if (rightEarClosest) { - distanceSourceToRightEar = + distanceSourceToRightEar = DISTANCE + radiusOfHead * (halfPi-alpha-gamma); if (debugFlag) debugPrint(" new distance from right ear to source = " + distanceSourceToRightEar); } else { - distanceSourceToLeftEar = + distanceSourceToLeftEar = DISTANCE + radiusOfHead * (halfPi-alpha-gamma); if (debugFlag) debugPrint(" new distance from left ear to source = " @@ -1240,11 +1240,11 @@ class JSPositionalSample extends JSSample /** * Short-cut taken. Rather than using actual delays from source - * (where the overall distances would be taken into account in + * (where the overall distances would be taken into account in * determining delay) the difference in the left and right delay * are applied. * This approach will be preceptibly wrong for sound sources that - * are very far away from the listener so both ears would have + * are very far away from the listener so both ears would have * large delay. */ sampleRate = channel.rateInHz * (0.001f); // rate in milliseconds @@ -1307,7 +1307,7 @@ class JSPositionalSample extends JSSample if (debugFlag) debugPrint("panSample: quadrant " + quadrant); switch (quadrant) { - case 1: + case 1: // Sound from front, right of center of head case 4: // Sound from back, right of center of head @@ -1329,7 +1329,7 @@ class JSPositionalSample extends JSSample // Combines distance and angular filter to set this sample's current // frequency cutoff value - calculateFilter(distanceSourceToCenterEar, attribs); + calculateFilter(distanceSourceToCenterEar, attribs); } /* panSample() */ diff --git a/src/classes/share/com/sun/j3d/audioengines/javasound/JSSample.java b/src/classes/share/com/sun/j3d/audioengines/javasound/JSSample.java index 91e4eb3..750e177 100755 --- a/src/classes/share/com/sun/j3d/audioengines/javasound/JSSample.java +++ b/src/classes/share/com/sun/j3d/audioengines/javasound/JSSample.java @@ -68,29 +68,29 @@ class JSSample extends com.sun.j3d.audioengines.Sample * with each sound. */ - /** + /** * Sound Data Types - * + * * Samples can be processed as streaming or buffered data. * Fully spatializing sound sources may require data to be buffered. - * + * * Sound data specified as Streaming is not copied by the AudioDevice * driver implementation. It is up the application to ensure that * this data is continuously accessible during sound rendering. * Futhermore, full sound spatialization may not be possible, for * all AudioDevice implementations on unbuffered sound data. - */ + */ static final int STREAMING_AUDIO_DATA = 1; - /** + /** * Sound data specified as Buffered is copied by the AudioDevice * driver implementation. - */ + */ static final int BUFFERED_AUDIO_DATA = 2; - /** - * MIDI data + /** + * MIDI data * TODO: differentiate between STREAMING and BUFFERED MIDI data * right now all MIDI data is buffered - */ + */ static final int STREAMING_MIDI_DATA = 3; static final int BUFFERED_MIDI_DATA = 3; static final int UNSUPPORTED_DATA_TYPE = -1; @@ -99,19 +99,19 @@ class JSSample extends com.sun.j3d.audioengines.Sample /** * sound data types: BUFFERED (cached) or STREAMING (non-cached) - */ + */ int dataType = BUFFERED_AUDIO_DATA; JSChannel channel = null; /** * Offset pointer within currently playing sample data - */ + */ long dataOffset = 0; /* * Maintain continuously playing silent sound sources. - */ + */ long timeDeactivated = 0; long positionDeactivated = 0; @@ -128,7 +128,7 @@ class JSSample extends com.sun.j3d.audioengines.Sample public JSSample() { super(); - if (debugFlag) + if (debugFlag) debugPrintln("JSSample constructor"); } @@ -153,19 +153,19 @@ class JSSample extends com.sun.j3d.audioengines.Sample else rateRatio = currentRateRatio * freqScaleFactor; } - else - rateRatio = currentRateRatio; + else + rateRatio = currentRateRatio; } /** * Clears/re-initialize fields associated with sample data for * this sound, * and frees any device specific data associated with this sample. - */ + */ public void clear() { super.clear(); if (debugFlag) - debugPrintln("JSSample.clear() entered"); + debugPrintln("JSSample.clear() entered"); // TODO: unload sound data at device // null out samples element that points to this? // would this cause samples list size to shrink? @@ -183,7 +183,7 @@ class JSSample extends com.sun.j3d.audioengines.Sample rateRatio = 1.0f; channel = null; if (debugFlag) - debugPrintln("JSSample.clear() exited"); + debugPrintln("JSSample.clear() exited"); } // @return error true if error occurred @@ -203,11 +203,11 @@ class JSSample extends com.sun.j3d.audioengines.Sample // TODO: How do we determine if the file is a MIDI file??? // for now set dataType to BUFFERED_ or STREAMING_AUDIO_DATA // used to test for ais instanceof AudioMidiInputStream || - // ais instanceof AudioRmfInputStream ) + // ais instanceof AudioRmfInputStream ) // then set dataType = JSSample.BUFFERED_MIDI_DATA; // QUESTION: can non-cached MIDI files ever be supported ? /**************** - // TODO: when we have a way to determine data type use code below + // TODO: when we have a way to determine data type use code below if (dataType==UNSUPPORTED_DATA_TYPE OR error_occurred) clearSound(index); if (debugFlag) @@ -222,10 +222,10 @@ class JSSample extends com.sun.j3d.audioengines.Sample dataType = STREAMING_AUDIO_DATA; if ((url == null) && (inputStream == null) && (path == null)) { - if (debugFlag) + if (debugFlag) debugPrint("JavaSoundMixer.loadSound null data - return error"); return true; - } + } // get ais if (path != null) { @@ -244,10 +244,10 @@ class JSSample extends com.sun.j3d.audioengines.Sample // get DataLine channel based on data type if (dataType == BUFFERED_AUDIO_DATA) { - if (debugFlag) + if (debugFlag) debugPrintln("JSSample.load dataType = BUFFERED "); channel = new JSClip(); - if (debugFlag) + if (debugFlag) debugPrintln(" calls JSClip.initAudioInputStream"); if (url != null) ais = channel.initAudioInputStream(url, cacheFlag); @@ -259,15 +259,15 @@ class JSSample extends com.sun.j3d.audioengines.Sample "initAudioInputStream() failed"); return true; } - if (debugFlag) + if (debugFlag) debugPrintln(" calls JSClip.initDataLine"); dataLine = channel.initDataLine(ais); } else if (dataType == STREAMING_AUDIO_DATA) { - if (debugFlag) + if (debugFlag) debugPrintln("JSSample.load dataType = STREAMING "); channel = new JSStream(); - if (debugFlag) + if (debugFlag) debugPrintln(" calls JSStream.initAudioInputStream"); if (url != null) ais = channel.initAudioInputStream(url, cacheFlag); @@ -279,14 +279,14 @@ class JSSample extends com.sun.j3d.audioengines.Sample "initAudioInputStream() failed"); return true; } - if (debugFlag) + if (debugFlag) debugPrintln(" calls JSStream.initDataLine"); dataLine = channel.initDataLine(ais); } else { if (debugFlag) - debugPrintln("JSSample.load doesn't support MIDI yet"); - } + debugPrintln("JSSample.load doesn't support MIDI yet"); + } if (dataLine == null) { if (debugFlag) debugPrint("JSSample.load initDataLine failed "); @@ -315,47 +315,47 @@ class JSSample extends com.sun.j3d.audioengines.Sample rateRatio = 1.0f; } -// TODO: NEED methods for any field accessed by both JSThread and -// JavaSoundMixer so that we can make these MT safe?? +// TODO: NEED methods for any field accessed by both JSThread and +// JavaSoundMixer so that we can make these MT safe?? /* * Process request for Filtering fields - */ - boolean getFilterFlag() { + */ + boolean getFilterFlag() { return false; } - float getFilterFreq() { + float getFilterFreq() { return -1.0f; } - void setCurrentRateRatio(float ratio) { + void setCurrentRateRatio(float ratio) { currentRateRatio = ratio; } - float getCurrentRateRatio() { + float getCurrentRateRatio() { return currentRateRatio; } - void setTargetRateRatio(float ratio) { + void setTargetRateRatio(float ratio) { targetRateRatio = ratio; } - float getTargetRateRatio() { + float getTargetRateRatio() { return targetRateRatio; } - void setRampRateFlag(boolean flag) { + void setRampRateFlag(boolean flag) { rampRateFlag = flag; } - boolean getRampRateFlag() { + boolean getRampRateFlag() { return rampRateFlag; } - void setDataType(int type) { + void setDataType(int type) { dataType = type; } - int getDataType() { + int getDataType() { return dataType; } diff --git a/src/classes/share/com/sun/j3d/audioengines/javasound/JSThread.java b/src/classes/share/com/sun/j3d/audioengines/javasound/JSThread.java index 784186e..9bde9fb 100755 --- a/src/classes/share/com/sun/j3d/audioengines/javasound/JSThread.java +++ b/src/classes/share/com/sun/j3d/audioengines/javasound/JSThread.java @@ -67,7 +67,7 @@ class JSThread extends com.sun.j3d.audioengines.AudioEngineThread { */ int totalChannels = 0; /** - * flags denoting if dynamic gain or rate interpolation is to be performed + * flags denoting if dynamic gain or rate interpolation is to be performed */ boolean rampGain = false; @@ -104,7 +104,7 @@ class JSThread extends com.sun.j3d.audioengines.AudioEngineThread { /** * This method performs one iteration of pending work to do - * + * * Wildly "garbled" sounds was caused by unequal changes in delta * time verses delta distances (resulting in jumps in rate factors * calculated for Doppler. This work thread is meant to smoothly @@ -127,7 +127,7 @@ can keep my own loop count for streams??? not really // QUESTION: will size ever get smaller after get performed??? int numSamples = audioEngine.getSampleListSize(); JSSample sample = null; - int numRateRamps = 0; + int numRateRamps = 0; for (int index = 0; index < numSamples; index++) { // loop thru samples looking for ones needing rate incremented sample = (JSSample)audioEngine.getSample(index); @@ -166,7 +166,7 @@ runMonitor(RUN, 0, null); /** * Gradually change rate scale factor - * + * * If the rate change is too great suddenly, it sounds like a * jump, so we need to change gradually over time. * Since an octive delta change up is 2.0 but down is 0.5, forced @@ -202,7 +202,7 @@ runMonitor(RUN, 0, null); } endOfRamp = false; // target value not reached } - /* + /* * otherwise delta change is within tolerance * so use requested RateRatio as calculated w/out change */ @@ -328,7 +328,7 @@ leftGain, rightGain ******/ } - void setSampleDelay(JSSample sample, JSAuralParameters attribs) { + void setSampleDelay(JSSample sample, JSAuralParameters attribs) { /****** // take fields as already set in sample and updates delay // called after sample.render performed @@ -408,7 +408,7 @@ leftDelay, rightDelay // take fields as already set in sample and updates rate // called after sample.render performed this.setSampleRate(sample, rateScaleFactor); - // disables rate from being gradually increased or decreased + // disables rate from being gradually increased or decreased // don't set global thread flat rampRate false just because // one sample's rate is set to a specific value. sample.setRampRateFlag(false); @@ -441,7 +441,7 @@ leftDelay, rightDelay com.sun.j3d.audio.J3DHaeClip.setSampleGain(index, gain); } else { - // dataType==JSAuralParameters.STREAMING_MIDI_DATA + // dataType==JSAuralParameters.STREAMING_MIDI_DATA // dataType==JSAuralParameters.BUFFERED_MIDI_DATA com.sun.j3d.audio.J3DHaeMidi.setSampleGain(index, gain); } @@ -490,7 +490,7 @@ leftDelay, rightDelay } ***********/ sample.setCurrentRateRatio(scaleFactor); - } + } boolean startSample(JSSample sample) { /********** @@ -558,7 +558,7 @@ leftDelay, rightDelay int reverbRtrnVal = JSClip.startSample( ((JSPositionalSample)sample).getReverbIndex(), loopCount, reverbGain); - + if (debugFlag) debugPrint("JSThread " + "start stream positionalSound with gain " + leftGain @@ -583,7 +583,7 @@ leftDelay, rightDelay // TODO: positional MIDI sounds not supported. // The above startSamples really just start on sample // Don't bother with reverb channel for now. - + // // start up reverb channel w/out delay even if reverb not on now // float reverbGain = 0.0f; @@ -668,7 +668,7 @@ leftDelay, rightDelay ************/ return true; } - + void pauseSample(JSSample sample) { /********** @@ -740,7 +740,7 @@ leftDelay, rightDelay ((JSPositionalSample)sample).getSecondIndex()); returnValue = JSStream.unpauseSample( ((JSPositionalSample)sample).getReverbIndex()); - } + } else returnValue = JSStream.unpauseSample(sample); } @@ -751,7 +751,7 @@ leftDelay, rightDelay ((JSPositionalSample)sample).getSecondIndex()); returnValue = JSClip.unpauseSample( ((JSPositionalSample)sample).getReverbIndex()); - } + } else returnValue = JSClip.unpauseSample(sample); } @@ -780,14 +780,14 @@ leftDelay, rightDelay if (debugFlag) debugPrint( "JSThread: Internal Error unpauseSample " + "for sample " + sample + " failed"); - + } // QUESTION: return value or not??? return; *************/ } -// TODO: +// TODO: void muteSample(JSSample sample) { // is this already muted? if so don't do anytning @@ -795,7 +795,7 @@ leftDelay, rightDelay // as a stop, advance restart... } -// TODO: +// TODO: void unmuteSample(JSSample sample) { if (debugFlag) debugPrint( "JSThread.unmuteSample not implemented"); @@ -834,7 +834,7 @@ leftDelay, rightDelay /** * Code to close the device * @return flag: true is closed sucessfully, false if error - */ + */ boolean close() { // TODO: for now do nothing return false; diff --git a/src/classes/share/com/sun/j3d/audioengines/javasound/JavaSoundMixer.java b/src/classes/share/com/sun/j3d/audioengines/javasound/JavaSoundMixer.java index 29cda52..75ce7ae 100755 --- a/src/classes/share/com/sun/j3d/audioengines/javasound/JavaSoundMixer.java +++ b/src/classes/share/com/sun/j3d/audioengines/javasound/JavaSoundMixer.java @@ -68,12 +68,12 @@ public class JavaSoundMixer extends AudioEngine3DL2 { // Debug print flags and methods static final boolean debugFlag = false; static final boolean internalErrors = false; - + void debugPrint(String message) { if (debugFlag) System.out.println(message); } - + void debugPrintln(String message) { if (debugFlag) System.out.println(message); @@ -93,7 +93,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { /* * new fields in extended class - */ + */ protected float deviceGain = 1.0f; protected static final int NOT_PAUSED = 0; @@ -106,7 +106,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { * Construct a new JavaSoundMixer with the specified P.E. * @param physicalEnvironment the physical environment object where we * want access to this device. - */ + */ public JavaSoundMixer(PhysicalEnvironment physicalEnvironment ) { super(physicalEnvironment); thread = new JSThread(Thread.currentThread().getThreadGroup(), this); @@ -117,17 +117,17 @@ public class JavaSoundMixer extends AudioEngine3DL2 { * for this audio device. * Overridden method from AudioEngine. * @return number of maximum voices play simultaneously on JavaSound Mixer. - */ + */ public int getTotalChannels() { if (thread != null) return thread.getTotalChannels(); else return 32; } - + /** * Code to initialize the device - * New interface to mixer/engine specific methods + * New interface to mixer/engine specific methods * @return flag: true is initialized sucessfully, false if error */ public boolean initialize() { @@ -144,7 +144,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { /** * Code to close the device. - * New interface to mixer/engine specific methods + * New interface to mixer/engine specific methods * @return flag: true is closed sucessfully, false if error */ public boolean close() { @@ -243,7 +243,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { sample.setSoundData(soundData); } } - + if (debugFlag) { debugPrint(" prepareSound type = "+soundType); debugPrintln("JavaSoundMixer.prepareSound returned "+index); @@ -254,7 +254,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { /** * Clears the fields associated with sample data for this sound. * Overriden method from AudioEngine3D. - */ + */ public void clearSound(int index) { // TODO: call JSXXXX clear method JSSample sample = null; @@ -329,9 +329,9 @@ public class JavaSoundMixer extends AudioEngine3DL2 { return; } - /* + /* * Overriden method from AudioEngine3D. - */ + */ public void setDirection(int index, Vector3d direction) { if (debugFlag) debugPrintln("JavaSoundMixer: setDirection for index " + index); @@ -345,28 +345,28 @@ public class JavaSoundMixer extends AudioEngine3DL2 { } return; } - - /* + + /* * Overriden method from AudioEngine3D. - */ + */ public void setReflectionCoefficient(float coefficient) { super.setReflectionCoefficient(coefficient); auralParams.reverbDirty |= JSAuralParameters.REFLECTION_COEFF_CHANGED; return; } - /* + /* * Overriden method from AudioEngine3D. - */ + */ public void setReverbDelay(float reverbDelay) { super.setReverbDelay(reverbDelay); auralParams.reverbDirty |= JSAuralParameters.REVERB_DELAY_CHANGED; return; } - /* + /* * Overriden method from AudioEngine3D. - */ + */ public void setReverbOrder(int reverbOrder) { super.setReverbOrder(reverbOrder); auralParams.reverbDirty |= JSAuralParameters.REVERB_ORDER_CHANGED; @@ -379,7 +379,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { * Point and Cone sounds?? * * For now background sounds are not reverberated - * + * * Overriden method from AudioEngine3D. */ public int startSample(int index) { @@ -390,7 +390,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { JSSample sample = null; if ( ( (sample = (JSSample)getSample(index)) == null) || - thread == null ) + thread == null ) return JSSample.NULL_SAMPLE; int soundType = sample.getSoundType(); @@ -409,7 +409,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { if (soundType != AudioDevice3D.BACKGROUND_SOUND) setFilter(index, sample.getFilterFlag(), sample.getFilterFreq()); } - + boolean startSuccessful; startSuccessful = thread.startSample(sample); @@ -417,7 +417,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { if (!startSuccessful) { if (internalErrors) - debugPrintln( + debugPrintln( "JavaSoundMixer: Internal Error startSample for index " + index + " failed"); return JSSample.NULL_SAMPLE; @@ -426,7 +426,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { if (debugFlag) debugPrintln(" startSample worked, " + "returning " + startSuccessful); - // NOTE: Set AuralParameters AFTER sound started + // NOTE: Set AuralParameters AFTER sound started // Setting AuralParameters before you start sound doesn't work if (!muted) { if (auralParams.reverbDirty > 0) { @@ -448,10 +448,10 @@ public class JavaSoundMixer extends AudioEngine3DL2 { return index; } } - - /* + + /* * Overriden method from AudioEngine3D. - */ + */ public int stopSample(int index) { // TODO: Rewrite this function @@ -485,9 +485,9 @@ public class JavaSoundMixer extends AudioEngine3DL2 { } } - /* + /* * Overriden method from AudioEngine3D. - */ + */ public void pauseSample(int index) { if (debugFlag) debugPrintln("JavaSoundMixer: PAUSESample for index " + index); @@ -498,9 +498,9 @@ public class JavaSoundMixer extends AudioEngine3DL2 { thread.pauseSample(sample); } - /* + /* * Overriden method from AudioEngine3D. - */ + */ public void unpauseSample(int index) { if (debugFlag) debugPrintln("JavaSoundMixer: UNPAUSESample for index " + index); @@ -510,17 +510,17 @@ public class JavaSoundMixer extends AudioEngine3DL2 { thread.unpauseSample(sample); } - /* + /* * Force thread to update sample. * Overriden method from AudioEngine3D. - */ + */ public void updateSample(int index) { if (debugFlag) debugPrintln("JavaSoundMixer: UPDATESample for index " + index); JSSample sample = null; if ( ( (sample = (JSSample)getSample(index)) == null) || - thread == null ) + thread == null ) return; int soundType = sample.getSoundType(); @@ -550,9 +550,9 @@ public class JavaSoundMixer extends AudioEngine3DL2 { setReverb(sample); // ensure reverb is current/correct // TODO: For now sum left & rightGains for reverb gain - float reverbGain = 0.0f; - if (!muted && auralParams.reverbFlag) { - reverbGain = sample.getGain() * auralParams.reflectionCoefficient; + float reverbGain = 0.0f; + if (!muted && auralParams.reverbFlag) { + reverbGain = sample.getGain() * auralParams.reflectionCoefficient; } sample.render(sample.getDirtyFlags(), getView(), auralParams); @@ -567,9 +567,9 @@ public class JavaSoundMixer extends AudioEngine3DL2 { return; } - /* + /* * Overriden method from AudioEngine3D. - */ + */ public void muteSample(int index) { JSSample sample = null; if ((sample = (JSSample)getSample(index)) == null) @@ -582,9 +582,9 @@ public class JavaSoundMixer extends AudioEngine3DL2 { return; } - /* + /* * Overriden method from AudioEngine3D. - */ + */ public void unmuteSample(int index) { JSSample sample = null; if ((sample = (JSSample)getSample(index)) == null) @@ -606,9 +606,9 @@ public class JavaSoundMixer extends AudioEngine3DL2 { return; } - /* + /* * Overriden method from AudioEngine3D. - */ + */ public long getSampleDuration(int index) { JSSample sample = null; if ((sample = (JSSample)getSample(index)) == null) @@ -624,24 +624,24 @@ public class JavaSoundMixer extends AudioEngine3DL2 { return duration; } - /* + /* * Overriden method from AudioEngine3D. - */ + */ public int getNumberOfChannelsUsed(int index) { /* * Calls same method with different signature containing the * sample's mute flag passed as the 2nd parameter. - */ + */ JSSample sample = null; if ((sample = (JSSample)getSample(index)) == null) return 0; - else + else return getNumberOfChannelsUsed(index, sample.getMuteFlag()); } /** * Overriden method from AudioEngine3D. - */ + */ public int getNumberOfChannelsUsed(int index, boolean muted) { /* * The JavaSoundMixer implementation uses THREE channels to render @@ -653,7 +653,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { * * TODO: When muted is implemented, that flag should be check * so that zero is returned. - */ + */ JSSample sample = null; if ((sample = (JSSample)getSample(index)) == null) return 0; @@ -672,9 +672,9 @@ public class JavaSoundMixer extends AudioEngine3DL2 { return 3; } - /* + /* * Overriden method from AudioEngine3D. - */ + */ public long getStartTime(int index) { JSSample sample = null; if ((sample = (JSSample)getSample(index)) == null) @@ -752,9 +752,9 @@ public class JavaSoundMixer extends AudioEngine3DL2 { * Remember Coeff change is choosen over Order change if BOTH made * otherwise the last one changed take precidence. */ - if (auralParams.reflectionCoefficient == 0.0f || + if (auralParams.reflectionCoefficient == 0.0f || auralParams.reverbCoefficient == 0.0f) - auralParams.reverbFlag = false; + auralParams.reverbFlag = false; else { auralParams.reverbFlag = true; if (order > 0) { @@ -787,7 +787,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { } if (debugFlag) - debugPrintln("JavaSoundMixer: setReverb for " + + debugPrintln("JavaSoundMixer: setReverb for " + sample + ", type = " + auralParams.reverbType + ", flag = " + auralParams.reverbFlag); auralParams.reverbDirty = 0; // clear the attribute reverb dirty flags @@ -804,7 +804,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { */ int soundType = sample.getSoundType(); int dataType = sample.getDataType(); - + // QUESTION: Should reverb be applied to background sounds? if ( (soundType == AudioDevice3D.CONE_SOUND) || (soundType == AudioDevice3D.POINT_SOUND) ) { @@ -814,7 +814,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { if (sample == null) return; JSPositionalSample posSample = (JSPositionalSample)sample; - if (posSample.channel == null) + if (posSample.channel == null) return; /********** @@ -831,9 +831,9 @@ public class JavaSoundMixer extends AudioEngine3DL2 { } /********** // TODO: - else if (dataType == JSSample.STREAMING_MIDI_DATA || + else if (dataType == JSSample.STREAMING_MIDI_DATA || dataType == JSSample.BUFFERED_MIDI_DATA) { - JSMidi.setSampleReverb(reverbIndex, + JSMidi.setSampleReverb(reverbIndex, auralParams.reverbType, auralParams.reverbFlag); } **********/ @@ -847,11 +847,11 @@ public class JavaSoundMixer extends AudioEngine3DL2 { // TEMPORARY: Override of method due to bug in Java Sound public void setLoop(int index, int count) { - JSSample sample = null; - if ((sample = (JSSample)getSample(index)) == null) + JSSample sample = null; + if ((sample = (JSSample)getSample(index)) == null) return; int dataType = sample.getDataType(); - + // WORKAROUND: // Bug in Java Sound engine hangs when INFINITE_LOOP count // for Audio Wave data. Leave count unchanged for Midi data. @@ -873,9 +873,9 @@ public class JavaSoundMixer extends AudioEngine3DL2 { // TODO: remove assumption from method void setFilter(int index, boolean filterFlag, float filterFreq) { JSPositionalSample posSample = null; - if ((posSample = (JSPositionalSample)getSample(index)) == null) + if ((posSample = (JSPositionalSample)getSample(index)) == null) return; - if (posSample.channel == null) + if (posSample.channel == null) return; int dataType = posSample.getDataType(); @@ -926,7 +926,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { /* * Set sample specific sample rate scale factor gain * @since Java 3D 1.3 - */ + */ public void setRateScaleFactor(int index, float rateScaleFactor) { JSSample sample = null; if ((sample = (JSSample)getSample(index)) == null) @@ -940,7 +940,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { * threads. * Causes all cached sounds to be paused and all streaming sounds to be * stopped. - */ + */ public void pause() { pause = PAUSE_PENDING; // TODO: pause all sounds @@ -950,7 +950,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { * Resumes audio device engine (if previously paused) without reinitializing * the device. * Causes all paused cached sounds to be resumed and all streaming sounds * restarted. - */ + */ public void resume() { pause = RESUME_PENDING; // TODO: unpause all sounds |