Mercurial > hg > svcore
comparison transform/FeatureExtractionModelTransformer.h @ 874:862fe7b20df7 tony_integration
Merge from tonioni branch
author | Chris Cannam |
---|---|
date | Tue, 28 Jan 2014 15:01:54 +0000 |
parents | 13803edd513d |
children | 47aa3aeb687b |
comparison
equal
deleted
inserted
replaced
862:786ee8d1f30e | 874:862fe7b20df7 |
---|---|
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 |
31 Q_OBJECT | 31 Q_OBJECT |
32 | 32 |
33 public: | 33 public: |
34 FeatureExtractionModelTransformer(Input input, | 34 FeatureExtractionModelTransformer(Input input, |
35 const Transform &transform); | 35 const Transform &transform); |
36 | |
37 // Obtain outputs for a set of transforms that all use the same | |
38 // plugin and input (but with different outputs). i.e. run the | |
39 // plugin once only and collect more than one output from it. | |
40 FeatureExtractionModelTransformer(Input input, | |
41 const Transforms &relatedTransforms); | |
42 | |
36 virtual ~FeatureExtractionModelTransformer(); | 43 virtual ~FeatureExtractionModelTransformer(); |
37 | 44 |
38 protected: | 45 protected: |
46 bool initialise(); | |
47 | |
39 virtual void run(); | 48 virtual void run(); |
40 | 49 |
41 Vamp::Plugin *m_plugin; | 50 Vamp::Plugin *m_plugin; |
42 Vamp::Plugin::OutputDescriptor *m_descriptor; | 51 std::vector<Vamp::Plugin::OutputDescriptor *> m_descriptors; // per transform |
43 int m_fixedRateFeatureNo; // to assign times to FixedSampleRate features | 52 std::vector<int> m_fixedRateFeatureNos; // to assign times to FixedSampleRate features |
44 int m_outputNo; | 53 std::vector<int> m_outputNos; |
45 | 54 |
46 void createOutputModel(); | 55 void createOutputModel(int n); |
47 | 56 |
48 void addFeature(size_t blockFrame, | 57 void addFeature(int n, |
58 size_t blockFrame, | |
49 const Vamp::Plugin::Feature &feature); | 59 const Vamp::Plugin::Feature &feature); |
50 | 60 |
51 void setCompletion(int); | 61 void setCompletion(int, int); |
52 | 62 |
53 void getFrames(int channelCount, long startFrame, long size, | 63 void getFrames(int channelCount, long startFrame, long size, |
54 float **buffer); | 64 float **buffer); |
55 | 65 |
56 // just casts | 66 // just casts |
57 | 67 |
58 DenseTimeValueModel *getConformingInput(); | 68 DenseTimeValueModel *getConformingInput(); |
59 | 69 |
60 template <typename ModelClass> bool isOutput() { | 70 template <typename ModelClass> bool isOutput(int n) { |
61 return dynamic_cast<ModelClass *>(m_output) != 0; | 71 return dynamic_cast<ModelClass *>(m_outputs[n]) != 0; |
62 } | 72 } |
63 | 73 |
64 template <typename ModelClass> ModelClass *getConformingOutput() { | 74 template <typename ModelClass> ModelClass *getConformingOutput(int n) { |
65 ModelClass *mc = dynamic_cast<ModelClass *>(m_output); | 75 if ((int)m_outputs.size() > n) { |
66 if (!mc) { | 76 ModelClass *mc = dynamic_cast<ModelClass *>(m_outputs[n]); |
67 std::cerr << "FeatureExtractionModelTransformer::getOutput: Output model not conformable" << std::endl; | 77 if (!mc) { |
68 } | 78 std::cerr << "FeatureExtractionModelTransformer::getOutput: Output model not conformable" << std::endl; |
69 return mc; | 79 } |
80 return mc; | |
81 } else { | |
82 std::cerr << "FeatureExtractionModelTransformer::getOutput: No such output number " << n << std::endl; | |
83 return 0; | |
84 } | |
70 } | 85 } |
71 }; | 86 }; |
72 | 87 |
73 #endif | 88 #endif |
74 | 89 |