annotate plugin/transform/ModelTransformerFactory.h @ 341:db8fcd280234

* Fix log range mapper bug
author Chris Cannam
date Mon, 26 Nov 2007 13:33:14 +0000
parents 13e5870040e6
children 700cd3350391 6f6ab834449d
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"
Chris@329 21
Chris@331 22 #include "ModelTransformer.h"
Chris@331 23
Chris@328 24 #include "PluginTransformer.h"
Chris@320 25
Chris@320 26 #include <map>
Chris@320 27 #include <set>
Chris@320 28
Chris@320 29 namespace Vamp { class PluginBase; }
Chris@320 30
Chris@320 31 class AudioCallbackPlaySource;
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@320 42 /**
Chris@320 43 * Get a configuration XML string for the given transform (by
Chris@320 44 * asking the user, most likely). Returns the selected input
Chris@320 45 * model if the transform is acceptable, 0 if the operation should
Chris@320 46 * be cancelled. Audio callback play source may be used to
Chris@320 47 * audition effects plugins, if provided.
Chris@320 48 */
Chris@329 49 Model *getConfigurationForTransformer(TransformId identifier,
Chris@332 50 const std::vector<Model *> &candidateInputModels,
Chris@332 51 PluginTransformer::ExecutionContext &context,
Chris@332 52 QString &configurationXml,
Chris@332 53 AudioCallbackPlaySource *source = 0,
Chris@332 54 size_t startFrame = 0,
Chris@332 55 size_t duration = 0);
Chris@320 56
Chris@320 57 /**
Chris@320 58 * Get the default execution context for the given transform
Chris@320 59 * and input model (if known).
Chris@320 60 */
Chris@329 61 PluginTransformer::ExecutionContext getDefaultContextForTransformer(TransformId identifier,
Chris@332 62 Model *inputModel = 0);
Chris@320 63
Chris@320 64 /**
Chris@320 65 * Return the output model resulting from applying the named
Chris@320 66 * transform to the given input model. The transform may still be
Chris@320 67 * working in the background when the model is returned; check the
Chris@320 68 * output model's isReady completion status for more details.
Chris@320 69 *
Chris@320 70 * If the transform is unknown or the input model is not an
Chris@320 71 * appropriate type for the given transform, or if some other
Chris@320 72 * problem occurs, return 0.
Chris@320 73 *
Chris@320 74 * The returned model is owned by the caller and must be deleted
Chris@320 75 * when no longer needed.
Chris@320 76 */
Chris@329 77 Model *transform(TransformId identifier, Model *inputModel,
Chris@328 78 const PluginTransformer::ExecutionContext &context,
Chris@320 79 QString configurationXml = "");
Chris@320 80
Chris@320 81 protected slots:
Chris@331 82 void transformerFinished();
Chris@320 83
Chris@320 84 void modelAboutToBeDeleted(Model *);
Chris@320 85
Chris@320 86 protected:
Chris@331 87 ModelTransformer *createTransformer(TransformId identifier, Model *inputModel,
Chris@331 88 const PluginTransformer::ExecutionContext &context,
Chris@331 89 QString configurationXml);
Chris@320 90
Chris@329 91 typedef std::map<TransformId, QString> TransformerConfigurationMap;
Chris@328 92 TransformerConfigurationMap m_lastConfigurations;
Chris@320 93
Chris@331 94 typedef std::set<ModelTransformer *> TransformerSet;
Chris@328 95 TransformerSet m_runningTransformers;
Chris@320 96
Chris@329 97 bool getChannelRange(TransformId identifier,
Chris@320 98 Vamp::PluginBase *plugin, int &min, int &max);
Chris@320 99
Chris@331 100 static ModelTransformerFactory *m_instance;
Chris@320 101 };
Chris@320 102
Chris@320 103
Chris@320 104 #endif