Mercurial > hg > svcore
comparison plugin/transform/Transform.h @ 383:94fc0591ea43 1.2-stable
* merge from trunk (1.2 ended up being tracked from trunk, but we may want
this branch for fixes later)
author | Chris Cannam |
---|---|
date | Wed, 27 Feb 2008 10:32:45 +0000 |
parents | 21bd032ae791 |
children |
comparison
equal
deleted
inserted
replaced
349:f39d33b0b265 | 383:94fc0591ea43 |
---|---|
16 #ifndef _TRANSFORM_H_ | 16 #ifndef _TRANSFORM_H_ |
17 #define _TRANSFORM_H_ | 17 #define _TRANSFORM_H_ |
18 | 18 |
19 #include "base/XmlExportable.h" | 19 #include "base/XmlExportable.h" |
20 #include "base/Window.h" | 20 #include "base/Window.h" |
21 | 21 #include "base/RealTime.h" |
22 #include <vamp-sdk/RealTime.h> | |
23 | 22 |
24 #include <QString> | 23 #include <QString> |
25 | 24 |
26 typedef QString TransformId; | 25 typedef QString TransformId; |
26 | |
27 class QXmlAttributes; | |
27 | 28 |
28 namespace Vamp { | 29 namespace Vamp { |
29 class PluginBase; | 30 class PluginBase; |
30 } | 31 } |
31 | 32 |
32 class Transform : public XmlExportable | 33 class Transform : public XmlExportable |
33 { | 34 { |
34 public: | 35 public: |
36 /** | |
37 * Construct a new Transform with default data and no identifier. | |
38 * The Transform object will be meaningless until some data and an | |
39 * identifier have been set on it. | |
40 * | |
41 * To construct a Transform for use with a particular transform | |
42 * identifier, use TransformFactory::getDefaultTransformFor. | |
43 */ | |
35 Transform(); | 44 Transform(); |
45 | |
46 /** | |
47 * Construct a Transform by parsing the given XML data string. | |
48 * This is the inverse of toXml. | |
49 */ | |
50 Transform(QString xml); | |
51 | |
36 virtual ~Transform(); | 52 virtual ~Transform(); |
37 | 53 |
38 void setIdentifier(TransformId id) { m_id = id; } | 54 /** |
39 TransformId getIdentifier() const { return m_id; } | 55 * Compare two Transforms. They only compare equal if every data |
40 | 56 * element matches. |
41 void setPlugin(QString pluginIdentifier); | 57 */ |
42 void setOutput(QString output); | 58 bool operator==(const Transform &); |
59 | |
60 void setIdentifier(TransformId id); | |
61 TransformId getIdentifier() const; | |
43 | 62 |
44 enum Type { FeatureExtraction, RealTimeEffect }; | 63 enum Type { FeatureExtraction, RealTimeEffect }; |
45 | 64 |
46 Type getType() const; | 65 Type getType() const; |
47 QString getPluginIdentifier() const; | 66 QString getPluginIdentifier() const; |
48 QString getOutput() const; | 67 QString getOutput() const; |
68 | |
69 void setPluginIdentifier(QString pluginIdentifier); | |
70 void setOutput(QString output); | |
71 | |
72 // Turn a plugin ID and output name into a transform ID. Note | |
73 // that our pluginIdentifier is the same thing as the Vamp SDK's | |
74 // PluginLoader::PluginKey. | |
75 static TransformId getIdentifierForPluginOutput(QString pluginIdentifier, | |
76 QString output = ""); | |
49 | 77 |
50 typedef std::map<QString, float> ParameterMap; | 78 typedef std::map<QString, float> ParameterMap; |
51 | 79 |
52 ParameterMap getParameters() const { return m_parameters; } | 80 const ParameterMap &getParameters() const; |
53 void setParameters(const ParameterMap &pm) { m_parameters = pm; } | 81 void setParameters(const ParameterMap &pm); |
82 void setParameter(QString name, float value); | |
54 | 83 |
55 typedef std::map<QString, QString> ConfigurationMap; | 84 typedef std::map<QString, QString> ConfigurationMap; |
56 | 85 |
57 ConfigurationMap getConfiguration() const { return m_configuration; } | 86 const ConfigurationMap &getConfiguration() const; |
58 void setConfiguration(const ConfigurationMap &cm) { m_configuration = cm; } | 87 void setConfiguration(const ConfigurationMap &cm); |
88 void setConfigurationValue(QString name, QString value); | |
59 | 89 |
60 QString getProgram() const { return m_program; } | 90 QString getPluginVersion() const; |
61 void setProgram(QString program) { m_program = program; } | 91 void setPluginVersion(QString version); |
92 | |
93 QString getProgram() const; | |
94 void setProgram(QString program); | |
62 | 95 |
63 size_t getStepSize() const { return m_stepSize; } | 96 size_t getStepSize() const; |
64 void setStepSize(size_t s) { m_stepSize = s; } | 97 void setStepSize(size_t s); |
65 | 98 |
66 size_t getBlockSize() const { return m_blockSize; } | 99 size_t getBlockSize() const; |
67 void setBlockSize(size_t s) { m_blockSize = s; } | 100 void setBlockSize(size_t s); |
68 | |
69 WindowType getWindowType() const { return m_windowType; } | |
70 void setWindowType(WindowType type) { m_windowType = type; } | |
71 | |
72 Vamp::RealTime getStartTime() const { return m_startTime; } | |
73 void setStartTime(Vamp::RealTime t) { m_startTime = t; } | |
74 | |
75 Vamp::RealTime getDuration() const { return m_duration; } // 0 -> all | |
76 void setDuration(Vamp::RealTime d) { m_duration = d; } | |
77 | 101 |
78 float getSampleRate() const { return m_sampleRate; } // 0 -> as input | 102 WindowType getWindowType() const; |
79 void setSampleRate(float rate) { m_sampleRate = rate; } | 103 void setWindowType(WindowType type); |
104 | |
105 RealTime getStartTime() const; | |
106 void setStartTime(RealTime t); | |
107 | |
108 RealTime getDuration() const; // 0 -> all | |
109 void setDuration(RealTime d); | |
110 | |
111 float getSampleRate() const; // 0 -> as input | |
112 void setSampleRate(float rate); | |
80 | 113 |
81 void toXml(QTextStream &stream, QString indent = "", | 114 void toXml(QTextStream &stream, QString indent = "", |
82 QString extraAttributes = "") const; | 115 QString extraAttributes = "") const; |
83 | 116 |
84 static Transform fromXmlString(QString xml); | 117 /** |
118 * Set the main transform data from the given XML attributes. | |
119 * This does not set the parameters or configuration, which are | |
120 * exported to separate XML elements rather than attributes of the | |
121 * transform element. | |
122 * | |
123 * Note that this only sets those attributes which are actually | |
124 * present in the argument. Any attributes not defined in the | |
125 * attribute will remain unchanged in the Transform. If your aim | |
126 * is to create a transform exactly matching the given attributes, | |
127 * ensure you start from an empty transform rather than one that | |
128 * has already been configured. | |
129 */ | |
130 void setFromXmlAttributes(const QXmlAttributes &); | |
85 | 131 |
86 protected: | 132 protected: |
87 TransformId m_id; // pluginid:output, that is type:soname:label:output | 133 TransformId m_id; // pluginid:output, that is type:soname:label:output |
88 | 134 |
89 static QString createIdentifier | 135 static QString createIdentifier |
93 (QString identifier, | 139 (QString identifier, |
94 QString &type, QString &soName, QString &label, QString &output); | 140 QString &type, QString &soName, QString &label, QString &output); |
95 | 141 |
96 ParameterMap m_parameters; | 142 ParameterMap m_parameters; |
97 ConfigurationMap m_configuration; | 143 ConfigurationMap m_configuration; |
144 QString m_pluginVersion; | |
98 QString m_program; | 145 QString m_program; |
99 size_t m_stepSize; | 146 size_t m_stepSize; |
100 size_t m_blockSize; | 147 size_t m_blockSize; |
101 WindowType m_windowType; | 148 WindowType m_windowType; |
102 Vamp::RealTime m_startTime; | 149 RealTime m_startTime; |
103 Vamp::RealTime m_duration; | 150 RealTime m_duration; |
104 float m_sampleRate; | 151 float m_sampleRate; |
105 }; | 152 }; |
106 | 153 |
107 #endif | 154 #endif |
108 | 155 |