svcore  1.9
TransformFactory Class Reference

#include <TransformFactory.h>

Inheritance diagram for TransformFactory:
Collaboration diagram for TransformFactory:

Classes

class  UninstalledTransformsPopulateThread
 

Public Types

enum  TransformInstallStatus { TransformUnknown, TransformInstalled, TransformNotInstalled }
 
typedef std::map< TransformId, TextMatcher::MatchSearchResults
 

Public Member Functions

 TransformFactory ()
 
virtual ~TransformFactory ()
 
void startPopulationThread ()
 TransformFactory has a background thread that can populate uninstalled transforms from network RDF resources. More...
 
TransformList getAllTransformDescriptions ()
 
TransformDescription getTransformDescription (TransformId id)
 
bool haveInstalledTransforms ()
 
TransformList getUninstalledTransformDescriptions ()
 
TransformDescription getUninstalledTransformDescription (TransformId id)
 
bool haveUninstalledTransforms (bool waitForCheckToComplete=false)
 
TransformInstallStatus getTransformInstallStatus (TransformId id)
 
std::vector< TransformDescription::TypegetAllTransformTypes ()
 
std::vector< QString > getTransformCategories (TransformDescription::Type)
 
std::vector< QString > getTransformMakers (TransformDescription::Type)
 
QString getTransformTypeName (TransformDescription::Type) const
 
SearchResults search (QString keyword)
 
SearchResults search (QStringList keywords)
 
bool haveTransform (TransformId identifier)
 Return true if the given transform is known. More...
 
Transform getDefaultTransformFor (TransformId identifier, int rate=0)
 A single transform ID can lead to many possible Transforms, with different parameters and execution context settings. More...
 
QString getTransformName (TransformId identifier)
 Full name of a transform, suitable for putting on a menu. More...
 
QString getTransformFriendlyName (TransformId identifier)
 Brief but friendly name of a transform, suitable for use as the name of the output layer. More...
 
QString getTransformUnits (TransformId identifier)
 
QString getTransformInfoUrl (TransformId identifier)
 
Vamp::Plugin::InputDomain getTransformInputDomain (TransformId identifier)
 
bool isTransformConfigurable (TransformId identifier)
 Return true if the transform has any configurable parameters, i.e. More...
 
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. More...
 
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. More...
 
Vamp::Plugin * downcastVampPlugin (Vamp::PluginBase *)
 Convert a Vamp::PluginBase to a Vamp::Plugin, if it is one. More...
 
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. More...
 
void setPluginParameters (const Transform &transform, Vamp::PluginBase *plugin)
 Set the parameters, program and configuration strings on the given plugin from the given Transform object. More...
 
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. More...
 
QString getPluginConfigurationXml (const Transform &transform)
 Retrieve a <plugin ... More...
 
void setParametersFromPluginConfigurationXml (Transform &transform, QString xml)
 Set the plugin parameters, program and configuration strings on the given Transform object from the given <plugin ... More...
 

Static Public Member Functions

static TransformFactorygetInstance ()
 
static void deleteInstance ()
 

Protected Types

typedef std::map< TransformId, TransformDescriptionTransformDescriptionMap
 

Protected Member Functions

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

Protected Attributes

TransformDescriptionMap m_transforms
 
bool m_transformsPopulated
 
TransformDescriptionMap m_uninstalledTransforms
 
bool m_uninstalledTransformsPopulated
 
QMutex m_transformsMutex
 
QMutex m_uninstalledTransformsMutex
 
UninstalledTransformsPopulateThreadm_thread
 
bool m_exiting
 
bool m_populatingSlowly
 

Static Protected Attributes

static TransformFactorym_instance = new TransformFactory
 

Detailed Description

Definition at line 33 of file TransformFactory.h.

Member Typedef Documentation

◆ SearchResults

◆ TransformDescriptionMap

Definition at line 200 of file TransformFactory.h.

Member Enumeration Documentation

◆ TransformInstallStatus

Enumerator
TransformUnknown 
TransformInstalled 
TransformNotInstalled 

Definition at line 64 of file TransformFactory.h.

Constructor & Destructor Documentation

◆ TransformFactory()

TransformFactory::TransformFactory ( )

Definition at line 59 of file TransformFactory.cpp.

◆ ~TransformFactory()

TransformFactory::~TransformFactory ( )
virtual

Definition at line 68 of file TransformFactory.cpp.

References m_exiting, m_thread, and SVDEBUG.

Member Function Documentation

◆ getInstance()

◆ deleteInstance()

void TransformFactory::deleteInstance ( )
static

Definition at line 52 of file TransformFactory.cpp.

References m_instance, and SVDEBUG.

◆ startPopulationThread()

void TransformFactory::startPopulationThread ( )

TransformFactory has a background thread that can populate uninstalled transforms from network RDF resources.

It is not started by default, but it's a good idea to start it when the program starts up, if the uninstalled transforms may be of use later; otherwise there will be a bottleneck the first time they're requested.

If this thread is not already running, start it now.

Definition at line 84 of file TransformFactory.cpp.

References m_thread, and m_uninstalledTransformsMutex.

◆ getAllTransformDescriptions()

TransformList TransformFactory::getAllTransformDescriptions ( )

Definition at line 108 of file TransformFactory.cpp.

References m_transforms, and populateTransforms().

◆ getTransformDescription()

TransformDescription TransformFactory::getTransformDescription ( TransformId  id)

Definition at line 134 of file TransformFactory.cpp.

References m_transforms, and populateTransforms().

◆ haveInstalledTransforms()

bool TransformFactory::haveInstalledTransforms ( )

Definition at line 146 of file TransformFactory.cpp.

References m_transforms, and populateTransforms().

◆ getUninstalledTransformDescriptions()

TransformList TransformFactory::getUninstalledTransformDescriptions ( )

◆ getUninstalledTransformDescription()

TransformDescription TransformFactory::getUninstalledTransformDescription ( TransformId  id)

◆ haveUninstalledTransforms()

bool TransformFactory::haveUninstalledTransforms ( bool  waitForCheckToComplete = false)

◆ getTransformInstallStatus()

◆ getAllTransformTypes()

std::vector< TransformDescription::Type > TransformFactory::getAllTransformTypes ( )

Definition at line 244 of file TransformFactory.cpp.

References m_transforms, and populateTransforms().

◆ getTransformCategories()

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

Definition at line 263 of file TransformFactory.cpp.

References m_transforms, and populateTransforms().

◆ getTransformMakers()

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

Definition at line 290 of file TransformFactory.cpp.

References m_transforms, and populateTransforms().

◆ getTransformTypeName()

◆ search() [1/2]

TransformFactory::SearchResults TransformFactory::search ( QString  keyword)

Definition at line 1105 of file TransformFactory.cpp.

◆ search() [2/2]

◆ haveTransform()

bool TransformFactory::haveTransform ( TransformId  identifier)

Return true if the given transform is known.

Definition at line 835 of file TransformFactory.cpp.

References m_transforms, and populateTransforms().

◆ getDefaultTransformFor()

Transform TransformFactory::getDefaultTransformFor ( TransformId  identifier,
int  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 753 of file TransformFactory.cpp.

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

◆ getTransformName()

QString TransformFactory::getTransformName ( TransformId  identifier)

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

Definition at line 842 of file TransformFactory.cpp.

References m_transforms.

◆ getTransformFriendlyName()

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 850 of file TransformFactory.cpp.

References m_transforms.

Referenced by ModelTransformerFactory::transformMultiple().

◆ getTransformUnits()

QString TransformFactory::getTransformUnits ( TransformId  identifier)

◆ getTransformInfoUrl()

QString TransformFactory::getTransformInfoUrl ( TransformId  identifier)

Definition at line 866 of file TransformFactory.cpp.

References m_transforms.

◆ getTransformInputDomain()

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

◆ isTransformConfigurable()

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 896 of file TransformFactory.cpp.

References m_transforms.

◆ getTransformChannelRange()

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 904 of file TransformFactory.cpp.

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

◆ instantiatePluginFor()

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 772 of file TransformFactory.cpp.

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

◆ downcastVampPlugin()

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

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 817 of file TransformFactory.cpp.

Referenced by getTransformInputDomain(), and makeContextConsistentWithPlugin().

◆ setParametersFromPlugin()

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 941 of file TransformFactory.cpp.

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

Referenced by getDefaultTransformFor(), and setParametersFromPluginConfigurationXml().

◆ setPluginParameters()

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 989 of file TransformFactory.cpp.

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

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

◆ makeContextConsistentWithPlugin()

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 1027 of file TransformFactory.cpp.

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

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

◆ getPluginConfigurationXml()

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 1064 of file TransformFactory.cpp.

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

◆ setParametersFromPluginConfigurationXml()

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 1087 of file TransformFactory.cpp.

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

◆ populateTransforms()

◆ populateUninstalledTransforms()

◆ populateFeatureExtractionPlugins()

◆ populateRealTimePlugins()

◆ instantiateDefaultPluginFor()

Member Data Documentation

◆ m_transforms

◆ m_transformsPopulated

bool TransformFactory::m_transformsPopulated
protected

Definition at line 203 of file TransformFactory.h.

Referenced by populateTransforms().

◆ m_uninstalledTransforms

◆ m_uninstalledTransformsPopulated

bool TransformFactory::m_uninstalledTransformsPopulated
protected

◆ m_transformsMutex

QMutex TransformFactory::m_transformsMutex
protected

Definition at line 214 of file TransformFactory.h.

Referenced by populateTransforms().

◆ m_uninstalledTransformsMutex

QMutex TransformFactory::m_uninstalledTransformsMutex
protected

◆ m_thread

UninstalledTransformsPopulateThread* TransformFactory::m_thread
protected

Definition at line 227 of file TransformFactory.h.

Referenced by startPopulationThread(), and ~TransformFactory().

◆ m_exiting

bool TransformFactory::m_exiting
protected

◆ m_populatingSlowly

◆ m_instance

TransformFactory * TransformFactory::m_instance = new TransformFactory
staticprotected

Definition at line 231 of file TransformFactory.h.

Referenced by deleteInstance(), and getInstance().


The documentation for this class was generated from the following files: