Open Ephys GUI
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Classes | Public Types | Public Member Functions | Public Attributes
GenericProcessor Class Reference

Abstract base class for creating processors. More...

#include <GenericProcessor.h>

Inheritance diagram for GenericProcessor:
AccessClass ArduinoOutput AudioNode AudioResamplingNode EventDetector EventNode ExampleProcessor FilterNode FPGAOutput LfpDisplayNode Merger PhaseDetector RecordControl RecordNode ReferenceNode ResamplingNode SignalGenerator SourceNode SpikeDetector SpikeDisplayNode Splitter WiFiOutput

List of all members.

Classes

struct  ProcessorSettings
 Settings used by most processors. More...

Public Types

enum  eventTypes {
  TIMESTAMP = 0, BUFFER_SIZE = 1, PARAMETER_CHANGE = 2, TTL = 3,
  SPIKE = 4, EEG = 5, CONTINUOUS = 6
}
enum  eventChannelTypes { GENERIC_EVENT = 999, SINGLE_ELECTRODE = 1, STEREOTRODE = 2, TETRODE = 4 }

Public Member Functions

 GenericProcessor (const String &name_)
 Constructor (sets the processor's name).
virtual ~GenericProcessor ()
 Destructor.
const String getName () const
 Returns the name of the processor.
virtual void prepareToPlay (double sampleRate, int estimatedSamplesPerBlock)
 Called by JUCE as soon as a processor is created, as well as before the start of audio callbacks.
void releaseResources ()
 Called by JUCE as soon as audio callbacks end.
virtual void setParameter (int parameterIndex, float newValue)
 Allows parameters to change while acquisition is active.
virtual AudioProcessorEditor * createEditor ()
 Creates a GenericEditor.
bool hasEditor () const
 The default is to have no editor.
void reset ()
 JUCE method.
void setCurrentProgramStateInformation (const void *data, int sizeInBytes)
 JUCE method.
void setStateInformation (const void *data, int sizeInBytes)
 JUCE method.
void getCurrentProgramStateInformation (MemoryBlock &destData)
 JUCE method.
void getStateInformation (MemoryBlock &destData)
 JUCE method.
void changeProgramName (int index, const String &newName)
 JUCE method.
void setCurrentProgram (int index)
 JUCE method.
const String getInputChannelName (int channelIndex) const
 Returns the name of the input channel with a given index.
const String getOutputChannelName (int channelIndex) const
 Returns the name of the output channel with a given index.
const String getParameterName (int parameterIndex)
 Returns the name of the parameter with a given index.
const String getParameterText (int parameterIndex)
 Returns additional details about the parameter with a given index.
float getParameter (int parameterIndex)
 Returns the current value of a parameter with a given index.
const String getProgramName (int index)
 JUCE method.
bool isInputChannelStereoPair (int index) const
 JUCE method.
bool isOutputChannelStereoPair (int index) const
 JUCE method.
bool acceptsMidi () const
 All processors can accept MIDI (event) data by default.
bool producesMidi () const
 All processors can produce MIDI (event) data by default.
bool isParameterAutomatable (int parameterIndex)
 JUCE method.
bool isMetaParameter (int parameterIndex)
 JUCE method.
int getNumParameters ()
 Returns the number of user-editable parameters for this processor.
int getNumPrograms ()
 JUCE method.
int getCurrentProgram ()
 JUCE method.
virtual void process (AudioSampleBuffer &continuousBuffer, MidiBuffer &eventBuffer, int &nSamples)=0
 Defines a processor's functionality.
virtual float getSampleRate ()
 Returns the sample rate for a processor (assumes the same rate for all channels).
virtual float getDefaultSampleRate ()
 Returns the default sample rate, in case a processor has no source (or is itself a source).
virtual int getNumInputs ()
 Returns the number of inputs to a processor.
virtual int getNumOutputs ()
 Returns the number of outputs from a processor.
virtual int getDefaultNumOutputs ()
 Returns the default number of outputs, in case a processor has no source (or is itself a source).
virtual float getDefaultBitVolts ()
 Returns the default number of volts per bit, in case a processor has no source (or is itself a source).
virtual int getNextChannel (bool t)
 Returns the next available channel (and increments the channel if the input is set to 'true'.
virtual void resetConnections ()
 Resets all inter-processor connections prior to the start of data acquisition.
virtual void setCurrentChannel (int chan)
 Sets the current channel (for purposes of updating parameter).
int getNodeId ()
 Returns the unique integer ID for a processor.
void setNodeId (int id)
 Sets the unique integer ID for a processor.
GenericProcessorgetSourceNode ()
 Returns a pointer to the processor immediately preceding a given processor in the signal chain.
GenericProcessorgetDestNode ()
 Returns a pointer to the processor immediately following a given processor in the signal chain.
virtual void switchIO (int)
 Sets the input or output of a splitter or merger.
virtual void switchIO ()
 Switches the input or output of a splitter or merger.
virtual void setPathToProcessor (GenericProcessor *p)
 Sets the input to a merger a given processor.
virtual void setSourceNode (GenericProcessor *sn)
 Sets a processor's source node.
virtual void setDestNode (GenericProcessor *dn)
 Sets a processor's destination node.
virtual void setMergerSourceNode (GenericProcessor *sn)
 Sets one of two possible source nodes for a merger.
virtual void setSplitterDestNode (GenericProcessor *dn)
 Sets one of two possible source nodes for a splitter.
virtual bool isSource ()
 Returns true if a processor is a source, false otherwise.
virtual bool isSink ()
 Returns true if a processor is a sink, false otherwise.
virtual bool isSplitter ()
 Returns true if a processor is a splitter, false otherwise.
virtual bool isMerger ()
 Returns true if a processor is a merger, false otherwise.
virtual bool canSendSignalTo (GenericProcessor *)
 Returns true if a processor is able to send its output to a given processor.
virtual bool isReady ()
 Returns true if a processor is ready to process data (e.g., all of its parameters are initialized, and its data source is connected).
virtual bool enable ()
 Called immediately prior to the start of data acquisition, once all processors in the signal chain have indicated they are ready to process data.
virtual bool disable ()
 Called immediately after the end of data acquisition.
virtual void enableEditor ()
 Informs a processor's editor that data acquisition is about to begin.
virtual void disableEditor ()
 Informs a processor's editor that data acquisition has ended.
virtual bool enabledState ()
 Indicates whether or not a processor is currently enabled (i.e., able to process data).
virtual void enabledState (bool t)
 Sets whether or not a processor is enabled (i.e., able to process data).
virtual void enableCurrentChannel (bool)
 Turns a given channel on or off.
virtual bool stillHasSource ()
 Indicates whether a source node is connected to a processor (used for mergers).
virtual AudioSampleBuffer * getContinuousBuffer ()
 Returns a pointer to the processor's internal continuous buffer, if it exists.
virtual MidiBuffer * getEventBuffer ()
 Returns a pointer to the processor's internal event buffer, if it exists.
virtual int checkForEvents (MidiBuffer &mb)
 Can be called by processors that need to respond to incoming events.
virtual void addEvent (MidiBuffer &mb, uint8 type, int sampleNum, uint8 eventID=0, uint8 eventChannel=0, uint8 numBytes=0, uint8 *data=0)
 Makes it easier for processors to add events to the MidiBuffer.
virtual void handleEvent (int eventType, MidiMessage &event, int samplePosition=0)
 Makes it easier for processors to respond to incoming events, such as TTLs and spikes.
virtual GenericEditorgetEditor ()
 Returns a pointer to the processor's editor.
virtual void clearSettings ()
 Resets the 'settings' struct to its default state.
virtual void update ()
 Default method for updating settings, called by every processor.
virtual void updateSettings ()
 Custom method for updating settings, called automatically by update().
ParametergetParameterByName (String parameterName)
 Returns the parameter for a given name.
ParametergetParameterReference (int parameterIndex)
 Returns the parameter for a given index.
- Public Member Functions inherited from AccessClass
 AccessClass ()
 ~AccessClass ()
void setUIComponent (UIComponent *)
 Sets the object's UIComponent and copies all the necessary pointers from the UIComponent.
virtual void updateChildComponents ()
 Called within setUIComponent() to enable subclasses to update their members' pointers.
EditorViewportgetEditorViewport ()
 Returns a pointer to the application's EditorViewport.
DataViewportgetDataViewport ()
 Returns a pointer to the application's DataViewport.
ProcessorListgetProcessorList ()
 Returns a pointer to the application's ProcessorList.
ProcessorGraphgetProcessorGraph ()
 Returns a pointer to the application's ProcessorGraph.
ControlPanelgetControlPanel ()
 Returns a pointer to the application's DataViewport.
MessageCentergetMessageCenter ()
 Returns a pointer to the application's MessageCenter.
UIComponentgetUIComponent ()
 Returns a pointer to the application's UIComponent.
AudioComponentgetAudioComponent ()
 Returns a pointer to the application's AudioComponent.

Public Attributes

GenericProcessorsourceNode
 Pointer to a processor's immediate source node.
GenericProcessordestNode
 Pointer to a processor's immediate destination.
bool isEnabled
bool wasConnected
int nextAvailableChannel
int saveOrder
 Variable used to orchestrate saving the ProcessorGraph.
int loadOrder
 Variable used to orchestrate loading the ProcessorGraph.
int currentChannel
 The channel that will be updated the next time a parameter is changed.
ScopedPointer< GenericEditoreditor
 Pointer to the processor's editor.
OwnedArray< Channelchannels
 Array of Channel objects for all continuous channels.
OwnedArray< ChanneleventChannels
 Array of Channel objects for all event channels.
ProcessorSettings settings
int nodeId
 Each processor has a unique integer ID that can be used to identify it.
Array< Parameterparameters
 An array of parameters that the user can modify.

Detailed Description

Abstract base class for creating processors.

All processors must be derived from this class, and must provide an implementation of the process() method.

Any processors that are not filters must override the isSource(), isSink(), isSplitter(), and isMerger() methods.

See https://github.com/open-ephys/GUI/wiki/Custom-processors for information on how to design a processor that inherits from GenericProcessor.

See also:
ProcessorGraph, GenericEditor, SourceNode, FilterNode, LfpDisplayNode

Member Enumeration Documentation

Enumerator:
TIMESTAMP 
BUFFER_SIZE 
PARAMETER_CHANGE 
TTL 
SPIKE 
EEG 
CONTINUOUS 
Enumerator:
GENERIC_EVENT 
SINGLE_ELECTRODE 
STEREOTRODE 
TETRODE 

Constructor & Destructor Documentation

GenericProcessor::GenericProcessor ( const String &  name_)

Constructor (sets the processor's name).

virtual GenericProcessor::~GenericProcessor ( )
virtual

Destructor.


Member Function Documentation

const String GenericProcessor::getName ( ) const

Returns the name of the processor.

virtual void GenericProcessor::prepareToPlay ( double  sampleRate,
int  estimatedSamplesPerBlock 
)
virtual

Called by JUCE as soon as a processor is created, as well as before the start of audio callbacks.

To avoid starting data acquisition prematurely, use the enable() function instead.

Reimplemented in AudioResamplingNode.

void GenericProcessor::releaseResources ( )

Called by JUCE as soon as audio callbacks end.

Use disable() instead.

Reimplemented in AudioResamplingNode.

virtual void GenericProcessor::setParameter ( int  parameterIndex,
float  newValue 
)
virtual

Allows parameters to change while acquisition is active.

If the user wants to change ANY variables that are used within the process() method, this must be done through setParameter(). Otherwise the application will crash.

Reimplemented in ExampleProcessor, AudioNode, RecordNode, SpikeDetector, AudioResamplingNode, SpikeDisplayNode, SourceNode, ArduinoOutput, WiFiOutput, LfpDisplayNode, FPGAOutput, ResamplingNode, PhaseDetector, FilterNode, ReferenceNode, SignalGenerator, and EventDetector.

virtual AudioProcessorEditor* GenericProcessor::createEditor ( )
virtual
bool GenericProcessor::hasEditor ( ) const

The default is to have no editor.

Reimplemented in SourceNode, ResamplingNode, PhaseDetector, SignalGenerator, FilterNode, and ReferenceNode.

void GenericProcessor::reset ( )

JUCE method.

Not used.

void GenericProcessor::setCurrentProgramStateInformation ( const void *  data,
int  sizeInBytes 
)

JUCE method.

Not used.

void GenericProcessor::setStateInformation ( const void *  data,
int  sizeInBytes 
)

JUCE method.

Not used.

void GenericProcessor::getCurrentProgramStateInformation ( MemoryBlock &  destData)

JUCE method.

Not used.

void GenericProcessor::getStateInformation ( MemoryBlock &  destData)

JUCE method.

Not used.

void GenericProcessor::changeProgramName ( int  index,
const String &  newName 
)

JUCE method.

Not used.

void GenericProcessor::setCurrentProgram ( int  index)

JUCE method.

Not used.

const String GenericProcessor::getInputChannelName ( int  channelIndex) const

Returns the name of the input channel with a given index.

const String GenericProcessor::getOutputChannelName ( int  channelIndex) const

Returns the name of the output channel with a given index.

const String GenericProcessor::getParameterName ( int  parameterIndex)

Returns the name of the parameter with a given index.

const String GenericProcessor::getParameterText ( int  parameterIndex)

Returns additional details about the parameter with a given index.

float GenericProcessor::getParameter ( int  parameterIndex)

Returns the current value of a parameter with a given index.

const String GenericProcessor::getProgramName ( int  index)

JUCE method.

Not used.

bool GenericProcessor::isInputChannelStereoPair ( int  index) const

JUCE method.

Not used.

bool GenericProcessor::isOutputChannelStereoPair ( int  index) const

JUCE method.

Not used.

bool GenericProcessor::acceptsMidi ( ) const

All processors can accept MIDI (event) data by default.

bool GenericProcessor::producesMidi ( ) const

All processors can produce MIDI (event) data by default.

bool GenericProcessor::isParameterAutomatable ( int  parameterIndex)

JUCE method.

Not used.

bool GenericProcessor::isMetaParameter ( int  parameterIndex)

JUCE method.

Not used.

int GenericProcessor::getNumParameters ( )

Returns the number of user-editable parameters for this processor.

References parameters.

int GenericProcessor::getNumPrograms ( )

JUCE method.

Not used.

int GenericProcessor::getCurrentProgram ( )

JUCE method.

Not used.

virtual void GenericProcessor::process ( AudioSampleBuffer &  continuousBuffer,
MidiBuffer &  eventBuffer,
int &  nSamples 
)
pure virtual

Defines a processor's functionality.

This is the most important function for each processor, as it determines how it creates, modifies, or responds to incoming data streams. Rather than use the default JUCE processBlock() method, processBlock() automatically calls process() in order to add the 'nSamples' variable to indicate the number of samples in the current buffer.

Implemented in ExampleProcessor, AudioNode, SpikeDetector, AudioResamplingNode, SpikeDisplayNode, RecordNode, SourceNode, WiFiOutput, Splitter, LfpDisplayNode, Merger, ArduinoOutput, FPGAOutput, ResamplingNode, PhaseDetector, FilterNode, ReferenceNode, SignalGenerator, EventDetector, EventNode, and RecordControl.

virtual float GenericProcessor::getSampleRate ( )
virtual

Returns the sample rate for a processor (assumes the same rate for all channels).

Reimplemented in SourceNode, and SignalGenerator.

References GenericProcessor::ProcessorSettings::sampleRate, and settings.

virtual float GenericProcessor::getDefaultSampleRate ( )
virtual

Returns the default sample rate, in case a processor has no source (or is itself a source).

Reimplemented in SourceNode.

virtual int GenericProcessor::getNumInputs ( )
virtual

Returns the number of inputs to a processor.

References GenericProcessor::ProcessorSettings::numInputs, and settings.

virtual int GenericProcessor::getNumOutputs ( )
virtual

Returns the number of outputs from a processor.

References GenericProcessor::ProcessorSettings::numOutputs, and settings.

virtual int GenericProcessor::getDefaultNumOutputs ( )
virtual

Returns the default number of outputs, in case a processor has no source (or is itself a source).

Reimplemented in SignalGenerator, SourceNode, and EventNode.

virtual float GenericProcessor::getDefaultBitVolts ( )
virtual

Returns the default number of volts per bit, in case a processor has no source (or is itself a source).

Reimplemented in SourceNode.

virtual int GenericProcessor::getNextChannel ( bool  t)
virtual

Returns the next available channel (and increments the channel if the input is set to 'true'.

virtual void GenericProcessor::resetConnections ( )
virtual

Resets all inter-processor connections prior to the start of data acquisition.

Reimplemented in RecordNode, and AudioNode.

virtual void GenericProcessor::setCurrentChannel ( int  chan)
virtual

Sets the current channel (for purposes of updating parameter).

References currentChannel.

int GenericProcessor::getNodeId ( )

Returns the unique integer ID for a processor.

References nodeId.

void GenericProcessor::setNodeId ( int  id)

Sets the unique integer ID for a processor.

References nodeId.

GenericProcessor* GenericProcessor::getSourceNode ( )

Returns a pointer to the processor immediately preceding a given processor in the signal chain.

References sourceNode.

GenericProcessor* GenericProcessor::getDestNode ( )

Returns a pointer to the processor immediately following a given processor in the signal chain.

References destNode.

virtual void GenericProcessor::switchIO ( int  )
virtual

Sets the input or output of a splitter or merger.

Reimplemented in Splitter, and Merger.

virtual void GenericProcessor::switchIO ( )
virtual

Switches the input or output of a splitter or merger.

Reimplemented in Splitter, and Merger.

virtual void GenericProcessor::setPathToProcessor ( GenericProcessor p)
virtual

Sets the input to a merger a given processor.

Reimplemented in Splitter.

virtual void GenericProcessor::setSourceNode ( GenericProcessor sn)
virtual

Sets a processor's source node.

virtual void GenericProcessor::setDestNode ( GenericProcessor dn)
virtual

Sets a processor's destination node.

virtual void GenericProcessor::setMergerSourceNode ( GenericProcessor sn)
virtual

Sets one of two possible source nodes for a merger.

Reimplemented in Merger.

virtual void GenericProcessor::setSplitterDestNode ( GenericProcessor dn)
virtual

Sets one of two possible source nodes for a splitter.

Reimplemented in Splitter.

virtual bool GenericProcessor::isSource ( )
virtual

Returns true if a processor is a source, false otherwise.

Reimplemented in SourceNode, SignalGenerator, ExampleProcessor, and EventNode.

virtual bool GenericProcessor::isSink ( )
virtual

Returns true if a processor is a sink, false otherwise.

Reimplemented in ArduinoOutput, WiFiOutput, FPGAOutput, SpikeDisplayNode, ExampleProcessor, and LfpDisplayNode.

virtual bool GenericProcessor::isSplitter ( )
virtual

Returns true if a processor is a splitter, false otherwise.

Reimplemented in Splitter.

virtual bool GenericProcessor::isMerger ( )
virtual

Returns true if a processor is a merger, false otherwise.

Reimplemented in Merger.

virtual bool GenericProcessor::canSendSignalTo ( GenericProcessor )
virtual

Returns true if a processor is able to send its output to a given processor.

Ideally, this should always return true, but there may be special cases when this is not possible.

virtual bool GenericProcessor::isReady ( )
virtual

Returns true if a processor is ready to process data (e.g., all of its parameters are initialized, and its data source is connected).

Reimplemented in SourceNode.

References isEnabled.

virtual bool GenericProcessor::enable ( )
virtual

Called immediately prior to the start of data acquisition, once all processors in the signal chain have indicated they are ready to process data.

Reimplemented in RecordNode, SpikeDetector, SourceNode, SpikeDisplayNode, ArduinoOutput, LfpDisplayNode, ResamplingNode, PhaseDetector, and SignalGenerator.

References isEnabled.

virtual bool GenericProcessor::disable ( )
virtual

Called immediately after the end of data acquisition.

Reimplemented in RecordNode, SpikeDetector, SourceNode, SpikeDisplayNode, ArduinoOutput, LfpDisplayNode, and SignalGenerator.

virtual void GenericProcessor::enableEditor ( )
virtual

Informs a processor's editor that data acquisition is about to begin.

virtual void GenericProcessor::disableEditor ( )
virtual

Informs a processor's editor that data acquisition has ended.

virtual bool GenericProcessor::enabledState ( )
virtual

Indicates whether or not a processor is currently enabled (i.e., able to process data).

References isEnabled.

virtual void GenericProcessor::enabledState ( bool  t)
virtual

Sets whether or not a processor is enabled (i.e., able to process data).

Reimplemented in SourceNode.

References isEnabled.

virtual void GenericProcessor::enableCurrentChannel ( bool  )
virtual

Turns a given channel on or off.

Reimplemented in AudioNode.

virtual bool GenericProcessor::stillHasSource ( )
virtual

Indicates whether a source node is connected to a processor (used for mergers).

Reimplemented in Merger.

virtual AudioSampleBuffer* GenericProcessor::getContinuousBuffer ( )
virtual

Returns a pointer to the processor's internal continuous buffer, if it exists.

Reimplemented in AudioResamplingNode.

virtual MidiBuffer* GenericProcessor::getEventBuffer ( )
virtual

Returns a pointer to the processor's internal event buffer, if it exists.

virtual int GenericProcessor::checkForEvents ( MidiBuffer &  mb)
virtual

Can be called by processors that need to respond to incoming events.

virtual void GenericProcessor::addEvent ( MidiBuffer &  mb,
uint8  type,
int  sampleNum,
uint8  eventID = 0,
uint8  eventChannel = 0,
uint8  numBytes = 0,
uint8 *  data = 0 
)
virtual

Makes it easier for processors to add events to the MidiBuffer.

virtual void GenericProcessor::handleEvent ( int  eventType,
MidiMessage &  event,
int  samplePosition = 0 
)
virtual

Makes it easier for processors to respond to incoming events, such as TTLs and spikes.

Called by checkForEvents().

Reimplemented in LfpDisplayNode, ArduinoOutput, WiFiOutput, FPGAOutput, and RecordControl.

virtual GenericEditor* GenericProcessor::getEditor ( )
virtual

Returns a pointer to the processor's editor.

References editor.

virtual void GenericProcessor::clearSettings ( )
virtual

Resets the 'settings' struct to its default state.

virtual void GenericProcessor::update ( )
virtual

Default method for updating settings, called by every processor.

virtual void GenericProcessor::updateSettings ( )
virtual

Custom method for updating settings, called automatically by update().

Reimplemented in SpikeDetector, Merger, FPGAOutput, SignalGenerator, LfpDisplayNode, PhaseDetector, FilterNode, ReferenceNode, ResamplingNode, and EventNode.

Parameter& GenericProcessor::getParameterByName ( String  parameterName)

Returns the parameter for a given name.

Parameter& GenericProcessor::getParameterReference ( int  parameterIndex)

Returns the parameter for a given index.


Member Data Documentation

GenericProcessor* GenericProcessor::sourceNode

Pointer to a processor's immediate source node.

Referenced by getSourceNode().

GenericProcessor* GenericProcessor::destNode

Pointer to a processor's immediate destination.

Referenced by getDestNode().

bool GenericProcessor::isEnabled

Referenced by enable(), enabledState(), and isReady().

bool GenericProcessor::wasConnected
int GenericProcessor::nextAvailableChannel
int GenericProcessor::saveOrder

Variable used to orchestrate saving the ProcessorGraph.

int GenericProcessor::loadOrder

Variable used to orchestrate loading the ProcessorGraph.

int GenericProcessor::currentChannel

The channel that will be updated the next time a parameter is changed.

Referenced by setCurrentChannel().

ScopedPointer<GenericEditor> GenericProcessor::editor

Pointer to the processor's editor.

Referenced by getEditor().

OwnedArray<Channel> GenericProcessor::channels

Array of Channel objects for all continuous channels.

OwnedArray<Channel> GenericProcessor::eventChannels

Array of Channel objects for all event channels.

ProcessorSettings GenericProcessor::settings
int GenericProcessor::nodeId

Each processor has a unique integer ID that can be used to identify it.

Referenced by getNodeId(), and setNodeId().

Array<Parameter> GenericProcessor::parameters

An array of parameters that the user can modify.

Referenced by getNumParameters().


The documentation for this class was generated from the following file: