com.webkitchen.eeg.analysis
Class BandMonitor

java.lang.Object
  extended by com.webkitchen.eeg.analysis.BandMonitor
All Implemented Interfaces:
IAmplitudeGenerator, IBandSampleListener, java.util.EventListener

public class BandMonitor
extends java.lang.Object
implements IBandSampleListener, IAmplitudeGenerator

Listens for samples in a given band, calculates the amplitude average for the samples, and notifies listeners of the new average amplitude. Objects can add themselves as listeners/observers to receive copies of all new average amplitudes.


Constructor Summary
BandMonitor(int sampleSize, double tolerance, int minNotificationInterval)
          Creates a new monitor that will calculate amplitude values for a filtered signal
 
Method Summary
 void addAmplitudeListener(IAmplitudeListener listener)
          Attach listener to receive notification/copies of new amplitude levels
 void receiveBand(double bandSample)
          Processes the sample to calculate the signal amplitude, and notifies all listeners if the difference between the new amplitude and last sent amplitude is greater than our tolerance amount, or if the number of processed values has reached our minNotificationInterval
 void removeAllAmplitudeListeners()
          Remove all listeners from our notification list
 void removeAmplitudeListener(IAmplitudeListener listener)
          Remove listener from our notification list
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BandMonitor

public BandMonitor(int sampleSize,
                   double tolerance,
                   int minNotificationInterval)
Creates a new monitor that will calculate amplitude values for a filtered signal

Parameters:
sampleSize - the number of samples to use in our RMS calculation
tolerance - the amount of change in amplitude required before notifying listeners
minNotificationInterval - the minimum interval for notifying listeners, even if amplitude has not changed beyond tolerance amount
Method Detail

receiveBand

public void receiveBand(double bandSample)
Processes the sample to calculate the signal amplitude, and notifies all listeners if the difference between the new amplitude and last sent amplitude is greater than our tolerance amount, or if the number of processed values has reached our minNotificationInterval

Specified by:
receiveBand in interface IBandSampleListener
Parameters:
bandSample - the filtered sample value

addAmplitudeListener

public void addAmplitudeListener(IAmplitudeListener listener)
Attach listener to receive notification/copies of new amplitude levels

Specified by:
addAmplitudeListener in interface IAmplitudeGenerator
Parameters:
listener - the observer who wants to receive amplitude levels

removeAmplitudeListener

public void removeAmplitudeListener(IAmplitudeListener listener)
Remove listener from our notification list

Specified by:
removeAmplitudeListener in interface IAmplitudeGenerator
Parameters:
listener - the observer to remove

removeAllAmplitudeListeners

public void removeAllAmplitudeListeners()
Remove all listeners from our notification list

Specified by:
removeAllAmplitudeListeners in interface IAmplitudeGenerator