comparison transform/FeatureExtractionModelTransformer.h @ 851:c9846844ac11 tonioni

Merge branch tonioni_multi_transform
author Chris Cannam
date Mon, 02 Dec 2013 15:47:06 +0000
parents dba8a02b0413
children 13803edd513d
comparison
equal deleted inserted replaced
847:2d53205f70cd 851:c9846844ac11
11 published by the Free Software Foundation; either version 2 of the 11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file 12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information. 13 COPYING included with this distribution for more information.
14 */ 14 */
15 15
16 #ifndef _FEATURE_EXTRACTION_PLUGIN_TRANSFORMER_H_ 16 #ifndef _FEATURE_EXTRACTION_MODEL_TRANSFORMER_H_
17 #define _FEATURE_EXTRACTION_PLUGIN_TRANSFORMER_H_ 17 #define _FEATURE_EXTRACTION_MODEL_TRANSFORMER_H_
18 18
19 #include "ModelTransformer.h" 19 #include "ModelTransformer.h"
20 20
21 #include <QString> 21 #include <QString>
22 22
29 class FeatureExtractionModelTransformer : public ModelTransformer 29 class FeatureExtractionModelTransformer : public ModelTransformer
30 { 30 {
31 Q_OBJECT 31 Q_OBJECT
32 32
33 public: 33 public:
34 enum PreferredOutputModel { 34 enum PreferredOutputModel {
35 NoteOutputModel, 35 NoteOutputModel,
36 FlexiNoteOutputModel, 36 FlexiNoteOutputModel,
37 UndefinedOutputModel = 255 37 UndefinedOutputModel = 255
38 }; 38 };
39 39
40 FeatureExtractionModelTransformer(Input input, 40 FeatureExtractionModelTransformer(Input input,
41 const Transform &transform, 41 const Transform &transform,
42 const PreferredOutputModel outputmodel); 42 const PreferredOutputModel outputmodel);
43
44 // Obtain outputs for a set of transforms that all use the same
45 // plugin and input (but with different outputs). i.e. run the
46 // plugin once only and collect more than one output from it.
47 FeatureExtractionModelTransformer(Input input,
48 const Transforms &relatedTransforms,
49 const PreferredOutputModel outputmodel);
43 50
44 virtual ~FeatureExtractionModelTransformer(); 51 virtual ~FeatureExtractionModelTransformer();
45 52
46 protected: 53 protected:
54 bool initialise();
55
47 virtual void run(); 56 virtual void run();
48 57
49 Vamp::Plugin *m_plugin; 58 Vamp::Plugin *m_plugin;
50 Vamp::Plugin::OutputDescriptor *m_descriptor; 59 std::vector<Vamp::Plugin::OutputDescriptor *> m_descriptors; // per transform
51 int m_fixedRateFeatureNo; // to assign times to FixedSampleRate features 60 std::vector<int> m_fixedRateFeatureNos; // to assign times to FixedSampleRate features
52 int m_outputNo; 61 std::vector<int> m_outputNos;
53 PreferredOutputModel m_preferredOutputModel; 62 PreferredOutputModel m_preferredOutputModel;
54 63
55 void createOutputModel(); 64 void createOutputModel(int n);
56 65
57 void addFeature(size_t blockFrame, 66 void addFeature(int n,
67 size_t blockFrame,
58 const Vamp::Plugin::Feature &feature); 68 const Vamp::Plugin::Feature &feature);
59 69
60 void setCompletion(int); 70 void setCompletion(int, int);
61 71
62 void getFrames(int channelCount, long startFrame, long size, 72 void getFrames(int channelCount, long startFrame, long size,
63 float **buffer); 73 float **buffer);
64 74
65 // just casts 75 // just casts
66 76
67 DenseTimeValueModel *getConformingInput(); 77 DenseTimeValueModel *getConformingInput();
68 78
69 template <typename ModelClass> bool isOutput() { 79 template <typename ModelClass> bool isOutput(int n) {
70 return dynamic_cast<ModelClass *>(m_output) != 0; 80 return dynamic_cast<ModelClass *>(m_outputs[n]) != 0;
71 } 81 }
72 82
73 template <typename ModelClass> ModelClass *getConformingOutput() { 83 template <typename ModelClass> ModelClass *getConformingOutput(int n) {
74 ModelClass *mc = dynamic_cast<ModelClass *>(m_output); 84 if ((int)m_outputs.size() > n) {
75 if (!mc) { 85 ModelClass *mc = dynamic_cast<ModelClass *>(m_outputs[n]);
76 std::cerr << "FeatureExtractionModelTransformer::getOutput: Output model not conformable" << std::endl; 86 if (!mc) {
77 } 87 std::cerr << "FeatureExtractionModelTransformer::getOutput: Output model not conformable" << std::endl;
78 return mc; 88 }
89 return mc;
90 } else {
91 std::cerr << "FeatureExtractionModelTransformer::getOutput: No such output number " << n << std::endl;
92 return 0;
93 }
79 } 94 }
80 }; 95 };
81 96
82 #endif 97 #endif
83 98