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 * Get the default execution context for the given transform
|
Chris@320
|
58 * and input model (if known).
|
Chris@320
|
59 */
|
Chris@350
|
60 /*!!!
|
Chris@329
|
61 PluginTransformer::ExecutionContext getDefaultContextForTransformer(TransformId identifier,
|
Chris@332
|
62 Model *inputModel = 0);
|
Chris@350
|
63 */
|
Chris@320
|
64 /**
|
Chris@320
|
65 * Return the output model resulting from applying the named
|
Chris@320
|
66 * transform to the given input model. The transform may still be
|
Chris@320
|
67 * working in the background when the model is returned; check the
|
Chris@320
|
68 * output model's isReady completion status for more details.
|
Chris@320
|
69 *
|
Chris@320
|
70 * If the transform is unknown or the input model is not an
|
Chris@320
|
71 * appropriate type for the given transform, or if some other
|
Chris@320
|
72 * problem occurs, return 0.
|
Chris@320
|
73 *
|
Chris@320
|
74 * The returned model is owned by the caller and must be deleted
|
Chris@320
|
75 * when no longer needed.
|
Chris@320
|
76 */
|
Chris@350
|
77 Model *transform(const Transform &transform,
|
Chris@350
|
78 const ModelTransformer::Input &input);
|
Chris@320
|
79
|
Chris@320
|
80 protected slots:
|
Chris@331
|
81 void transformerFinished();
|
Chris@320
|
82
|
Chris@320
|
83 void modelAboutToBeDeleted(Model *);
|
Chris@320
|
84
|
Chris@320
|
85 protected:
|
Chris@350
|
86 ModelTransformer *createTransformer(const Transform &transform,
|
Chris@350
|
87 const ModelTransformer::Input &input);
|
Chris@320
|
88
|
Chris@329
|
89 typedef std::map<TransformId, QString> TransformerConfigurationMap;
|
Chris@328
|
90 TransformerConfigurationMap m_lastConfigurations;
|
Chris@320
|
91
|
Chris@331
|
92 typedef std::set<ModelTransformer *> TransformerSet;
|
Chris@328
|
93 TransformerSet m_runningTransformers;
|
Chris@320
|
94
|
Chris@329
|
95 bool getChannelRange(TransformId identifier,
|
Chris@320
|
96 Vamp::PluginBase *plugin, int &min, int &max);
|
Chris@320
|
97
|
Chris@331
|
98 static ModelTransformerFactory *m_instance;
|
Chris@320
|
99 };
|
Chris@320
|
100
|
Chris@320
|
101
|
Chris@320
|
102 #endif
|