public class SampleThread extends AbstractFilter
Modifier and Type | Class and Description |
---|---|
private class |
SampleThread.Runner
Separate thread to continuously update the buffer with most recent sensors
data at fixed interval.
|
Modifier and Type | Field and Description |
---|---|
(package private) float[] |
buffer |
(package private) int |
interval |
(package private) boolean |
newSampleAvailable |
(package private) boolean |
running |
private float |
sampleRate |
sampleSize, source
Constructor and Description |
---|
SampleThread(SampleProvider source,
float sampleRate)
Create an instance and run at
sampleRate . |
Modifier and Type | Method and Description |
---|---|
void |
fetchSample(float[] dst,
int off)
Fetches a sample from a sensors or filter.
|
float |
getSampleRate() |
boolean |
isNewSampleAvailable() |
void |
setSampleRate(float rate) |
void |
start()
Start the sampling (Default at instantiation)
|
void |
stop()
Stop the sampling
|
sampleSize
float[] buffer
boolean running
private float sampleRate
int interval
boolean newSampleAvailable
public SampleThread(SampleProvider source, float sampleRate)
sampleRate
.source
- A SampleProvidersampleRate
- The sample rate expressed in Hertz (Samples / second)public boolean isNewSampleAvailable()
public void fetchSample(float[] dst, int off)
SampleProvider
fetchSample
in interface SampleProvider
fetchSample
in class AbstractFilter
dst
- The array to store the sample in.off
- The elements of the sample are stored in the array starting at the offset position.public float getSampleRate()
public void setSampleRate(float rate)
rate
- in Hzpublic void start()
public void stop()