Essentia  2.1-beta5-dev
streamingalgorithmwrapper.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2016 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 
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 
46  StreamingAlgorithmWrapper() : _algorithm(0) {}
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() {
71  _algorithm->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 
87  _algorithm->declareParameters();
88  _params = _defaultParams = _algorithm->defaultParameters();
89  parameterRange = _algorithm->parameterRange;
91  }
92 
94 
95 };
96 
97 } // namespace streaming
98 } // namespace essentia
99 
100 #endif // ESSENTIA_STREAMINGALGORITHMWRAPPER_H
Definition: streamingalgorithmwrapper.h:30
void configure()
Definition: streamingalgorithmwrapper.h:70
Definition: parameter.h:276
standard::Algorithm * _algorithm
Definition: streamingalgorithmwrapper.h:41
ParameterMap _params
Definition: configurable.h:172
Definition: streamingalgorithmwrapper.h:31
Definition: sourcebase.h:52
void synchronizeInput(const std::string &name)
DescriptionMap parameterDescription
Definition: configurable.h:176
const std::string & name() const
Definition: configurable.h:48
NumeralType
Definition: streamingalgorithmwrapper.h:29
DescriptionMap parameterRange
Definition: configurable.h:177
void reset()
Definition: streamingalgorithmwrapper.h:74
StreamingAlgorithmWrapper()
Definition: streamingalgorithmwrapper.h:46
Definition: sinkbase.h:52
Definition: streamingalgorithmwrapper.h:35
const ParameterMap & defaultParameters() const
Definition: configurable.h:97
void configure(const ParameterMap &params)
Definition: streamingalgorithmwrapper.h:65
void declareOutput(SourceBase &source, NumeralType type, const std::string &name)
NumeralTypeMap _inputType
Definition: streamingalgorithmwrapper.h:40
virtual void reset()
Definition: algorithm.h:88
AlgorithmStatus
Definition: streamingalgorithm.h:106
ParameterMap _defaultParams
Definition: configurable.h:173
void declareAlgorithm(const std::string &name)
Definition: debugging.h:42
Definition: algorithm.h:28
EssentiaMap< std::string, NumeralType > NumeralTypeMap
Definition: streamingalgorithmwrapper.h:38
Definition: streamingalgorithm.h:140
virtual void setParameters(const ParameterMap &params)
NumeralTypeMap _outputType
Definition: streamingalgorithmwrapper.h:40
virtual void declareParameters()=0
void setParameters(const ParameterMap &params)
Definition: streamingalgorithmwrapper.h:81
int _streamSize
Definition: streamingalgorithmwrapper.h:42
virtual void configure(const ParameterMap &params)
void synchronizeOutput(const std::string &name)
void declareParameters()
Definition: streamingalgorithmwrapper.h:86
Definition: algorithm.h:31
#define E_DEBUG(module, msg)
Definition: debugging.h:157
void declareInput(SinkBase &sink, NumeralType type, const std::string &name)