comparison 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
comparison
equal deleted inserted replaced
387:7aa1de571880 388:370aa9714ef5
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Sonic Visualiser
5 An audio file viewer and annotation editor.
6 Centre for Digital Music, Queen Mary, University of London.
7 This file copyright 2006 Chris Cannam and QMUL.
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information.
14 */
15
16 #ifndef _MODEL_TRANSFORMER_FACTORY_H_
17 #define _MODEL_TRANSFORMER_FACTORY_H_
18
19 #include "Transform.h"
20 #include "TransformDescription.h"
21
22 #include "ModelTransformer.h"
23
24 #include <map>
25 #include <set>
26
27 namespace Vamp { class PluginBase; }
28
29 class AudioCallbackPlaySource;
30
31 class ModelTransformerFactory : public QObject
32 {
33 Q_OBJECT
34
35 public:
36 virtual ~ModelTransformerFactory();
37
38 static ModelTransformerFactory *getInstance();
39
40 /**
41 * Fill out the configuration for the given transform (by asking
42 * the user, most likely). Returns the selected input model and
43 * channel if the transform is acceptable, or an input with a null
44 * model if the operation should be cancelled. Audio callback
45 * play source may be used to audition effects plugins, if
46 * provided.
47 */
48 ModelTransformer::Input
49 getConfigurationForTransform(Transform &transform,
50 const std::vector<Model *> &candidateInputModels,
51 Model *defaultInputModel,
52 AudioCallbackPlaySource *source = 0,
53 size_t startFrame = 0,
54 size_t duration = 0);
55
56 /**
57 * Return the output model resulting from applying the named
58 * transform to the given input model. The transform may still be
59 * working in the background when the model is returned; check the
60 * output model's isReady completion status for more details.
61 *
62 * If the transform is unknown or the input model is not an
63 * appropriate type for the given transform, or if some other
64 * problem occurs, return 0. Set message if there is any error or
65 * warning to report.
66 *
67 * The returned model is owned by the caller and must be deleted
68 * when no longer needed.
69 */
70 Model *transform(const Transform &transform,
71 const ModelTransformer::Input &input,
72 QString &message);
73
74 protected slots:
75 void transformerFinished();
76
77 void modelAboutToBeDeleted(Model *);
78
79 protected:
80 ModelTransformer *createTransformer(const Transform &transform,
81 const ModelTransformer::Input &input);
82
83 typedef std::map<TransformId, QString> TransformerConfigurationMap;
84 TransformerConfigurationMap m_lastConfigurations;
85
86 typedef std::set<ModelTransformer *> TransformerSet;
87 TransformerSet m_runningTransformers;
88
89 bool getChannelRange(TransformId identifier,
90 Vamp::PluginBase *plugin, int &min, int &max);
91
92 static ModelTransformerFactory *m_instance;
93 };
94
95
96 #endif