Transform.h

Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Sonic Visualiser
00005     An audio file viewer and annotation editor.
00006     Centre for Digital Music, Queen Mary, University of London.
00007     This file copyright 2006-2007 Chris Cannam and QMUL.
00008    
00009     This program is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU General Public License as
00011     published by the Free Software Foundation; either version 2 of the
00012     License, or (at your option) any later version.  See the file
00013     COPYING included with this distribution for more information.
00014 */
00015 
00016 #ifndef _TRANSFORM_H_
00017 #define _TRANSFORM_H_
00018 
00019 #include "base/XmlExportable.h"
00020 #include "base/Window.h"
00021 #include "base/RealTime.h"
00022 
00023 #include <QString>
00024 
00025 typedef QString TransformId;
00026 
00027 class QXmlAttributes;
00028 
00029 namespace Vamp {
00030     class PluginBase;
00031 }
00032 
00033 class Transform : public XmlExportable
00034 {
00035 public:
00044     Transform();
00045 
00050     Transform(QString xml);
00051 
00052     virtual ~Transform();
00053 
00058     bool operator==(const Transform &);
00059 
00060     void setIdentifier(TransformId id);
00061     TransformId getIdentifier() const;
00062 
00063     enum Type { FeatureExtraction, RealTimeEffect };
00064 
00065     Type getType() const;
00066     QString getPluginIdentifier() const;
00067     QString getOutput() const;
00068     
00069     void setPluginIdentifier(QString pluginIdentifier);
00070     void setOutput(QString output);
00071 
00072     // Turn a plugin ID and output name into a transform ID.  Note
00073     // that our pluginIdentifier is the same thing as the Vamp SDK's
00074     // PluginLoader::PluginKey.
00075     static TransformId getIdentifierForPluginOutput(QString pluginIdentifier,
00076                                                     QString output = "");
00077 
00078     typedef std::map<QString, float> ParameterMap;
00079     
00080     const ParameterMap &getParameters() const;
00081     void setParameters(const ParameterMap &pm);
00082     void setParameter(QString name, float value);
00083 
00084     typedef std::map<QString, QString> ConfigurationMap;
00085 
00086     const ConfigurationMap &getConfiguration() const;
00087     void setConfiguration(const ConfigurationMap &cm);
00088     void setConfigurationValue(QString name, QString value);
00089 
00090     QString getPluginVersion() const;
00091     void setPluginVersion(QString version);
00092 
00093     QString getProgram() const;
00094     void setProgram(QString program);
00095     
00096     size_t getStepSize() const;
00097     void setStepSize(size_t s);
00098     
00099     size_t getBlockSize() const;
00100     void setBlockSize(size_t s);
00101     
00102     WindowType getWindowType() const;
00103     void setWindowType(WindowType type);
00104     
00105     RealTime getStartTime() const;
00106     void setStartTime(RealTime t);
00107     
00108     RealTime getDuration() const; // 0 -> all
00109     void setDuration(RealTime d);
00110     
00111     float getSampleRate() const; // 0 -> as input
00112     void setSampleRate(float rate);
00113 
00114     void toXml(QTextStream &stream, QString indent = "",
00115                QString extraAttributes = "") const;
00116 
00130     void setFromXmlAttributes(const QXmlAttributes &);
00131 
00132 protected:
00133     TransformId m_id; // pluginid:output, that is type:soname:label:output
00134     
00135     static QString createIdentifier
00136     (QString type, QString soName, QString label, QString output);
00137 
00138     static void parseIdentifier
00139     (QString identifier,
00140      QString &type, QString &soName, QString &label, QString &output);
00141 
00142     ParameterMap m_parameters;
00143     ConfigurationMap m_configuration;
00144     QString m_pluginVersion;
00145     QString m_program;
00146     size_t m_stepSize;
00147     size_t m_blockSize;
00148     WindowType m_windowType;
00149     RealTime m_startTime;
00150     RealTime m_duration;
00151     float m_sampleRate;
00152 };
00153 
00154 #endif
00155 

Generated on Wed Feb 20 15:45:29 2008 for SonicVisualiser by  doxygen 1.5.1