annotate transform/ModelTransformerFactory.h @ 489:82ab61fa9223

* Reorganise our sparql queries on the basis that Redland must be available, not only optional. So for anything querying the pool of data about plugins, we use a single datastore and model which is initialised at the outset by PluginRDFIndexer and then queried directly; for anything that "reads from a file" (e.g. loading annotations) we query directly using Rasqal, going to the datastore when we need additional plugin-related information. This may improve performance, but mostly it simplifies the code and fixes a serious issue with RDF import in the previous versions (namely that multiple sequential RDF imports would end up sharing the same RDF data pool!)
author Chris Cannam
date Fri, 21 Nov 2008 16:12:29 +0000
parents 4c000e196bf1
children 12578237b99c
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@486 24 #include <vamp-hostsdk/PluginBase.h>
Chris@486 25
Chris@320 26 #include <map>
Chris@320 27 #include <set>
Chris@320 28
Chris@389 29 class AudioPlaySource;
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@389 44 * model if the operation should be cancelled. Audio play source
Chris@389 45 * may be used to audition effects plugins, if provided.
Chris@320 46 */
Chris@350 47 ModelTransformer::Input
Chris@350 48 getConfigurationForTransform(Transform &transform,
Chris@350 49 const std::vector<Model *> &candidateInputModels,
Chris@350 50 Model *defaultInputModel,
Chris@389 51 AudioPlaySource *source = 0,
Chris@350 52 size_t startFrame = 0,
Chris@350 53 size_t duration = 0);
Chris@350 54
Chris@320 55 /**
Chris@320 56 * Return the output model resulting from applying the named
Chris@320 57 * transform to the given input model. The transform may still be
Chris@320 58 * working in the background when the model is returned; check the
Chris@320 59 * output model's isReady completion status for more details.
Chris@320 60 *
Chris@320 61 * If the transform is unknown or the input model is not an
Chris@320 62 * appropriate type for the given transform, or if some other
Chris@361 63 * problem occurs, return 0. Set message if there is any error or
Chris@361 64 * warning to report.
Chris@320 65 *
Chris@320 66 * The returned model is owned by the caller and must be deleted
Chris@320 67 * when no longer needed.
Chris@320 68 */
Chris@350 69 Model *transform(const Transform &transform,
Chris@361 70 const ModelTransformer::Input &input,
Chris@361 71 QString &message);
Chris@320 72
Chris@320 73 protected slots:
Chris@331 74 void transformerFinished();
Chris@320 75
Chris@320 76 void modelAboutToBeDeleted(Model *);
Chris@320 77
Chris@320 78 protected:
Chris@350 79 ModelTransformer *createTransformer(const Transform &transform,
Chris@350 80 const ModelTransformer::Input &input);
Chris@320 81
Chris@329 82 typedef std::map<TransformId, QString> TransformerConfigurationMap;
Chris@328 83 TransformerConfigurationMap m_lastConfigurations;
Chris@320 84
Chris@331 85 typedef std::set<ModelTransformer *> TransformerSet;
Chris@328 86 TransformerSet m_runningTransformers;
Chris@320 87
Chris@329 88 bool getChannelRange(TransformId identifier,
Chris@320 89 Vamp::PluginBase *plugin, int &min, int &max);
Chris@320 90
Chris@331 91 static ModelTransformerFactory *m_instance;
Chris@320 92 };
Chris@320 93
Chris@320 94
Chris@320 95 #endif