annotate plugin/transform/ModelTransformerFactory.h @ 346:a9ccd644f3bf

* Attempt to fix finding of file:/// URLs * Fix incorrect reassignment of source model in layers that had no source model previously, when replacing a null main model
author Chris Cannam
date Thu, 29 Nov 2007 17:10:53 +0000
parents 700cd3350391
children d7c41483af8f 94fc0591ea43
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@345 51 Model *defaultInputModel,
Chris@332 52 PluginTransformer::ExecutionContext &context,
Chris@332 53 QString &configurationXml,
Chris@332 54 AudioCallbackPlaySource *source = 0,
Chris@332 55 size_t startFrame = 0,
Chris@332 56 size_t duration = 0);
Chris@320 57
Chris@320 58 /**
Chris@320 59 * Get the default execution context for the given transform
Chris@320 60 * and input model (if known).
Chris@320 61 */
Chris@329 62 PluginTransformer::ExecutionContext getDefaultContextForTransformer(TransformId identifier,
Chris@332 63 Model *inputModel = 0);
Chris@320 64
Chris@320 65 /**
Chris@320 66 * Return the output model resulting from applying the named
Chris@320 67 * transform to the given input model. The transform may still be
Chris@320 68 * working in the background when the model is returned; check the
Chris@320 69 * output model's isReady completion status for more details.
Chris@320 70 *
Chris@320 71 * If the transform is unknown or the input model is not an
Chris@320 72 * appropriate type for the given transform, or if some other
Chris@320 73 * problem occurs, return 0.
Chris@320 74 *
Chris@320 75 * The returned model is owned by the caller and must be deleted
Chris@320 76 * when no longer needed.
Chris@320 77 */
Chris@329 78 Model *transform(TransformId identifier, Model *inputModel,
Chris@328 79 const PluginTransformer::ExecutionContext &context,
Chris@320 80 QString configurationXml = "");
Chris@320 81
Chris@320 82 protected slots:
Chris@331 83 void transformerFinished();
Chris@320 84
Chris@320 85 void modelAboutToBeDeleted(Model *);
Chris@320 86
Chris@320 87 protected:
Chris@331 88 ModelTransformer *createTransformer(TransformId identifier, Model *inputModel,
Chris@331 89 const PluginTransformer::ExecutionContext &context,
Chris@331 90 QString configurationXml);
Chris@320 91
Chris@329 92 typedef std::map<TransformId, QString> TransformerConfigurationMap;
Chris@328 93 TransformerConfigurationMap m_lastConfigurations;
Chris@320 94
Chris@331 95 typedef std::set<ModelTransformer *> TransformerSet;
Chris@328 96 TransformerSet m_runningTransformers;
Chris@320 97
Chris@329 98 bool getChannelRange(TransformId identifier,
Chris@320 99 Vamp::PluginBase *plugin, int &min, int &max);
Chris@320 100
Chris@331 101 static ModelTransformerFactory *m_instance;
Chris@320 102 };
Chris@320 103
Chris@320 104
Chris@320 105 #endif