com.webkitchen.eeg.analysis
Class RatioMonitor

java.lang.Object
  extended by com.webkitchen.eeg.analysis.RatioMonitor
All Implemented Interfaces:
IDualAmplitudeGenerator, IDualBandSampleListener, IRatioGenerator, java.util.EventListener

public class RatioMonitor
extends java.lang.Object
implements IDualBandSampleListener, IRatioGenerator, IDualAmplitudeGenerator

Listens for samples in two given bands, calculates the amplitude averages for each and the ratio between the two, then notifies listeners of the ratio. Objects can add themselves as listeners/observers to receive copies of all new amplitude ratios.


Constructor Summary
RatioMonitor(int sampleSize, double tolerance, int minNotificationInterval)
          Creates a new monitor that will calculate the ratio between the amplitude values of two filtered signals
 
Method Summary
 void addAmplitudeListener(IDualAmplitudeListener listener)
          Attach listener to receive notification/copies of new amplitude levels for two different frequency bands
 void addRatioListener(IRatioListener listener)
          Attach listener to receive notification of the player's ratio of 2 wave bands
 void receiveBand(double sample1, double sample2)
          Processes the samples to calculate the current amplitude ratio, and notifies all listeners if the difference between the new ratio and last sent ratio 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 removeAllRatioListeners()
          Remove all listeners from our notification list
 void removeAmplitudeListener(IDualAmplitudeListener listener)
          Remove listener from our notification list
 void removeRatioListener(IRatioListener 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

RatioMonitor

public RatioMonitor(int sampleSize,
                    double tolerance,
                    int minNotificationInterval)
Creates a new monitor that will calculate the ratio between the amplitude values of two filtered signals

Parameters:
sampleSize - the number of samples to use in our RMS calculation
tolerance - the amount of change in ratio 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 sample1,
                        double sample2)
Processes the samples to calculate the current amplitude ratio, and notifies all listeners if the difference between the new ratio and last sent ratio is greater than our tolerance amount, or if the number of processed values has reached our minNotificationInterval

Specified by:
receiveBand in interface IDualBandSampleListener
Parameters:
sample1 - one filtered sample
sample2 - the other filtered sample

addRatioListener

public void addRatioListener(IRatioListener listener)
Attach listener to receive notification of the player's ratio of 2 wave bands

Specified by:
addRatioListener in interface IRatioGenerator
Parameters:
listener - the observer who wants to receive the player's ratio of 2 wave bands

removeRatioListener

public void removeRatioListener(IRatioListener listener)
Remove listener from our notification list

Specified by:
removeRatioListener in interface IRatioGenerator
Parameters:
listener - the observer to remove

removeAllRatioListeners

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

Specified by:
removeAllRatioListeners in interface IRatioGenerator

addAmplitudeListener

public void addAmplitudeListener(IDualAmplitudeListener listener)
Attach listener to receive notification/copies of new amplitude levels for two different frequency bands

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

removeAmplitudeListener

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

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

removeAllAmplitudeListeners

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

Specified by:
removeAllAmplitudeListeners in interface IDualAmplitudeGenerator