annotate transform/ModelTransformerFactory.h @ 388:370aa9714ef5

* Move plugin/transform to plain transform. This way transform can depend on model and GUI classes, but plugin doesn't have to.
author Chris Cannam
date Wed, 12 Mar 2008 18:02:17 +0000
parents plugin/transform/ModelTransformerFactory.h@399ea254afd6
children a1b6d2e33cab
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@320 24 #include <map>
Chris@320 25 #include <set>
Chris@320 26
Chris@320 27 namespace Vamp { class PluginBase; }
Chris@320 28
Chris@320 29 class AudioCallbackPlaySource;
Chris@320 30
Chris@331 31 class ModelTransformerFactory : public QObject
Chris@320 32 {
Chris@320 33 Q_OBJECT
Chris@320 34
Chris@320 35 public:
Chris@331 36 virtual ~ModelTransformerFactory();
Chris@320 37
Chris@331 38 static ModelTransformerFactory *getInstance();
Chris@320 39
Chris@320 40 /**
Chris@350 41 * Fill out the configuration for the given transform (by asking
Chris@350 42 * the user, most likely). Returns the selected input model and
Chris@350 43 * channel if the transform is acceptable, or an input with a null
Chris@350 44 * model if the operation should be cancelled. Audio callback
Chris@350 45 * play source may be used to audition effects plugins, if
Chris@350 46 * provided.
Chris@320 47 */
Chris@350 48 ModelTransformer::Input
Chris@350 49 getConfigurationForTransform(Transform &transform,
Chris@350 50 const std::vector<Model *> &candidateInputModels,
Chris@350 51 Model *defaultInputModel,
Chris@350 52 AudioCallbackPlaySource *source = 0,
Chris@350 53 size_t startFrame = 0,
Chris@350 54 size_t duration = 0);
Chris@350 55
Chris@320 56 /**
Chris@320 57 * Return the output model resulting from applying the named
Chris@320 58 * transform to the given input model. The transform may still be
Chris@320 59 * working in the background when the model is returned; check the
Chris@320 60 * output model's isReady completion status for more details.
Chris@320 61 *
Chris@320 62 * If the transform is unknown or the input model is not an
Chris@320 63 * appropriate type for the given transform, or if some other
Chris@361 64 * problem occurs, return 0. Set message if there is any error or
Chris@361 65 * warning to report.
Chris@320 66 *
Chris@320 67 * The returned model is owned by the caller and must be deleted
Chris@320 68 * when no longer needed.
Chris@320 69 */
Chris@350 70 Model *transform(const Transform &transform,
Chris@361 71 const ModelTransformer::Input &input,
Chris@361 72 QString &message);
Chris@320 73
Chris@320 74 protected slots:
Chris@331 75 void transformerFinished();
Chris@320 76
Chris@320 77 void modelAboutToBeDeleted(Model *);
Chris@320 78
Chris@320 79 protected:
Chris@350 80 ModelTransformer *createTransformer(const Transform &transform,
Chris@350 81 const ModelTransformer::Input &input);
Chris@320 82
Chris@329 83 typedef std::map<TransformId, QString> TransformerConfigurationMap;
Chris@328 84 TransformerConfigurationMap m_lastConfigurations;
Chris@320 85
Chris@331 86 typedef std::set<ModelTransformer *> TransformerSet;
Chris@328 87 TransformerSet m_runningTransformers;
Chris@320 88
Chris@329 89 bool getChannelRange(TransformId identifier,
Chris@320 90 Vamp::PluginBase *plugin, int &min, int &max);
Chris@320 91
Chris@331 92 static ModelTransformerFactory *m_instance;
Chris@320 93 };
Chris@320 94
Chris@320 95
Chris@320 96 #endif