Essentia
2.1-beta6-dev
|
#include <streamingalgorithm.h>
Public Types | |
typedef OrderedMap< SinkBase > | InputMap |
typedef OrderedMap< SourceBase > | OutputMap |
Public Member Functions | |
Algorithm () | |
virtual | ~Algorithm () |
SinkBase & | input (const std::string &name) |
SourceBase & | output (const std::string &name) |
SinkBase & | input (int idx) |
SourceBase & | output (int idx) |
const InputMap & | inputs () const |
const OutputMap & | outputs () const |
std::vector< std::string > | inputNames () const |
std::vector< std::string > | outputNames () const |
virtual void | shouldStop (bool stop) |
virtual bool | shouldStop () const |
void | disconnectAll () |
AlgorithmStatus | acquireData () |
void | releaseData () |
virtual AlgorithmStatus | process ()=0 |
virtual void | reset () |
Public Member Functions inherited from Configurable | |
virtual | ~Configurable () |
const std::string & | name () const |
void | setName (const std::string &name) |
virtual void | declareParameters ()=0 |
virtual void | setParameters (const ParameterMap ¶ms) |
virtual void | configure (const ParameterMap ¶ms) |
virtual void | configure () |
const ParameterMap & | defaultParameters () const |
const Parameter & | parameter (const std::string &key) const |
Public Attributes | |
DescriptionMap | inputDescription |
DescriptionMap | outputDescription |
Public Attributes inherited from Configurable | |
DescriptionMap | parameterDescription |
DescriptionMap | parameterRange |
Static Public Attributes | |
static const std::string | processingMode |
Protected Member Functions | |
void | declareInput (SinkBase &sink, const std::string &name, const std::string &desc) |
void | declareInput (SinkBase &sink, int n, const std::string &name, const std::string &desc) |
void | declareInput (SinkBase &sink, int acquireSize, int releaseSize, const std::string &name, const std::string &desc) |
void | declareOutput (SourceBase &source, const std::string &name, const std::string &desc) |
void | declareOutput (SourceBase &source, int n, const std::string &name, const std::string &desc) |
void | declareOutput (SourceBase &source, int acquireSize, int releaseSize, const std::string &name, const std::string &desc) |
Protected Member Functions inherited from Configurable | |
void | declareParameter (const std::string &name, const std::string &desc, const std::string &range, const Parameter &defaultValue) |
Protected Attributes | |
bool | _shouldStop |
OutputMap | _outputs |
InputMap | _inputs |
int | nProcess |
Protected Attributes inherited from Configurable | |
std::string | _name |
ParameterMap | _params |
ParameterMap | _defaultParams |
Friends | |
class | essentia::scheduler::Network |
A streaming::Algorithm is an algorithm that can be used in streaming mode. It is very similar to a 'classic' algorithm, but instead of having inputs and outputs that you need to set manually each time you want to call the process() method, they have input stream connectors (called Sinks, because data flows into them as water in a sink) and output stream connectors (called Sources, because data flows out of them).
Connections between two algorithms (actually, between a source and a sink) represent a flow of Tokens, which can be of any type, as long as the Source and Sink are themselves of the same type. A token is the smallest unit you can have in your stream. For example, for an audio stream, the token type will be Real, because a single audio sample is represented as a Real. A frame cutter which outputs frames will have the Token type set to vector<Real>, because you can't take smaller than that, otherwise the frame would be incomplete. A framecutter is then a strange beast, because it has a Sink<Real> (input is a stream of audio samples), but has also a Source<vector<Real> >, because it outputs whole frames one by one. This might seem strange, but is not a problem at all.
NB: of course, the input of the framecutter will consume tokens much more quickly than the rate at which it produces output tokens (frames). That is not a problem at all.
typedef OrderedMap<SinkBase> InputMap |
typedef OrderedMap<SourceBase> OutputMap |
|
inline |
|
inlinevirtual |
AlgorithmStatus acquireData | ( | ) |
This is a non-blocking function.
Referenced by DiskWriter< T >::process(), and VectorInput< TokenType, acquireSize >::process().
|
protected |
Declare a Sink for this algorithm. The sink uses its default acquire/release size.
Referenced by Copy< TokenType >::Copy(), AlgorithmComposite::declareInput(), DevNull< TokenType >::DevNull(), DiskWriter< T >::DiskWriter(), FileOutput< TokenType, StorageType >::FileOutput(), PoolStorage< TokenType, StorageType >::PoolStorage(), and VectorOutput< TokenType, StorageType >::VectorOutput().
|
protected |
Declare a Sink for this algorithm. The sink uses the given acquire/release size.
|
protected |
Declare a Sink for this algorithm. The sink uses n
for the acquire/release size.
|
protected |
Declare a Source for this algorithm. The source uses its default acquire/release size.
Referenced by Copy< TokenType >::Copy(), AlgorithmComposite::declareOutput(), and VectorInput< TokenType, acquireSize >::VectorInput().
|
protected |
Declare a Source for this algorithm. The source uses the given acquire/release size.
|
protected |
Declare a Source for this algorithm. The source uses n
for the acquire/release size.
void disconnectAll | ( | ) |
Disconnect all sources and sinks of this algorithm from anything they would be connected to.
SinkBase& input | ( | const std::string & | name | ) |
SinkBase& input | ( | int | idx | ) |
|
inline |
Returns the names of all the inputs that have been defined for this algorithm.
|
inline |
SourceBase& output | ( | const std::string & | name | ) |
Referenced by essentia::streaming::connect().
SourceBase& output | ( | int | idx | ) |
|
inline |
Returns the names of all the outputs that have been defined for this algorithm.
|
inline |
|
pure virtual |
Implemented in StreamingAlgorithmWrapper, AlgorithmComposite, VectorOutput< TokenType, StorageType >, VectorInput< TokenType, acquireSize >, RingBufferVectorOutput, RingBufferOutput, RingBufferInput, PoolStorage< TokenType, StorageType >, FileOutput< TokenType, StorageType >, DiskWriter< T >, DevNull< TokenType >, Copy< TokenType >, and AccumulatorAlgorithm.
void releaseData | ( | ) |
Referenced by DiskWriter< T >::process(), and VectorInput< TokenType, acquireSize >::process().
|
virtual |
This function will be called when doing batch computations between each file that is processed. That is, if your algorithm is some sort of state machine, it allows you to reset it to its original state to process another file without having to delete and reinstantiate it. This function should not be called directly. Use resetNetwork instead to reset a network of connected Algorithms.
Reimplemented in StreamingAlgorithmWrapper, AlgorithmComposite, VectorOutput< TokenType, StorageType >, VectorInput< TokenType, acquireSize >, RingBufferVectorOutput, RingBufferOutput, RingBufferInput, and AccumulatorAlgorithm.
Referenced by VectorInput< TokenType, acquireSize >::reset(), and StreamingAlgorithmWrapper::reset().
|
inlinevirtual |
Returns whether the algorithm should stop, ie: it has received an end-of-stream signal.
Reimplemented in VectorInput< TokenType, acquireSize >.
|
virtual |
Sets whether an algorithm should stop as soon as it has finished processing all of its inputs. This is most often called when the algorithm has received an STOP_WHEN_DONE signal (at the end of the stream).
Reimplemented in RingBufferInput.
|
friend |
|
protected |
|
protected |
|
protected |
DescriptionMap inputDescription |
|
protected |
number of times the process() method has been called
DescriptionMap outputDescription |
|
static |