annotate transform/FeatureExtractionModelTransformer.h @ 859:13803edd513d tonioni

Use a settings setting for flexi/non-flexi determination -- this may not be the right thing in the long run but it's simpler and easier than passing through a random value that doesn't actually come from anywhere
author Chris Cannam
date Wed, 04 Dec 2013 19:30:02 +0000
parents dba8a02b0413
children 47aa3aeb687b
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@350 34 FeatureExtractionModelTransformer(Input input,
Chris@859 35 const Transform &transform);
Chris@848 36
Chris@848 37 // Obtain outputs for a set of transforms that all use the same
Chris@848 38 // plugin and input (but with different outputs). i.e. run the
Chris@848 39 // plugin once only and collect more than one output from it.
Chris@848 40 FeatureExtractionModelTransformer(Input input,
Chris@859 41 const Transforms &relatedTransforms);
gyorgyf@786 42
Chris@331 43 virtual ~FeatureExtractionModelTransformer();
Chris@320 44
Chris@320 45 protected:
Chris@849 46 bool initialise();
Chris@849 47
Chris@320 48 virtual void run();
Chris@320 49
Chris@320 50 Vamp::Plugin *m_plugin;
Chris@849 51 std::vector<Vamp::Plugin::OutputDescriptor *> m_descriptors; // per transform
Chris@849 52 std::vector<int> m_fixedRateFeatureNos; // to assign times to FixedSampleRate features
Chris@849 53 std::vector<int> m_outputNos;
Chris@320 54
Chris@849 55 void createOutputModel(int n);
Chris@558 56
Chris@850 57 void addFeature(int n,
Chris@850 58 size_t blockFrame,
Chris@320 59 const Vamp::Plugin::Feature &feature);
Chris@320 60
Chris@850 61 void setCompletion(int, int);
Chris@320 62
Chris@363 63 void getFrames(int channelCount, long startFrame, long size,
Chris@363 64 float **buffer);
Chris@320 65
Chris@320 66 // just casts
Chris@441 67
Chris@350 68 DenseTimeValueModel *getConformingInput();
Chris@441 69
Chris@849 70 template <typename ModelClass> bool isOutput(int n) {
Chris@849 71 return dynamic_cast<ModelClass *>(m_outputs[n]) != 0;
Chris@441 72 }
Chris@441 73
Chris@849 74 template <typename ModelClass> ModelClass *getConformingOutput(int n) {
Chris@849 75 if ((int)m_outputs.size() > n) {
Chris@849 76 ModelClass *mc = dynamic_cast<ModelClass *>(m_outputs[n]);
Chris@849 77 if (!mc) {
Chris@849 78 std::cerr << "FeatureExtractionModelTransformer::getOutput: Output model not conformable" << std::endl;
Chris@849 79 }
Chris@849 80 return mc;
Chris@849 81 } else {
Chris@849 82 std::cerr << "FeatureExtractionModelTransformer::getOutput: No such output number " << n << std::endl;
Chris@849 83 return 0;
Chris@849 84 }
Chris@320 85 }
Chris@320 86 };
Chris@320 87
Chris@320 88 #endif
Chris@320 89