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_FACTORY_H_ 00017 #define _TRANSFORM_FACTORY_H_ 00018 00019 #include "TransformDescription.h" 00020 00021 #include <vamp-sdk/Plugin.h> 00022 00023 #include <map> 00024 #include <set> 00025 00026 class TransformFactory : public QObject 00027 { 00028 Q_OBJECT 00029 00030 public: 00031 virtual ~TransformFactory(); 00032 00033 static TransformFactory *getInstance(); 00034 00035 TransformList getAllTransformDescriptions(); 00036 TransformDescription getTransformDescription(TransformId id); 00037 00038 std::vector<QString> getAllTransformTypes(); 00039 std::vector<QString> getTransformCategories(QString transformType); 00040 std::vector<QString> getTransformMakers(QString transformType); 00041 00045 bool haveTransform(TransformId identifier); 00046 00052 Transform getDefaultTransformFor(TransformId identifier, size_t rate = 0); 00053 00057 QString getTransformName(TransformId identifier); 00058 00063 QString getTransformFriendlyName(TransformId identifier); 00064 00065 QString getTransformUnits(TransformId identifier); 00066 00067 Vamp::Plugin::InputDomain getTransformInputDomain(TransformId identifier); 00068 00074 bool isTransformConfigurable(TransformId identifier); 00075 00082 bool getTransformChannelRange(TransformId identifier, 00083 int &minChannels, int &maxChannels); 00084 00105 Vamp::PluginBase *instantiatePluginFor(const Transform &transform); 00106 00112 Vamp::Plugin *downcastVampPlugin(Vamp::PluginBase *); 00113 00120 void setParametersFromPlugin(Transform &transform, Vamp::PluginBase *plugin); 00121 00126 void setPluginParameters(const Transform &transform, Vamp::PluginBase *plugin); 00127 00133 void makeContextConsistentWithPlugin(Transform &transform, Vamp::PluginBase *plugin); 00134 00144 QString getPluginConfigurationXml(const Transform &transform); 00145 00155 void setParametersFromPluginConfigurationXml(Transform &transform, 00156 QString xml); 00157 00158 protected: 00159 typedef std::map<TransformId, TransformDescription> TransformDescriptionMap; 00160 TransformDescriptionMap m_transforms; 00161 00162 void populateTransforms(); 00163 void populateFeatureExtractionPlugins(TransformDescriptionMap &); 00164 void populateRealTimePlugins(TransformDescriptionMap &); 00165 00166 Vamp::PluginBase *instantiateDefaultPluginFor(TransformId id, size_t rate); 00167 00168 static TransformFactory *m_instance; 00169 }; 00170 00171 00172 #endif
1.5.1