Essentia  2.1-beta6-dev
streamingalgorithmwrapper.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2021 Music Technology Group - Universitat Pompeu Fabra
3  *
4  * This file is part of Essentia
5  *
6  * Essentia is free software: you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License as published by the Free
8  * Software Foundation (FSF), either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the Affero GNU General Public License
17  * version 3 along with this program. If not, see http://www.gnu.org/licenses/
18  */
19 
20 #ifndef ESSENTIA_STREAMINGALGORITHMWRAPPER_H
21 #define ESSENTIA_STREAMINGALGORITHMWRAPPER_H
22 
23 #include "streamingalgorithm.h"
24 #include "algorithm.h"
25 
26 namespace essentia {
27 namespace streaming {
28 
31  STREAM
32 };
33 
34 
36 
37  protected:
39 
40  NumeralTypeMap _inputType, _outputType; // indicates whether the algo takes a single token or a sequence of tokens
43 
44  public:
45 
48 
49  void declareInput(SinkBase& sink, NumeralType type, const std::string& name);
50  void declareInput(SinkBase& sink, NumeralType type, int n, const std::string& name);
51 
52  void declareOutput(SourceBase& source, NumeralType type, const std::string& name);
53  void declareOutput(SourceBase& source, NumeralType type, int n, const std::string& name);
54 
55 
56  void synchronizeInput(const std::string& name);
57  //void synchronizeInput(SinkBase* input);
58  void synchronizeOutput(const std::string& name);
59  //void synchronizeOutput(SourceBase* output);
60 
61  void synchronizeIO();
62 
63  void declareAlgorithm(const std::string& name);
64 
65  void configure(const ParameterMap& params) {
66  _algorithm->configure(params);
67  this->setParameters(params);
68  }
69 
70  void configure() {
72  }
73 
74  void reset() {
76  E_DEBUG(EAlgorithm, "Standard : " << name() << "::reset()");
77  _algorithm->reset();
78  E_DEBUG(EAlgorithm, "Standard : " << name() << "::reset() ok!");
79  }
80 
81  void setParameters(const ParameterMap& params) {
83  _algorithm->setParameters(params);
84  }
85 
91  }
92 
94 
95 };
96 
97 } // namespace streaming
98 } // namespace essentia
99 
100 #endif // ESSENTIA_STREAMINGALGORITHMWRAPPER_H
virtual void declareParameters()=0
DescriptionMap parameterRange
Definition: configurable.h:177
ParameterMap _params
Definition: configurable.h:172
DescriptionMap parameterDescription
Definition: configurable.h:176
virtual void configure(const ParameterMap &params)
const std::string & name() const
Definition: configurable.h:48
virtual void setParameters(const ParameterMap &params)
ParameterMap _defaultParams
Definition: configurable.h:173
const ParameterMap & defaultParameters() const
Definition: configurable.h:97
Definition: parameter.h:276
Definition: algorithm.h:31
virtual void reset()
Definition: algorithm.h:88
Definition: streamingalgorithm.h:140
Definition: sinkbase.h:52
Definition: sourcebase.h:52
Definition: streamingalgorithmwrapper.h:35
void setParameters(const ParameterMap &params)
Definition: streamingalgorithmwrapper.h:81
NumeralTypeMap _inputType
Definition: streamingalgorithmwrapper.h:40
NumeralTypeMap _outputType
Definition: streamingalgorithmwrapper.h:40
void synchronizeInput(const std::string &name)
void declareInput(SinkBase &sink, NumeralType type, int n, const std::string &name)
void configure(const ParameterMap &params)
Definition: streamingalgorithmwrapper.h:65
void synchronizeOutput(const std::string &name)
void declareOutput(SourceBase &source, NumeralType type, const std::string &name)
int _streamSize
Definition: streamingalgorithmwrapper.h:42
standard::Algorithm * _algorithm
Definition: streamingalgorithmwrapper.h:41
void declareAlgorithm(const std::string &name)
EssentiaMap< std::string, NumeralType > NumeralTypeMap
Definition: streamingalgorithmwrapper.h:38
void declareOutput(SourceBase &source, NumeralType type, int n, const std::string &name)
StreamingAlgorithmWrapper()
Definition: streamingalgorithmwrapper.h:46
void declareParameters()
Definition: streamingalgorithmwrapper.h:86
void reset()
Definition: streamingalgorithmwrapper.h:74
void declareInput(SinkBase &sink, NumeralType type, const std::string &name)
void configure()
Definition: streamingalgorithmwrapper.h:70
#define E_DEBUG(module, msg)
Definition: debugging.h:157
NumeralType
Definition: streamingalgorithmwrapper.h:29
@ TOKEN
Definition: streamingalgorithmwrapper.h:30
@ STREAM
Definition: streamingalgorithmwrapper.h:31
AlgorithmStatus
Definition: streamingalgorithm.h:106
Definition: algorithm.h:28
@ EAlgorithm
Definition: debugging.h:42