annotate transform/TransformFactory.h @ 60:3086ff194ea0

* More structural work on feature extraction plugin C <-> C++ adapter * Allow use of LADSPA/DSSI plugins with control outputs as feature extraction plugins (DSSI with MIDI output still to come) * Reorder labels on spectrogram status box * Minor tweaks in doc etc.
author Chris Cannam
date Mon, 27 Mar 2006 15:03:02 +0000
parents 7439f1696314
children ba405e5e69d3
rev   line source
Chris@49 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@0 2
Chris@0 3 /*
Chris@52 4 Sonic Visualiser
Chris@52 5 An audio file viewer and annotation editor.
Chris@52 6 Centre for Digital Music, Queen Mary, University of London.
Chris@52 7 This file copyright 2006 Chris Cannam.
Chris@0 8
Chris@52 9 This program is free software; you can redistribute it and/or
Chris@52 10 modify it under the terms of the GNU General Public License as
Chris@52 11 published by the Free Software Foundation; either version 2 of the
Chris@52 12 License, or (at your option) any later version. See the file
Chris@52 13 COPYING included with this distribution for more information.
Chris@0 14 */
Chris@0 15
Chris@0 16 #ifndef _TRANSFORM_FACTORY_H_
Chris@0 17 #define _TRANSFORM_FACTORY_H_
Chris@0 18
Chris@0 19 #include "Transform.h"
Chris@0 20
Chris@16 21 #include <map>
Chris@16 22
Chris@0 23 class TransformFactory : public QObject
Chris@0 24 {
Chris@0 25 Q_OBJECT
Chris@0 26
Chris@0 27 public:
Chris@0 28 virtual ~TransformFactory();
Chris@0 29
Chris@0 30 static TransformFactory *instance();
Chris@0 31
Chris@56 32 // The name is intended to be computer-referenceable, and unique
Chris@47 33 // within the application. The description is intended to be
Chris@47 34 // human readable. In principle it doesn't have to be unique, but
Chris@47 35 // the factory will add suffixes to ensure that it is, all the
Chris@60 36 // same (just to avoid user confusion). The friendly name is a
Chris@60 37 // shorter version of the description.
Chris@0 38
Chris@0 39 struct TransformDesc {
Chris@56 40 TransformDesc() { }
Chris@60 41 TransformDesc(TransformName _name, QString _description,
Chris@60 42 QString _friendlyName, QString _maker,
Chris@60 43 bool _configurable) :
Chris@60 44 name(_name), description(_description), friendlyName(_friendlyName),
Chris@60 45 maker(_maker), configurable(_configurable) { }
Chris@0 46 TransformName name;
Chris@0 47 QString description;
Chris@60 48 QString friendlyName;
Chris@60 49 QString maker;
Chris@56 50 bool configurable;
Chris@0 51 };
Chris@0 52 typedef std::vector<TransformDesc> TransformList;
Chris@0 53
Chris@0 54 TransformList getAllTransforms();
Chris@0 55
Chris@0 56 /**
Chris@56 57 * Get a configuration XML string for the given transform (by
Chris@56 58 * asking the user, most likely). Returns true if the transform
Chris@56 59 * is acceptable, false if the operation should be cancelled.
Chris@56 60 */
Chris@56 61 bool getConfigurationForTransform(TransformName name, Model *inputModel,
Chris@56 62 QString &configurationXml);
Chris@56 63
Chris@56 64 /**
Chris@0 65 * Return the output model resulting from applying the named
Chris@0 66 * transform to the given input model. The transform may still be
Chris@0 67 * working in the background when the model is returned; check the
Chris@0 68 * output model's isReady completion status for more details.
Chris@0 69 *
Chris@0 70 * If the transform is unknown or the input model is not an
Chris@0 71 * appropriate type for the given transform, or if some other
Chris@0 72 * problem occurs, return 0.
Chris@0 73 *
Chris@0 74 * The returned model is owned by the caller and must be deleted
Chris@0 75 * when no longer needed.
Chris@0 76 */
Chris@56 77 Model *transform(TransformName name, Model *inputModel,
Chris@56 78 QString configurationXml = "");
Chris@0 79
Chris@18 80 /**
Chris@18 81 * Full description of a transform, suitable for putting on a menu.
Chris@18 82 */
Chris@16 83 QString getTransformDescription(TransformName name);
Chris@16 84
Chris@18 85 /**
Chris@18 86 * Brief but friendly description of a transform, suitable for use
Chris@18 87 * as the name of the output layer.
Chris@18 88 */
Chris@18 89 QString getTransformFriendlyName(TransformName name);
Chris@18 90
Chris@57 91 /**
Chris@57 92 * Return true if the transform has any configurable parameters,
Chris@57 93 * i.e. if getConfigurationForTransform can ever return a non-trivial
Chris@57 94 * (not equivalent to empty) configuration string.
Chris@57 95 */
Chris@57 96 bool isTransformConfigurable(TransformName name);
Chris@57 97
Chris@0 98 //!!! Need some way to indicate that the input model has changed /
Chris@0 99 //been deleted so as not to blow up backgrounded transform! -- Or
Chris@0 100 //indeed, if the output model has been deleted -- could equally
Chris@0 101 //well happen!
Chris@0 102
Chris@0 103 //!!! Need transform category!
Chris@0 104
Chris@0 105 protected slots:
Chris@0 106 void transformFinished();
Chris@0 107
Chris@0 108 protected:
Chris@0 109 Transform *createTransform(TransformName name, Model *inputModel,
Chris@56 110 QString configurationXml, bool start);
Chris@0 111
Chris@56 112 struct TransformIdent
Chris@56 113 {
Chris@56 114 TransformName name;
Chris@56 115 QString configurationXml;
Chris@56 116 };
Chris@56 117
Chris@56 118 typedef std::map<TransformName, QString> TransformConfigurationMap;
Chris@56 119 TransformConfigurationMap m_lastConfigurations;
Chris@56 120
Chris@56 121 typedef std::map<TransformName, TransformDesc> TransformDescriptionMap;
Chris@56 122 TransformDescriptionMap m_transforms;
Chris@56 123
Chris@16 124 void populateTransforms();
Chris@60 125 void populateFeatureExtractionPlugins(TransformDescriptionMap &);
Chris@60 126 void populateRealTimePlugins(TransformDescriptionMap &);
Chris@16 127
Chris@0 128 static TransformFactory *m_instance;
Chris@0 129 };
Chris@0 130
Chris@0 131
Chris@0 132 #endif