|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
UltrasoundAnalyzer
The UltrasoundAnalyzer thread class takes an array of bytes, concatenates them into 16-bit values in little endian format, then creates an UltrasoundDetector object to decide whether or not the samples contain the desired frequency. The boolean decision as to whether or not ultrasound was present in the block of samples is sent back to the UltrasoundListener object that instantiated this thread.
UltrasoundAnalyzer is a continuously running thread. As long as the available() method indicates that the thread is ready to receive data, analysis begins by calling the analyze() method with the array of bytes to be analyzed. Once the analysis is complete, this thread signals the UltrasoundListener object and becomes available for another set of data.
Field Summary | |
protected boolean |
analyzing
|
protected byte[] |
byteSamples
|
protected int |
CHANNELS
|
protected UltrasoundDetector |
usd
|
protected UltrasoundListener |
usl
|
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Fields inherited from interface Constants |
AVG_DETECT_TIME, BIGEND, DEBOUNCE_VAL, GROUPADDR, HISTORY_SIZE, MAX_DETECT_TIME, MAXMSGSIZE, N, NUMTHREADS, PORTNUM, ROOM_MSG_BUF, SAMPLE_SIZE, SAMPLING_RATE, SEQUENCE, SIGN, TARGET_FREQUENCY, WEIGHT |
Constructor Summary | |
UltrasoundAnalyzer(UltrasoundListener usListener,
boolean inDebug,
int channels)
The main UltrasoundAnalyzer constructor takes a reference to an UltrasoundListener and a byte array containing the samples to be analyzed. |
Method Summary | |
boolean |
analyze(byte[] samples)
Begin DSP analysis of data in order to determine whether or not ultrasound is present in the set of audio samples. |
boolean |
available()
Returns a boolean indicating whether or not this thread object is available to begin analysis of a new data set. |
protected double[] |
littleEndConcat()
Helper method for concatenating all the values in a byte array into 16-bit double values using the little endian format. |
void |
run()
The UltrasoundAnalyzer thread first concatenates the array of bytes into 16-bit little endian samples, then uses the UltrasoundDetector to determine whether or not the samples contain ultrasound and notifies the UltrasoundListener accordingly. |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, 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 |
protected UltrasoundListener usl
protected UltrasoundDetector usd
protected byte[] byteSamples
protected volatile boolean analyzing
protected int CHANNELS
Constructor Detail |
public UltrasoundAnalyzer(UltrasoundListener usListener, boolean inDebug, int channels)
usListener
- The object that will be notified of
ultrasound detections.inDebug
- Whether or not to print debugging information.channels
- The number of channels on which the audio was
recorded.Method Detail |
public void run()
run
in interface java.lang.Runnable
public boolean available()
public boolean analyze(byte[] samples)
samples
- The byte array of audio data to be analyzed for
ultrasound
protected double[] littleEndConcat()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |