annotate transform/FeatureExtractionModelTransformer.h @ 855:42bbc538d983 tonioni_multi_transform

Merge from tonioni branch
author Chris Cannam
date Wed, 04 Dec 2013 18:29:15 +0000
parents dba8a02b0413
children 13803edd513d
rev   line source
Chris@320 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@320 2
Chris@320 3 /*
Chris@320 4 Sonic Visualiser
Chris@320 5 An audio file viewer and annotation editor.
Chris@320 6 Centre for Digital Music, Queen Mary, University of London.
Chris@320 7 This file copyright 2006 Chris Cannam and QMUL.
Chris@320 8
Chris@320 9 This program is free software; you can redistribute it and/or
Chris@320 10 modify it under the terms of the GNU General Public License as
Chris@320 11 published by the Free Software Foundation; either version 2 of the
Chris@320 12 License, or (at your option) any later version. See the file
Chris@320 13 COPYING included with this distribution for more information.
Chris@320 14 */
Chris@320 15
Chris@849 16 #ifndef _FEATURE_EXTRACTION_MODEL_TRANSFORMER_H_
Chris@849 17 #define _FEATURE_EXTRACTION_MODEL_TRANSFORMER_H_
Chris@320 18
Chris@350 19 #include "ModelTransformer.h"
Chris@350 20
Chris@361 21 #include <QString>
Chris@361 22
Chris@475 23 #include <vamp-hostsdk/Plugin.h>
Chris@350 24
Chris@350 25 #include <iostream>
Chris@320 26
Chris@320 27 class DenseTimeValueModel;
Chris@320 28
Chris@350 29 class FeatureExtractionModelTransformer : public ModelTransformer
Chris@320 30 {
Chris@320 31 Q_OBJECT
Chris@320 32
Chris@320 33 public:
Chris@848 34 enum PreferredOutputModel {
Chris@848 35 NoteOutputModel,
Chris@848 36 FlexiNoteOutputModel,
Chris@848 37 UndefinedOutputModel = 255
Chris@848 38 };
gyorgyf@786 39
Chris@350 40 FeatureExtractionModelTransformer(Input input,
gyorgyf@786 41 const Transform &transform,
Chris@848 42 const PreferredOutputModel outputmodel);
Chris@848 43
Chris@848 44 // Obtain outputs for a set of transforms that all use the same
Chris@848 45 // plugin and input (but with different outputs). i.e. run the
Chris@848 46 // plugin once only and collect more than one output from it.
Chris@848 47 FeatureExtractionModelTransformer(Input input,
Chris@848 48 const Transforms &relatedTransforms,
Chris@848 49 const PreferredOutputModel outputmodel);
gyorgyf@786 50
Chris@331 51 virtual ~FeatureExtractionModelTransformer();
Chris@320 52
Chris@320 53 protected:
Chris@849 54 bool initialise();
Chris@849 55
Chris@320 56 virtual void run();
Chris@320 57
Chris@320 58 Vamp::Plugin *m_plugin;
Chris@849 59 std::vector<Vamp::Plugin::OutputDescriptor *> m_descriptors; // per transform
Chris@849 60 std::vector<int> m_fixedRateFeatureNos; // to assign times to FixedSampleRate features
Chris@849 61 std::vector<int> m_outputNos;
Chris@822 62 PreferredOutputModel m_preferredOutputModel;
Chris@320 63
Chris@849 64 void createOutputModel(int n);
Chris@558 65
Chris@850 66 void addFeature(int n,
Chris@850 67 size_t blockFrame,
Chris@320 68 const Vamp::Plugin::Feature &feature);
Chris@320 69
Chris@850 70 void setCompletion(int, int);
Chris@320 71
Chris@363 72 void getFrames(int channelCount, long startFrame, long size,
Chris@363 73 float **buffer);
Chris@320 74
Chris@320 75 // just casts
Chris@441 76
Chris@350 77 DenseTimeValueModel *getConformingInput();
Chris@441 78
Chris@849 79 template <typename ModelClass> bool isOutput(int n) {
Chris@849 80 return dynamic_cast<ModelClass *>(m_outputs[n]) != 0;
Chris@441 81 }
Chris@441 82
Chris@849 83 template <typename ModelClass> ModelClass *getConformingOutput(int n) {
Chris@849 84 if ((int)m_outputs.size() > n) {
Chris@849 85 ModelClass *mc = dynamic_cast<ModelClass *>(m_outputs[n]);
Chris@849 86 if (!mc) {
Chris@849 87 std::cerr << "FeatureExtractionModelTransformer::getOutput: Output model not conformable" << std::endl;
Chris@849 88 }
Chris@849 89 return mc;
Chris@849 90 } else {
Chris@849 91 std::cerr << "FeatureExtractionModelTransformer::getOutput: No such output number " << n << std::endl;
Chris@849 92 return 0;
Chris@849 93 }
Chris@320 94 }
Chris@320 95 };
Chris@320 96
Chris@320 97 #endif
Chris@320 98