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@328
|
7 This file copyright 2006-2007 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@320
|
16 #ifndef _TRANSFORM_H_
|
Chris@320
|
17 #define _TRANSFORM_H_
|
Chris@320
|
18
|
Chris@328
|
19 #include "base/XmlExportable.h"
|
Chris@328
|
20 #include "base/Window.h"
|
Chris@350
|
21 #include "base/RealTime.h"
|
Chris@328
|
22
|
Chris@328
|
23 #include <QString>
|
Chris@320
|
24
|
Chris@320
|
25 typedef QString TransformId;
|
Chris@320
|
26
|
Chris@350
|
27 class QXmlAttributes;
|
Chris@350
|
28
|
Chris@328
|
29 namespace Vamp {
|
Chris@328
|
30 class PluginBase;
|
Chris@328
|
31 }
|
Chris@320
|
32
|
Chris@328
|
33 class Transform : public XmlExportable
|
Chris@320
|
34 {
|
Chris@320
|
35 public:
|
Chris@350
|
36 /**
|
Chris@350
|
37 * Construct a new Transform with default data and no identifier.
|
Chris@350
|
38 * The Transform object will be meaningless until some data and an
|
Chris@350
|
39 * identifier have been set on it.
|
Chris@350
|
40 *
|
Chris@350
|
41 * To construct a Transform for use with a particular transform
|
Chris@350
|
42 * identifier, use TransformFactory::getDefaultTransformFor.
|
Chris@350
|
43 */
|
Chris@328
|
44 Transform();
|
Chris@350
|
45
|
Chris@350
|
46 /**
|
Chris@350
|
47 * Construct a Transform by parsing the given XML data string.
|
Chris@350
|
48 * This is the inverse of toXml.
|
Chris@350
|
49 */
|
Chris@350
|
50 Transform(QString xml);
|
Chris@350
|
51
|
Chris@320
|
52 virtual ~Transform();
|
Chris@320
|
53
|
Chris@350
|
54 /**
|
Chris@350
|
55 * Compare two Transforms. They only compare equal if every data
|
Chris@350
|
56 * element matches.
|
Chris@350
|
57 */
|
Chris@350
|
58 bool operator==(const Transform &);
|
Chris@350
|
59
|
Chris@350
|
60 void setIdentifier(TransformId id);
|
Chris@350
|
61 TransformId getIdentifier() const;
|
Chris@328
|
62
|
Chris@328
|
63 void setPlugin(QString pluginIdentifier);
|
Chris@328
|
64 void setOutput(QString output);
|
Chris@320
|
65
|
Chris@328
|
66 enum Type { FeatureExtraction, RealTimeEffect };
|
Chris@328
|
67
|
Chris@328
|
68 Type getType() const;
|
Chris@328
|
69 QString getPluginIdentifier() const;
|
Chris@328
|
70 QString getOutput() const;
|
Chris@328
|
71
|
Chris@328
|
72 typedef std::map<QString, float> ParameterMap;
|
Chris@328
|
73
|
Chris@350
|
74 const ParameterMap &getParameters() const;
|
Chris@350
|
75 void setParameters(const ParameterMap &pm);
|
Chris@350
|
76 void setParameter(QString name, float value);
|
Chris@328
|
77
|
Chris@328
|
78 typedef std::map<QString, QString> ConfigurationMap;
|
Chris@328
|
79
|
Chris@350
|
80 const ConfigurationMap &getConfiguration() const;
|
Chris@350
|
81 void setConfiguration(const ConfigurationMap &cm);
|
Chris@350
|
82 void setConfigurationValue(QString name, QString value);
|
Chris@328
|
83
|
Chris@350
|
84 QString getProgram() const;
|
Chris@350
|
85 void setProgram(QString program);
|
Chris@328
|
86
|
Chris@350
|
87 size_t getStepSize() const;
|
Chris@350
|
88 void setStepSize(size_t s);
|
Chris@328
|
89
|
Chris@350
|
90 size_t getBlockSize() const;
|
Chris@350
|
91 void setBlockSize(size_t s);
|
Chris@328
|
92
|
Chris@350
|
93 WindowType getWindowType() const;
|
Chris@350
|
94 void setWindowType(WindowType type);
|
Chris@350
|
95
|
Chris@350
|
96 RealTime getStartTime() const;
|
Chris@350
|
97 void setStartTime(RealTime t);
|
Chris@350
|
98
|
Chris@350
|
99 RealTime getDuration() const; // 0 -> all
|
Chris@350
|
100 void setDuration(RealTime d);
|
Chris@350
|
101
|
Chris@350
|
102 float getSampleRate() const; // 0 -> as input
|
Chris@350
|
103 void setSampleRate(float rate);
|
Chris@328
|
104
|
Chris@328
|
105 void toXml(QTextStream &stream, QString indent = "",
|
Chris@328
|
106 QString extraAttributes = "") const;
|
Chris@328
|
107
|
Chris@350
|
108 /**
|
Chris@350
|
109 * Set the main transform data from the given XML attributes.
|
Chris@350
|
110 * This does not set the parameters or configuration, which are
|
Chris@350
|
111 * exported to separate XML elements rather than attributes of the
|
Chris@350
|
112 * transform element.
|
Chris@350
|
113 */
|
Chris@350
|
114 void setFromXmlAttributes(const QXmlAttributes &);
|
Chris@320
|
115
|
Chris@320
|
116 protected:
|
Chris@328
|
117 TransformId m_id; // pluginid:output, that is type:soname:label:output
|
Chris@328
|
118
|
Chris@328
|
119 static QString createIdentifier
|
Chris@328
|
120 (QString type, QString soName, QString label, QString output);
|
Chris@320
|
121
|
Chris@328
|
122 static void parseIdentifier
|
Chris@328
|
123 (QString identifier,
|
Chris@328
|
124 QString &type, QString &soName, QString &label, QString &output);
|
Chris@328
|
125
|
Chris@328
|
126 ParameterMap m_parameters;
|
Chris@328
|
127 ConfigurationMap m_configuration;
|
Chris@328
|
128 QString m_program;
|
Chris@328
|
129 size_t m_stepSize;
|
Chris@328
|
130 size_t m_blockSize;
|
Chris@328
|
131 WindowType m_windowType;
|
Chris@350
|
132 RealTime m_startTime;
|
Chris@350
|
133 RealTime m_duration;
|
Chris@328
|
134 float m_sampleRate;
|
Chris@320
|
135 };
|
Chris@320
|
136
|
Chris@320
|
137 #endif
|
Chris@328
|
138
|