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"
|
gyorgyf@786
|
21 #include "FeatureExtractionModelTransformer.h"
|
Chris@329
|
22
|
Chris@331
|
23 #include "ModelTransformer.h"
|
Chris@331
|
24
|
Chris@486
|
25 #include <vamp-hostsdk/PluginBase.h>
|
Chris@486
|
26
|
Chris@653
|
27 #include <QMap>
|
Chris@320
|
28 #include <map>
|
Chris@320
|
29 #include <set>
|
Chris@848
|
30 #include <vector>
|
Chris@320
|
31
|
Chris@389
|
32 class AudioPlaySource;
|
Chris@320
|
33
|
Chris@331
|
34 class ModelTransformerFactory : public QObject
|
Chris@320
|
35 {
|
Chris@320
|
36 Q_OBJECT
|
Chris@320
|
37
|
Chris@320
|
38 public:
|
Chris@331
|
39 virtual ~ModelTransformerFactory();
|
Chris@320
|
40
|
Chris@331
|
41 static ModelTransformerFactory *getInstance();
|
Chris@320
|
42
|
Chris@653
|
43 class UserConfigurator {
|
Chris@653
|
44 public:
|
Chris@653
|
45 virtual bool configure(ModelTransformer::Input &input,
|
Chris@653
|
46 Transform &transform,
|
Chris@653
|
47 Vamp::PluginBase *plugin,
|
Chris@664
|
48 Model *&inputModel,
|
Chris@653
|
49 AudioPlaySource *source,
|
Chris@653
|
50 size_t startFrame,
|
Chris@653
|
51 size_t duration,
|
Chris@653
|
52 const QMap<QString, Model *> &modelMap,
|
Chris@653
|
53 QStringList candidateModelNames,
|
Chris@653
|
54 QString defaultModelName) = 0;
|
Chris@653
|
55 };
|
Chris@653
|
56
|
Chris@320
|
57 /**
|
Chris@653
|
58 * Fill out the configuration for the given transform (may include
|
Chris@653
|
59 * asking the user by calling back on the UserConfigurator).
|
Chris@653
|
60 * Returns the selected input model and channel if the transform
|
Chris@653
|
61 * is acceptable, or an input with a null model if the operation
|
Chris@653
|
62 * should be cancelled. Audio play source may be used to audition
|
Chris@653
|
63 * effects plugins, if provided.
|
Chris@320
|
64 */
|
Chris@350
|
65 ModelTransformer::Input
|
Chris@350
|
66 getConfigurationForTransform(Transform &transform,
|
Chris@350
|
67 const std::vector<Model *> &candidateInputModels,
|
Chris@350
|
68 Model *defaultInputModel,
|
Chris@389
|
69 AudioPlaySource *source = 0,
|
Chris@350
|
70 size_t startFrame = 0,
|
Chris@653
|
71 size_t duration = 0,
|
Chris@653
|
72 UserConfigurator *configurator = 0);
|
Chris@350
|
73
|
Chris@320
|
74 /**
|
Chris@320
|
75 * Return the output model resulting from applying the named
|
Chris@320
|
76 * transform to the given input model. The transform may still be
|
Chris@320
|
77 * working in the background when the model is returned; check the
|
Chris@320
|
78 * output model's isReady completion status for more details.
|
Chris@320
|
79 *
|
Chris@320
|
80 * If the transform is unknown or the input model is not an
|
Chris@320
|
81 * appropriate type for the given transform, or if some other
|
Chris@361
|
82 * problem occurs, return 0. Set message if there is any error or
|
Chris@361
|
83 * warning to report.
|
Chris@320
|
84 *
|
Chris@320
|
85 * The returned model is owned by the caller and must be deleted
|
Chris@320
|
86 * when no longer needed.
|
Chris@320
|
87 */
|
Chris@848
|
88 Model *transform(const Transform &transform,
|
Chris@848
|
89 const ModelTransformer::Input &input,
|
Chris@848
|
90 QString &message);
|
Chris@848
|
91
|
Chris@848
|
92 /**
|
Chris@848
|
93 * Return the multiple output models resulting from applying the
|
Chris@848
|
94 * named transforms to the given input model. The transforms may
|
Chris@848
|
95 * differ only in output identifier for the plugin: they must all
|
Chris@848
|
96 * use the same plugin, parameters, and programs. The plugin will
|
Chris@848
|
97 * be run once only, but more than one output will be harvested
|
Chris@848
|
98 * (as appropriate). Models will be returned in the same order as
|
Chris@848
|
99 * the transforms were given. The plugin may still be working in
|
Chris@848
|
100 * the background when the model is returned; check the output
|
Chris@848
|
101 * models' isReady completion statuses for more details.
|
Chris@848
|
102 *
|
Chris@848
|
103 * If a transform is unknown or the transforms are insufficiently
|
Chris@848
|
104 * closely related or the input model is not an appropriate type
|
Chris@848
|
105 * for the given transform, or if some other problem occurs,
|
Chris@848
|
106 * return 0. Set message if there is any error or warning to
|
Chris@848
|
107 * report.
|
Chris@848
|
108 *
|
Chris@848
|
109 * The returned models are owned by the caller and must be deleted
|
Chris@848
|
110 * when no longer needed.
|
Chris@848
|
111 */
|
Chris@848
|
112 std::vector<Model *> transformMultiple(const Transforms &transform,
|
Chris@848
|
113 const ModelTransformer::Input &input,
|
Chris@848
|
114 QString &message);
|
Chris@320
|
115
|
Chris@320
|
116 protected slots:
|
Chris@331
|
117 void transformerFinished();
|
Chris@320
|
118
|
Chris@320
|
119 void modelAboutToBeDeleted(Model *);
|
Chris@320
|
120
|
Chris@320
|
121 protected:
|
Chris@850
|
122 ModelTransformer *createTransformer(const Transforms &transforms,
|
Chris@350
|
123 const ModelTransformer::Input &input);
|
Chris@320
|
124
|
Chris@329
|
125 typedef std::map<TransformId, QString> TransformerConfigurationMap;
|
Chris@328
|
126 TransformerConfigurationMap m_lastConfigurations;
|
Chris@320
|
127
|
Chris@331
|
128 typedef std::set<ModelTransformer *> TransformerSet;
|
Chris@328
|
129 TransformerSet m_runningTransformers;
|
Chris@320
|
130
|
Chris@331
|
131 static ModelTransformerFactory *m_instance;
|
Chris@320
|
132 };
|
Chris@320
|
133
|
Chris@320
|
134
|
Chris@320
|
135 #endif
|