Chris@330
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@330
|
2
|
Chris@330
|
3 /*
|
Chris@330
|
4 Sonic Visualiser
|
Chris@330
|
5 An audio file viewer and annotation editor.
|
Chris@330
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@330
|
7 This file copyright 2006-2007 Chris Cannam and QMUL.
|
Chris@330
|
8
|
Chris@330
|
9 This program is free software; you can redistribute it and/or
|
Chris@330
|
10 modify it under the terms of the GNU General Public License as
|
Chris@330
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@330
|
12 License, or (at your option) any later version. See the file
|
Chris@330
|
13 COPYING included with this distribution for more information.
|
Chris@330
|
14 */
|
Chris@330
|
15
|
Chris@330
|
16 #ifndef _TRANSFORM_FACTORY_H_
|
Chris@330
|
17 #define _TRANSFORM_FACTORY_H_
|
Chris@330
|
18
|
Chris@330
|
19 #include "TransformDescription.h"
|
Chris@330
|
20
|
Chris@330
|
21 #include <map>
|
Chris@330
|
22 #include <set>
|
Chris@330
|
23
|
Chris@330
|
24 namespace Vamp { class PluginBase; }
|
Chris@330
|
25
|
Chris@330
|
26 class TransformFactory : public QObject
|
Chris@330
|
27 {
|
Chris@330
|
28 Q_OBJECT
|
Chris@330
|
29
|
Chris@330
|
30 public:
|
Chris@330
|
31 virtual ~TransformFactory();
|
Chris@330
|
32
|
Chris@330
|
33 static TransformFactory *getInstance();
|
Chris@330
|
34
|
Chris@330
|
35 TransformList getAllTransforms();
|
Chris@330
|
36
|
Chris@330
|
37 std::vector<QString> getAllTransformTypes();
|
Chris@330
|
38
|
Chris@330
|
39 std::vector<QString> getTransformCategories(QString transformType);
|
Chris@330
|
40 std::vector<QString> getTransformMakers(QString transformType);
|
Chris@330
|
41
|
Chris@330
|
42 /**
|
Chris@330
|
43 * Return true if the given transform is known.
|
Chris@330
|
44 */
|
Chris@330
|
45 bool haveTransform(TransformId identifier);
|
Chris@330
|
46
|
Chris@330
|
47 /**
|
Chris@330
|
48 * Full name of a transform, suitable for putting on a menu.
|
Chris@330
|
49 */
|
Chris@330
|
50 QString getTransformName(TransformId identifier);
|
Chris@330
|
51
|
Chris@330
|
52 /**
|
Chris@330
|
53 * Brief but friendly name of a transform, suitable for use
|
Chris@330
|
54 * as the name of the output layer.
|
Chris@330
|
55 */
|
Chris@330
|
56 QString getTransformFriendlyName(TransformId identifier);
|
Chris@330
|
57
|
Chris@330
|
58 QString getTransformUnits(TransformId identifier);
|
Chris@330
|
59
|
Chris@330
|
60 /**
|
Chris@330
|
61 * Return true if the transform has any configurable parameters,
|
Chris@330
|
62 * i.e. if getConfigurationForTransform can ever return a non-trivial
|
Chris@330
|
63 * (not equivalent to empty) configuration string.
|
Chris@330
|
64 */
|
Chris@330
|
65 bool isTransformConfigurable(TransformId identifier);
|
Chris@330
|
66
|
Chris@330
|
67 /**
|
Chris@330
|
68 * If the transform has a prescribed number or range of channel
|
Chris@330
|
69 * inputs, return true and set minChannels and maxChannels to the
|
Chris@330
|
70 * minimum and maximum number of channel inputs the transform can
|
Chris@330
|
71 * accept. Return false if it doesn't care.
|
Chris@330
|
72 */
|
Chris@330
|
73 bool getTransformChannelRange(TransformId identifier,
|
Chris@330
|
74 int &minChannels, int &maxChannels);
|
Chris@332
|
75
|
Chris@332
|
76 /**
|
Chris@332
|
77 * Set the plugin parameters, program and configuration strings on
|
Chris@332
|
78 * the given Transform object from the given plugin instance.
|
Chris@332
|
79 * Note that no check is made whether the plugin is actually the
|
Chris@332
|
80 * "correct" one for the transform.
|
Chris@332
|
81 */
|
Chris@332
|
82 void setParametersFromPlugin(Transform &transform, Vamp::PluginBase *plugin);
|
Chris@332
|
83
|
Chris@332
|
84 /**
|
Chris@332
|
85 * If the given Transform object has no processing step and block
|
Chris@332
|
86 * sizes set, set them to appropriate defaults for the given
|
Chris@332
|
87 * plugin.
|
Chris@332
|
88 */
|
Chris@332
|
89 void makeContextConsistentWithPlugin(Transform &transform, Vamp::PluginBase *plugin);
|
Chris@332
|
90
|
Chris@332
|
91 /**
|
Chris@332
|
92 * A single transform ID can lead to many possible Transforms,
|
Chris@332
|
93 * with different parameters and execution context settings.
|
Chris@332
|
94 * Return the default one for the given transform.
|
Chris@332
|
95 */
|
Chris@332
|
96 Transform getDefaultTransformFor(TransformId identifier, size_t rate = 0);
|
Chris@332
|
97
|
Chris@330
|
98 protected:
|
Chris@330
|
99 typedef std::map<TransformId, TransformDescription> TransformDescriptionMap;
|
Chris@330
|
100 TransformDescriptionMap m_transforms;
|
Chris@330
|
101
|
Chris@330
|
102 void populateTransforms();
|
Chris@330
|
103 void populateFeatureExtractionPlugins(TransformDescriptionMap &);
|
Chris@330
|
104 void populateRealTimePlugins(TransformDescriptionMap &);
|
Chris@330
|
105
|
Chris@330
|
106 static TransformFactory *m_instance;
|
Chris@330
|
107 };
|
Chris@330
|
108
|
Chris@330
|
109
|
Chris@330
|
110 #endif
|