ESP OpenBCI - An EEG Signal Processing Library for OpenBCI Hardware

com.github.mrstampy.esp.multiconnectionsocket
Class RawDataSampleBuffer<SAMPLE>

java.lang.Object
  extended by com.github.mrstampy.esp.multiconnectionsocket.RawDataSampleBuffer<SAMPLE>
Type Parameters:
SAMPLE - the generic type
All Implemented Interfaces:
ConnectionEventListener, java.util.EventListener
Direct Known Subclasses:
SampleBuffer

public abstract class RawDataSampleBuffer<SAMPLE>
extends java.lang.Object
implements ConnectionEventListener

This class uses Disruptor internally. Add as a ConnectionEventListener to the AbstractMultiConnectionSocket.

Author:
burton

Constructor Summary
protected RawDataSampleBuffer(int bufferSize, int fftSize)
          Instantiates a new raw data sample buffer.
 
Method Summary
abstract  void addSample(SAMPLE sample)
          Adds the sample.
protected  void addSampleImpl(double... sample)
          Adds the sample impl.
 void clear()
          Clear.
 void connectionEventPerformed(ConnectionEvent e)
          Implementation starts/stops disruptor.
 int getBufferSize()
          Gets the buffer size.
 int getFftSize()
          Gets the fft size.
 double[] getSnapshot()
          Gets the snapshot.
 void setBufferSize(int bufferSize)
          Sets the buffer size.
 void setFftSize(int fftSize)
          Sets the fft size.
 void stopTuning()
          Invoked after a period of time after invoking tune().
 void tune()
          When invoked the number of samples will be counted.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RawDataSampleBuffer

protected RawDataSampleBuffer(int bufferSize,
                              int fftSize)
Instantiates a new raw data sample buffer.

Parameters:
bufferSize - the buffer size
fftSize - the fft size
Method Detail

connectionEventPerformed

public void connectionEventPerformed(ConnectionEvent e)
Implementation starts/stops disruptor.

Specified by:
connectionEventPerformed in interface ConnectionEventListener
Parameters:
e - the e

addSample

public abstract void addSample(SAMPLE sample)
Adds the sample.

Parameters:
sample - the sample

addSampleImpl

protected void addSampleImpl(double... sample)
Adds the sample impl.

Parameters:
sample - the sample

getSnapshot

public double[] getSnapshot()
Gets the snapshot.

Returns:
the snapshot

clear

public void clear()
Clear.


tune

public void tune()
When invoked the number of samples will be counted. When stopTuning() is invoked the time taken to process the total number of samples taken during that time will be used to resize the sample buffer.


stopTuning

public void stopTuning()
Invoked after a period of time after invoking tune(). Will resize the queue to represent ~ 1 second's worth of data based upon the total number of samples received during tuning.


getBufferSize

public int getBufferSize()
Gets the buffer size.

Returns:
the buffer size

setBufferSize

public void setBufferSize(int bufferSize)
Sets the buffer size.

Parameters:
bufferSize - the new buffer size

getFftSize

public int getFftSize()
Gets the fft size.

Returns:
the fft size

setFftSize

public void setFftSize(int fftSize)
Sets the fft size.

Parameters:
fftSize - the new fft size

brought to you by Mr. Stampy