annotate transform/ModelTransformerFactory.h @ 787:4faea021b5c1 tonioni

cleanup
author gyorgyf
date Sat, 13 Apr 2013 15:36:54 +0100
parents 5295bdb58840
children 539740f231fa
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@331 16 #ifndef _MODEL_TRANSFORMER_FACTORY_H_
Chris@331 17 #define _MODEL_TRANSFORMER_FACTORY_H_
Chris@320 18
Chris@331 19 #include "Transform.h"
Chris@329 20 #include "TransformDescription.h"
gyorgyf@786 21 #include "FeatureExtractionModelTransformer.h"
Chris@329 22
Chris@331 23 #include "ModelTransformer.h"
Chris@331 24
Chris@486 25 #include <vamp-hostsdk/PluginBase.h>
Chris@486 26
Chris@653 27 #include <QMap>
Chris@320 28 #include <map>
Chris@320 29 #include <set>
Chris@320 30
Chris@389 31 class AudioPlaySource;
Chris@320 32
Chris@331 33 class ModelTransformerFactory : public QObject
Chris@320 34 {
Chris@320 35 Q_OBJECT
Chris@320 36
Chris@320 37 public:
Chris@331 38 virtual ~ModelTransformerFactory();
Chris@320 39
Chris@331 40 static ModelTransformerFactory *getInstance();
Chris@320 41
Chris@653 42 class UserConfigurator {
Chris@653 43 public:
Chris@653 44 virtual bool configure(ModelTransformer::Input &input,
Chris@653 45 Transform &transform,
Chris@653 46 Vamp::PluginBase *plugin,
Chris@664 47 Model *&inputModel,
Chris@653 48 AudioPlaySource *source,
Chris@653 49 size_t startFrame,
Chris@653 50 size_t duration,
Chris@653 51 const QMap<QString, Model *> &modelMap,
Chris@653 52 QStringList candidateModelNames,
Chris@653 53 QString defaultModelName) = 0;
Chris@653 54 };
Chris@653 55
Chris@320 56 /**
Chris@653 57 * Fill out the configuration for the given transform (may include
Chris@653 58 * asking the user by calling back on the UserConfigurator).
Chris@653 59 * Returns the selected input model and channel if the transform
Chris@653 60 * is acceptable, or an input with a null model if the operation
Chris@653 61 * should be cancelled. Audio play source may be used to audition
Chris@653 62 * effects plugins, if provided.
Chris@320 63 */
Chris@350 64 ModelTransformer::Input
Chris@350 65 getConfigurationForTransform(Transform &transform,
Chris@350 66 const std::vector<Model *> &candidateInputModels,
Chris@350 67 Model *defaultInputModel,
Chris@389 68 AudioPlaySource *source = 0,
Chris@350 69 size_t startFrame = 0,
Chris@653 70 size_t duration = 0,
Chris@653 71 UserConfigurator *configurator = 0);
Chris@350 72
Chris@320 73 /**
Chris@320 74 * Return the output model resulting from applying the named
Chris@320 75 * transform to the given input model. The transform may still be
Chris@320 76 * working in the background when the model is returned; check the
Chris@320 77 * output model's isReady completion status for more details.
Chris@320 78 *
Chris@320 79 * If the transform is unknown or the input model is not an
Chris@320 80 * appropriate type for the given transform, or if some other
Chris@361 81 * problem occurs, return 0. Set message if there is any error or
Chris@361 82 * warning to report.
Chris@320 83 *
Chris@320 84 * The returned model is owned by the caller and must be deleted
Chris@320 85 * when no longer needed.
Chris@320 86 */
gyorgyf@786 87 Model *transform(const Transform &transform,
gyorgyf@786 88 const ModelTransformer::Input &input,
gyorgyf@786 89 QString &message,
gyorgyf@786 90 const FeatureExtractionModelTransformer::PreferredOutputModel outputmodel = FeatureExtractionModelTransformer::NoteOutputModel);
Chris@320 91
Chris@320 92 protected slots:
Chris@331 93 void transformerFinished();
Chris@320 94
Chris@320 95 void modelAboutToBeDeleted(Model *);
Chris@320 96
Chris@320 97 protected:
Chris@350 98 ModelTransformer *createTransformer(const Transform &transform,
Chris@350 99 const ModelTransformer::Input &input);
Chris@320 100
Chris@329 101 typedef std::map<TransformId, QString> TransformerConfigurationMap;
Chris@328 102 TransformerConfigurationMap m_lastConfigurations;
Chris@320 103
Chris@331 104 typedef std::set<ModelTransformer *> TransformerSet;
Chris@328 105 TransformerSet m_runningTransformers;
Chris@320 106
Chris@331 107 static ModelTransformerFactory *m_instance;
gyorgyf@787 108 /**
gyorgyf@787 109 * allows the FeatureExtractionModelTransformer output model to be selected externally,
gyorgyf@787 110 * but only in case of the need for NoteModel or FlexiNoteModel
gyorgyf@787 111 */
gyorgyf@786 112 FeatureExtractionModelTransformer::PreferredOutputModel m_preferredOutputModel ;
Chris@320 113 };
Chris@320 114
Chris@320 115
Chris@320 116 #endif