|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectUltrasoundDetector
The UltrasoundDetector class can be used to help analyze an ultrasound signal. UltrasoundDetector creates three Goertzel objects in order to determine whether or not the desired frequency is present in a set of data. One Goertzel object performs the Goertzel algorithm with the target frequency, obtaining a relative magnitude for this frequency, while the other two Goertzel objects perform the Goertzel algorithm with frequencies slightly above and slightly below the target frequency. The relative magnitude returned by the target frequency is compared to the relative magnitudes returned by the other two frequencies. If the magnitude of the target frequency is more than twice the average of the other two magnitudes, the UltrasoundDetector class decides that ultrasound has been detected.
After it is constructed with the desired parameters, an UltrasoundDetector must be initialized with the init method. After initialization, the analyze method can be called to determine whether the target frequency is present in a block of N data samples.
This class is based on a C program implemented by Kevin Banks of Embedded Systems Programming.
Field Summary | |
protected boolean |
debug
|
protected Goertzel |
g
|
protected Goertzel |
gless
|
protected Goertzel |
gmore
|
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 | |
UltrasoundDetector()
Default Constructor |
|
UltrasoundDetector(float sampleRate,
float targetFreq,
int inN,
boolean inDebug)
Constructor. |
Method Summary | |
boolean |
analyze(double[] block)
This is the main method of the UltrasoundDetector class and it is used for testing N samples for the presence of the frequency specified by TARGET_FREQUENCY. |
int |
getN()
Provide means to access the value of N that is used by the Goertzel algorithm to detect the presence of a specified frequency. |
void |
init()
Method to initialize the Goertzel algorithm. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected boolean debug
protected Goertzel g
protected Goertzel gless
protected Goertzel gmore
Constructor Detail |
public UltrasoundDetector()
public UltrasoundDetector(float sampleRate, float targetFreq, int inN, boolean inDebug)
sampleRate
- is the sampling rate of the signal to be analyzedtargetFreq
- is the frequency that Goertzel will look for.inN
- is the block size to use with GoertzelinDebug
- indicates whether or not to turn debugging info on.Method Detail |
public void init()
public int getN()
public boolean analyze(double[] block)
block
- An array of type double containing the N samples.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |