|
The Physiologist's Friend Simulation API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
ch.unizh.ini.friend.record.MicrophoneReporter
public class MicrophoneReporter
Uses the microphone input to detect and generate SpikeEvent
's.
This object is a thread that reads the microphone input and generates spikes from it.
To use this class, make a new instance, register SpikeListener
's,
and startReporting()
the thread. To stop reporting, use stopReporting()
.
An instance of this class is constructed by
FriendGUI
when microphone recording is activated; listeners are added there.
A spike is positive edge triggered by the microphone input going above the setThreshold(byte)
;
a new spike is not generated until the input falls below the threshold-hystersis level
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
Thread.State, Thread.UncaughtExceptionHandler |
Field Summary |
---|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
MicrophoneReporter()
Creates a new instance of SpikeTest. |
|
MicrophoneReporter(SimulationSetup setup)
|
Method Summary | |
---|---|
void |
addSpikeListener(SpikeListener listener)
add a listener for all spikes. |
void |
clearSpikeListeners()
remove all listeners |
void |
compute(float dt)
Computes the new state of this component of the simulation. |
protected void |
finalize()
Release the line on finialization. |
byte |
getHystersis()
|
Collection |
getSpikeListeners()
|
byte |
getThreshold()
|
boolean |
isReporting()
|
static void |
main(String[] args)
test class by just printing . when it gets spikes |
void |
removeSpikeListener(SpikeListener listener)
removes a listener |
void |
run()
grabs samples from microphone input and generates SpikeEvent 's whenver spikes are detected. |
void |
setHystersis(byte h)
sets the hystersis for spike detection. |
void |
setThreshold(byte t)
sets the threshold for detecting spikes. |
void |
startReporting()
starts acquisition from microphone port and generation of SpikeEvent 's. |
void |
stopReporting()
removes all spike event listeners, ends thread after first stopping microphone acquisition. |
void |
update()
Updates the actual state to the newly computed - aka double-buffering. |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public MicrophoneReporter(SimulationSetup setup) throws LineUnavailableException
setup
- we are added to the setup as an updateable, but our update method does nothing
LineUnavailableException
- if microphone input not availableMicrophoneReporter()
public MicrophoneReporter() throws LineUnavailableException
Thread.start()
the thread.
LineUnavailableException
- if microphone input is not availableMethod Detail |
---|
public void setThreshold(byte t)
t
- the threshold.public byte getThreshold()
setThreshold(byte)
public void setHystersis(byte h)
SpikeEvent
can be not generated until the input drops below the threshold
-hystersis.
public byte getHystersis()
setHystersis(byte)
public void startReporting()
SpikeEvent
's. If line is not available it does nothing.
startReporting
in interface SpikeReporter
public void stopReporting()
SpikeEvent
's
stopReporting
in interface SpikeReporter
public void run()
SpikeEvent
's whenver spikes are detected.
Stopped by stopReporting()
run
in interface Runnable
run
in class Thread
protected void finalize() throws Throwable
finalize
in class Object
Throwable
public void addSpikeListener(SpikeListener listener)
called
when a spike occurs and are passed a SpikeEvent
.
addSpikeListener
in interface SpikeEventSource
listener
- the listenerpublic void removeSpikeListener(SpikeListener listener)
removeSpikeListener
in interface SpikeEventSource
listener
- to removepublic void clearSpikeListeners()
clearSpikeListeners
in interface SpikeEventSource
public static void main(String[] args)
public Collection getSpikeListeners()
getSpikeListeners
in interface SpikeEventSource
public boolean isReporting()
isReporting
in interface SpikeReporter
Thread.isAlive()
)public void compute(float dt)
compute
in interface Updateable
dt
- The time that has passed since the last invocation.public void update()
update
in interface Updateable
|
http://www.ini.unizh.ch/~tobi/friend | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |