com.sun.j3d.audioengines.javasound
Class JSThread

java.lang.Object
  extended by java.lang.Thread
      extended by com.sun.j3d.audioengines.AudioEngineThread
          extended by com.sun.j3d.audioengines.javasound.JSThread
All Implemented Interfaces:
java.lang.Runnable

 class JSThread
extends AudioEngineThread

The Thread Class extended for JavaSound Mixer specific audio device calls that dynamically, in 'real-time" change engine parameters such as volume/gain and sample-rate/frequency(pitch).


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
(package private)  AudioEngine3D audioEngine
          TODO: scalefactors applied to current sample rate to determine delta changes in rate (in Hz) float currentGain = 1.0f; float targetGain = 1.0f;
(package private)  boolean rampGain
          flags denoting if dynamic gain or rate interpolation is to be performed
(package private)  boolean rampRate
           
(package private)  int totalChannels
          The thread data for this thread
 
Fields inherited from class com.sun.j3d.audioengines.AudioEngineThread
active, args, classification, debugFlag, instanceNum, lastWaitTimestamp, NOTIFY_AND_WAIT, numInstances, referenceTime, RUN, running, started, STOP, type, UPDATE_THREAD, userStop, WAIT, waiting, WORK_THREAD
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
JSThread(java.lang.ThreadGroup t, AudioEngine3DL2 engine)
          This constructor simply assigns the given id.
 
Method Summary
(package private)  boolean adjustRate(JSSample sample)
          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.
 void cleanup()
           
(package private)  boolean close()
          Code to close the device
 void doWork()
          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.
(package private)  int getTotalChannels()
           
 void initialize()
          This initializes this thread.
(package private)  void muteSample(JSSample sample)
           
(package private)  void pauseSample(JSSample sample)
           
(package private)  void setRate(JSSample sample, float rateScaleFactor)
           
(package private)  void setSampleDelay(JSSample sample, JSAuralParameters attribs)
           
(package private)  void setSampleGain(JSSample sample, float gain)
           
(package private)  void setSampleGain(JSSample sample, JSAuralParameters attribs)
           
(package private)  void setSampleRate(JSSample sample, float scaleFactor)
           
(package private)  void setSampleRate(JSSample sample, JSAuralParameters attribs)
           
(package private)  void setTargetGain(JSSample sample, float scaleFactor)
           
(package private)  void setTargetRate(JSSample sample, float rateScaleFactor)
           
 void shutdown()
           
(package private)  int startClip()
           
(package private)  int startClips()
           
(package private)  boolean startSample(JSSample sample)
           
(package private)  int startStream()
           
(package private)  int startStreams()
           
(package private)  boolean stopSample(JSSample sample)
           
(package private)  void unmuteSample(JSSample sample)
           
(package private)  void unpauseSample(JSSample sample)
           
 
Methods inherited from class com.sun.j3d.audioengines.AudioEngineThread
debugPrint, finish, run, runMonitor
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

totalChannels

int totalChannels
The thread data for this thread


rampGain

boolean rampGain
flags denoting if dynamic gain or rate interpolation is to be performed


rampRate

boolean rampRate

audioEngine

AudioEngine3D audioEngine
TODO: scalefactors applied to current sample rate to determine delta changes in rate (in Hz) float currentGain = 1.0f; float targetGain = 1.0f;

Constructor Detail

JSThread

JSThread(java.lang.ThreadGroup t,
         AudioEngine3DL2 engine)
This constructor simply assigns the given id.

Method Detail

doWork

public void doWork()
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 increment/decrement changes in rate (and other future parameters) until the target value is reached.

Overrides:
doWork in class AudioEngineThread

getTotalChannels

int getTotalChannels()

adjustRate

boolean adjustRate(JSSample sample)
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 "max" rate of change is different for both.

Returns:
true if target rate value was reached

setSampleRate

void setSampleRate(JSSample sample,
                   JSAuralParameters attribs)

setSampleGain

void setSampleGain(JSSample sample,
                   JSAuralParameters attribs)

setSampleDelay

void setSampleDelay(JSSample sample,
                    JSAuralParameters attribs)

setTargetGain

void setTargetGain(JSSample sample,
                   float scaleFactor)

setRate

void setRate(JSSample sample,
             float rateScaleFactor)

setTargetRate

void setTargetRate(JSSample sample,
                   float rateScaleFactor)

setSampleGain

void setSampleGain(JSSample sample,
                   float gain)

setSampleRate

void setSampleRate(JSSample sample,
                   float scaleFactor)

startSample

boolean startSample(JSSample sample)

stopSample

boolean stopSample(JSSample sample)

pauseSample

void pauseSample(JSSample sample)

unpauseSample

void unpauseSample(JSSample sample)

muteSample

void muteSample(JSSample sample)

unmuteSample

void unmuteSample(JSSample sample)

startStreams

int startStreams()

startStream

int startStream()

startClips

int startClips()

startClip

int startClip()

initialize

public void initialize()
This initializes this thread. Once this method returns, the thread is ready to do work.

Overrides:
initialize in class AudioEngineThread

close

boolean close()
Code to close the device

Returns:
flag: true is closed sucessfully, false if error

shutdown

public void shutdown()
Overrides:
shutdown in class AudioEngineThread

cleanup

public void cleanup()
Overrides:
cleanup in class AudioEngineThread


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