TransformFactory Class Reference

#include <TransformFactory.h>

Collaboration diagram for TransformFactory:

Collaboration graph
[legend]
List of all members.

Detailed Description

Definition at line 26 of file TransformFactory.h.

Public Member Functions

virtual ~TransformFactory ()
TransformList getAllTransformDescriptions ()
TransformDescription getTransformDescription (TransformId id)
std::vector< QString > getAllTransformTypes ()
std::vector< QString > getTransformCategories (QString transformType)
std::vector< QString > getTransformMakers (QString transformType)
bool haveTransform (TransformId identifier)
 Return true if the given transform is known.
Transform getDefaultTransformFor (TransformId identifier, size_t rate=0)
 A single transform ID can lead to many possible Transforms, with different parameters and execution context settings.
QString getTransformName (TransformId identifier)
 Full name of a transform, suitable for putting on a menu.
QString getTransformFriendlyName (TransformId identifier)
 Brief but friendly name of a transform, suitable for use as the name of the output layer.
QString getTransformUnits (TransformId identifier)
Vamp::Plugin::InputDomain getTransformInputDomain (TransformId identifier)
bool isTransformConfigurable (TransformId identifier)
 Return true if the transform has any configurable parameters, i.e.
bool getTransformChannelRange (TransformId identifier, int &minChannels, int &maxChannels)
 If the transform has a prescribed number or range of channel inputs, return true and set minChannels and maxChannels to the minimum and maximum number of channel inputs the transform can accept.
Vamp::PluginBase * instantiatePluginFor (const Transform &transform)
 Load an appropriate plugin for the given transform and set the parameters, program and configuration strings on that plugin from the Transform object.
Vamp::Plugin * downcastVampPlugin (Vamp::PluginBase *)
 Convert a Vamp::PluginBase to a Vamp::Plugin, if it is one.
void setParametersFromPlugin (Transform &transform, Vamp::PluginBase *plugin)
 Set the plugin parameters, program and configuration strings on the given Transform object from the given plugin instance.
void setPluginParameters (const Transform &transform, Vamp::PluginBase *plugin)
 Set the parameters, program and configuration strings on the given plugin from the given Transform object.
void makeContextConsistentWithPlugin (Transform &transform, Vamp::PluginBase *plugin)
 If the given Transform object has no processing step and block sizes set, set them to appropriate defaults for the given plugin.
QString getPluginConfigurationXml (const Transform &transform)
 Retrieve a <plugin .
void setParametersFromPluginConfigurationXml (Transform &transform, QString xml)
 Set the plugin parameters, program and configuration strings on the given Transform object from the given <plugin .

Static Public Member Functions

static TransformFactorygetInstance ()

Protected Types

typedef std::map< TransformId,
TransformDescription
TransformDescriptionMap

Protected Member Functions

void populateTransforms ()
void populateFeatureExtractionPlugins (TransformDescriptionMap &)
void populateRealTimePlugins (TransformDescriptionMap &)
Vamp::PluginBase * instantiateDefaultPluginFor (TransformId id, size_t rate)

Protected Attributes

TransformDescriptionMap m_transforms

Static Protected Attributes

static TransformFactorym_instance


Member Typedef Documentation

typedef std::map<TransformId, TransformDescription> TransformFactory::TransformDescriptionMap [protected]

Definition at line 159 of file TransformFactory.h.


Constructor & Destructor Documentation

TransformFactory::~TransformFactory (  )  [virtual]

Definition at line 42 of file TransformFactory.cpp.


Member Function Documentation

TransformFactory * TransformFactory::getInstance (  )  [static]

Definition at line 37 of file TransformFactory.cpp.

References m_instance.

Referenced by Document::addDerivedModel(), MainWindow::addLayer(), Document::alignModel(), Document::canAlign(), Document::createDerivedLayer(), FeatureExtractionModelTransformer::FeatureExtractionModelTransformer(), ModelTransformerFactory::getChannelRange(), ModelTransformerFactory::getConfigurationForTransform(), MainWindow::handleOSCMessage(), SVFileReader::readPlugin(), RealTimeEffectModelTransformer::RealTimeEffectModelTransformer(), MainWindow::setupTransformsMenu(), ModelTransformerFactory::transform(), and Document::writeBackwardCompatibleDerivation().

TransformList TransformFactory::getAllTransformDescriptions (  ) 

Definition at line 47 of file TransformFactory.cpp.

References m_transforms, and populateTransforms().

Referenced by MainWindow::setupTransformsMenu().

TransformDescription TransformFactory::getTransformDescription ( TransformId  id  ) 

Definition at line 69 of file TransformFactory.cpp.

References m_transforms, and populateTransforms().

std::vector< QString > TransformFactory::getAllTransformTypes (  ) 

Definition at line 81 of file TransformFactory.cpp.

References m_transforms, and populateTransforms().

Referenced by MainWindow::setupTransformsMenu().

std::vector< QString > TransformFactory::getTransformCategories ( QString  transformType  ) 

Definition at line 100 of file TransformFactory.cpp.

References m_transforms, and populateTransforms().

Referenced by MainWindow::setupTransformsMenu().

std::vector< QString > TransformFactory::getTransformMakers ( QString  transformType  ) 

Definition at line 127 of file TransformFactory.cpp.

References m_transforms, and populateTransforms().

Referenced by MainWindow::setupTransformsMenu().

bool TransformFactory::haveTransform ( TransformId  identifier  ) 

Return true if the given transform is known.

Definition at line 519 of file TransformFactory.cpp.

References m_transforms, and populateTransforms().

Referenced by Document::canAlign().

Transform TransformFactory::getDefaultTransformFor ( TransformId  identifier,
size_t  rate = 0 
)

A single transform ID can lead to many possible Transforms, with different parameters and execution context settings.

Return the default one for the given transform.

Definition at line 443 of file TransformFactory.cpp.

References instantiateDefaultPluginFor(), makeContextConsistentWithPlugin(), Transform::setIdentifier(), setParametersFromPlugin(), Transform::setPluginVersion(), and Transform::setSampleRate().

Referenced by Document::alignModel().

QString TransformFactory::getTransformName ( TransformId  identifier  ) 

Full name of a transform, suitable for putting on a menu.

Definition at line 526 of file TransformFactory.cpp.

References m_transforms.

QString TransformFactory::getTransformFriendlyName ( TransformId  identifier  ) 

Brief but friendly name of a transform, suitable for use as the name of the output layer.

Definition at line 534 of file TransformFactory.cpp.

References m_transforms.

Referenced by ModelTransformerFactory::transform().

QString TransformFactory::getTransformUnits ( TransformId  identifier  ) 

Definition at line 542 of file TransformFactory.cpp.

References m_transforms.

Referenced by RealTimeEffectModelTransformer::RealTimeEffectModelTransformer().

Vamp::Plugin::InputDomain TransformFactory::getTransformInputDomain ( TransformId  identifier  ) 

Definition at line 550 of file TransformFactory.cpp.

References downcastVampPlugin(), Transform::FeatureExtraction, Transform::getType(), instantiateDefaultPluginFor(), and Transform::setIdentifier().

bool TransformFactory::isTransformConfigurable ( TransformId  identifier  ) 

Return true if the transform has any configurable parameters, i.e.

if getConfigurationForTransform can ever return a non-trivial (not equivalent to empty) configuration string.

Definition at line 572 of file TransformFactory.cpp.

References m_transforms.

bool TransformFactory::getTransformChannelRange ( TransformId  identifier,
int &  minChannels,
int &  maxChannels 
)

If the transform has a prescribed number or range of channel inputs, return true and set minChannels and maxChannels to the minimum and maximum number of channel inputs the transform can accept.

Return false if it doesn't care.

Definition at line 580 of file TransformFactory.cpp.

References RealTimePluginDescriptor::audioInputPortCount, RealTimePluginFactory::instanceFor(), and FeatureExtractionPluginFactory::instanceFor().

Vamp::PluginBase * TransformFactory::instantiatePluginFor ( const Transform transform  ) 

Load an appropriate plugin for the given transform and set the parameters, program and configuration strings on that plugin from the Transform object.

Note that this requires that the transform has a meaningful sample rate set, as that is used as the rate for the plugin. A Transform can legitimately have rate set at zero (= "use the rate of the input source"), so the caller will need to test for this case.

Returns the plugin thus loaded. This will be a Vamp::PluginBase, but not necessarily a Vamp::Plugin (only if the transform was a feature-extraction type -- call downcastVampPlugin if you only want Vamp::Plugins). Returns NULL if no suitable plugin was available.

The returned plugin is owned by the caller, and should be deleted (using "delete") when no longer needed.

Definition at line 462 of file TransformFactory.cpp.

References Transform::getIdentifier(), Transform::getSampleRate(), instantiateDefaultPluginFor(), and setPluginParameters().

Vamp::Plugin * TransformFactory::downcastVampPlugin ( Vamp::PluginBase *   ) 

Convert a Vamp::PluginBase to a Vamp::Plugin, if it is one.

Return NULL otherwise. This ill-fitting convenience function is really just a dynamic_cast wrapper.

!! why?

!! no, I mean really why?

Definition at line 501 of file TransformFactory.cpp.

Referenced by getTransformInputDomain(), and makeContextConsistentWithPlugin().

void TransformFactory::setParametersFromPlugin ( Transform transform,
Vamp::PluginBase *  plugin 
)

Set the plugin parameters, program and configuration strings on the given Transform object from the given plugin instance.

Note that no check is made whether the plugin is actually the "correct" one for the transform.

!! record plugin & API version

!! check that this is the right plugin!

Definition at line 617 of file TransformFactory.cpp.

References RealTimePluginInstance::getConfigurePairs(), Transform::setConfiguration(), Transform::setParameters(), and Transform::setProgram().

Referenced by getDefaultTransformFor(), and setParametersFromPluginConfigurationXml().

void TransformFactory::setPluginParameters ( const Transform transform,
Vamp::PluginBase *  plugin 
)

Set the parameters, program and configuration strings on the given plugin from the given Transform object.

!! check plugin & API version (see e.g. PluginXml::setParameters)

!! check that this is the right plugin!

Definition at line 662 of file TransformFactory.cpp.

References RealTimePluginInstance::configure(), Transform::getConfiguration(), Transform::getParameters(), and Transform::getProgram().

Referenced by FeatureExtractionModelTransformer::FeatureExtractionModelTransformer(), getPluginConfigurationXml(), instantiatePluginFor(), and RealTimeEffectModelTransformer::RealTimeEffectModelTransformer().

void TransformFactory::makeContextConsistentWithPlugin ( Transform transform,
Vamp::PluginBase *  plugin 
)

If the given Transform object has no processing step and block sizes set, set them to appropriate defaults for the given plugin.

Definition at line 700 of file TransformFactory.cpp.

References downcastVampPlugin(), Transform::getBlockSize(), Transform::getStepSize(), Transform::setBlockSize(), and Transform::setStepSize().

Referenced by FeatureExtractionModelTransformer::FeatureExtractionModelTransformer(), and getDefaultTransformFor().

QString TransformFactory::getPluginConfigurationXml ( const Transform transform  ) 

Retrieve a <plugin .

.. /> XML fragment that describes the plugin parameters, program and configuration data for the given transform.

This function is provided for backward compatibility only. Use Transform::toXml where compatibility with PluginXml descriptions of transforms is not required.

Definition at line 737 of file TransformFactory.cpp.

References Transform::getIdentifier(), instantiateDefaultPluginFor(), and setPluginParameters().

Referenced by Document::writeBackwardCompatibleDerivation().

void TransformFactory::setParametersFromPluginConfigurationXml ( Transform transform,
QString  xml 
)

Set the plugin parameters, program and configuration strings on the given Transform object from the given <plugin .

.. /> XML fragment.

This function is provided for backward compatibility only. Use Transform(QString) where compatibility with PluginXml descriptions of transforms is not required.

Definition at line 760 of file TransformFactory.cpp.

References Transform::getIdentifier(), instantiateDefaultPluginFor(), and setParametersFromPlugin().

void TransformFactory::populateTransforms (  )  [protected]

Definition at line 154 of file TransformFactory.cpp.

References m_transforms, populateFeatureExtractionPlugins(), and populateRealTimePlugins().

Referenced by getAllTransformDescriptions(), getAllTransformTypes(), getTransformCategories(), getTransformDescription(), getTransformMakers(), and haveTransform().

void TransformFactory::populateFeatureExtractionPlugins ( TransformDescriptionMap  )  [protected]

Definition at line 217 of file TransformFactory.cpp.

References FeatureExtractionPluginFactory::getAllPluginIdentifiers(), FeatureExtractionPluginFactory::getPluginCategory(), FeatureExtractionPluginFactory::instanceFor(), and FeatureExtractionPluginFactory::instantiatePlugin().

Referenced by populateTransforms().

void TransformFactory::populateRealTimePlugins ( TransformDescriptionMap  )  [protected]

Definition at line 310 of file TransformFactory.cpp.

References RealTimePluginDescriptor::audioInputPortCount, RealTimePluginDescriptor::audioOutputPortCount, RealTimePluginDescriptor::controlOutputPortCount, RealTimePluginDescriptor::controlOutputPortNames, RealTimePluginFactory::getAllPluginIdentifiers(), RealTimePluginFactory::getPluginCategory(), RealTimePluginFactory::getPluginDescriptor(), RealTimePluginFactory::instanceFor(), RealTimePluginDescriptor::isSynth, RealTimePluginDescriptor::maker, RealTimePluginDescriptor::name, and RealTimePluginDescriptor::parameterCount.

Referenced by populateTransforms().

Vamp::PluginBase * TransformFactory::instantiateDefaultPluginFor ( TransformId  id,
size_t  rate 
) [protected]

Definition at line 473 of file TransformFactory.cpp.

References Transform::FeatureExtraction, Transform::getPluginIdentifier(), Transform::getType(), RealTimePluginFactory::instanceFor(), FeatureExtractionPluginFactory::instanceFor(), RealTimePluginFactory::instantiatePlugin(), FeatureExtractionPluginFactory::instantiatePlugin(), and Transform::setIdentifier().

Referenced by getDefaultTransformFor(), getPluginConfigurationXml(), getTransformInputDomain(), instantiatePluginFor(), and setParametersFromPluginConfigurationXml().


Member Data Documentation

TransformDescriptionMap TransformFactory::m_transforms [protected]

Definition at line 160 of file TransformFactory.h.

Referenced by getAllTransformDescriptions(), getAllTransformTypes(), getTransformCategories(), getTransformDescription(), getTransformFriendlyName(), getTransformMakers(), getTransformName(), getTransformUnits(), haveTransform(), isTransformConfigurable(), and populateTransforms().

TransformFactory * TransformFactory::m_instance [static, protected]

Definition at line 168 of file TransformFactory.h.

Referenced by getInstance().


The documentation for this class was generated from the following files:
Generated on Wed Feb 20 15:45:37 2008 for SonicVisualiser by  doxygen 1.5.1