svcore
1.9
|
#include <TransformFactory.h>
Classes | |
class | UninstalledTransformsPopulateThread |
Public Types | |
enum | TransformInstallStatus { TransformUnknown, TransformInstalled, TransformNotInstalled } |
typedef std::map< TransformId, TextMatcher::Match > | SearchResults |
Public Member Functions | |
TransformFactory () | |
virtual | ~TransformFactory () |
void | startPopulationThread () |
TransformFactory has a background thread that can populate uninstalled transforms from network RDF resources. | |
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::Type > | getAllTransformTypes () |
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. | |
Transform | getDefaultTransformFor (TransformId identifier, int 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) |
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. | |
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 TransformFactory * | getInstance () |
static void | deleteInstance () |
Protected Types | |
typedef std::map< TransformId, TransformDescription > | TransformDescriptionMap |
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 |
UninstalledTransformsPopulateThread * | m_thread |
bool | m_exiting |
bool | m_populatingSlowly |
Static Protected Attributes | |
static TransformFactory * | m_instance = new TransformFactory |
Definition at line 33 of file TransformFactory.h.
typedef std::map<TransformId, TextMatcher::Match> TransformFactory::SearchResults |
Definition at line 77 of file TransformFactory.h.
typedef std::map<TransformId, TransformDescription> TransformFactory::TransformDescriptionMap [protected] |
Definition at line 200 of file TransformFactory.h.
Definition at line 64 of file TransformFactory.h.
Definition at line 59 of file TransformFactory.cpp.
TransformFactory::~TransformFactory | ( | ) | [virtual] |
Definition at line 68 of file TransformFactory.cpp.
TransformFactory * TransformFactory::getInstance | ( | ) | [static] |
Definition at line 46 of file TransformFactory.cpp.
References m_instance.
Referenced by FeatureExtractionModelTransformer::initialise(), populateUninstalledTransforms(), and RealTimeEffectModelTransformer::RealTimeEffectModelTransformer().
void TransformFactory::deleteInstance | ( | ) | [static] |
Definition at line 52 of file TransformFactory.cpp.
References m_instance, and SVDEBUG.
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.
Definition at line 108 of file TransformFactory.cpp.
References m_transforms, and populateTransforms().
Definition at line 134 of file TransformFactory.cpp.
References m_transforms, and populateTransforms().
Definition at line 146 of file TransformFactory.cpp.
References m_transforms, and populateTransforms().
Definition at line 153 of file TransformFactory.cpp.
References m_populatingSlowly, m_uninstalledTransforms, and populateUninstalledTransforms().
Definition at line 180 of file TransformFactory.cpp.
References m_populatingSlowly, m_uninstalledTransforms, and populateUninstalledTransforms().
bool TransformFactory::haveUninstalledTransforms | ( | bool | waitForCheckToComplete = false | ) |
Definition at line 193 of file TransformFactory.cpp.
References m_uninstalledTransforms, m_uninstalledTransformsMutex, m_uninstalledTransformsPopulated, and populateUninstalledTransforms().
TransformFactory::TransformInstallStatus TransformFactory::getTransformInstallStatus | ( | TransformId | id | ) |
Definition at line 212 of file TransformFactory.cpp.
References m_populatingSlowly, m_transforms, m_uninstalledTransforms, m_uninstalledTransformsMutex, m_uninstalledTransformsPopulated, populateTransforms(), populateUninstalledTransforms(), TransformInstalled, TransformNotInstalled, and TransformUnknown.
std::vector< TransformDescription::Type > TransformFactory::getAllTransformTypes | ( | ) |
Definition at line 244 of file TransformFactory.cpp.
References m_transforms, and populateTransforms().
std::vector< QString > TransformFactory::getTransformCategories | ( | TransformDescription::Type | transformType | ) |
Definition at line 263 of file TransformFactory.cpp.
References m_transforms, and populateTransforms().
std::vector< QString > TransformFactory::getTransformMakers | ( | TransformDescription::Type | transformType | ) |
Definition at line 290 of file TransformFactory.cpp.
References m_transforms, and populateTransforms().
QString TransformFactory::getTransformTypeName | ( | TransformDescription::Type | type | ) | const |
Definition at line 317 of file TransformFactory.cpp.
References TransformDescription::Analysis, TransformDescription::Effects, TransformDescription::EffectsData, TransformDescription::Generator, and TransformDescription::UnknownType.
Referenced by search().
TransformFactory::SearchResults TransformFactory::search | ( | QString | keyword | ) |
Definition at line 1105 of file TransformFactory.cpp.
TransformFactory::SearchResults TransformFactory::search | ( | QStringList | keywords | ) |
Definition at line 1113 of file TransformFactory.cpp.
References getTransformTypeName(), TextMatcher::Match::key, m_populatingSlowly, m_transforms, m_uninstalledTransforms, m_uninstalledTransformsMutex, m_uninstalledTransformsPopulated, populateTransforms(), TextMatcher::Match::score, and TextMatcher::test().
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().
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().
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.
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.
QString TransformFactory::getTransformUnits | ( | TransformId | identifier | ) |
Definition at line 858 of file TransformFactory.cpp.
References m_transforms.
Referenced by RealTimeEffectModelTransformer::RealTimeEffectModelTransformer().
QString TransformFactory::getTransformInfoUrl | ( | TransformId | identifier | ) |
Definition at line 866 of file TransformFactory.cpp.
References m_transforms.
Vamp::Plugin::InputDomain TransformFactory::getTransformInputDomain | ( | TransformId | identifier | ) |
Definition at line 874 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 896 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 904 of file TransformFactory.cpp.
References RealTimePluginDescriptor::audioInputPortCount, FeatureExtractionPluginFactory::instanceFor(), and RealTimePluginFactory::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 772 of file TransformFactory.cpp.
References Transform::getIdentifier(), Transform::getSampleRate(), instantiateDefaultPluginFor(), and setPluginParameters().
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().
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().
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().
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().
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().
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().
void TransformFactory::populateTransforms | ( | ) | [protected] |
Definition at line 330 of file TransformFactory.cpp.
References TransformDescription::identifier, m_exiting, m_transforms, m_transformsMutex, m_transformsPopulated, TransformDescription::maker, TransformDescription::name, populateFeatureExtractionPlugins(), and populateRealTimePlugins().
Referenced by getAllTransformDescriptions(), getAllTransformTypes(), getTransformCategories(), getTransformDescription(), getTransformInstallStatus(), getTransformMakers(), haveInstalledTransforms(), haveTransform(), populateUninstalledTransforms(), and search().
void TransformFactory::populateUninstalledTransforms | ( | ) | [protected] |
!! This will be amazingly slow
!! basically duplicated from above
!!???
Definition at line 637 of file TransformFactory.cpp.
References TransformDescription::Analysis, TransformDescription::category, TransformDescription::configurable, TransformDescription::description, TransformDescription::friendlyName, Transform::getIdentifierForPluginOutput(), getInstance(), PluginRDFDescription::getOutputIds(), PluginRDFDescription::getOutputName(), PluginRDFDescription::getPluginDescription(), PluginRDFDescription::getPluginInfoURL(), PluginRDFDescription::getPluginMaker(), PluginRDFDescription::getPluginName(), TransformDescription::identifier, TransformDescription::infoUrl, TransformDescription::longDescription, m_exiting, m_transforms, m_uninstalledTransforms, m_uninstalledTransformsMutex, m_uninstalledTransformsPopulated, TransformDescription::maker, TransformDescription::name, populateTransforms(), TransformDescription::type, and TransformDescription::units.
Referenced by getTransformInstallStatus(), getUninstalledTransformDescription(), getUninstalledTransformDescriptions(), haveUninstalledTransforms(), and TransformFactory::UninstalledTransformsPopulateThread::run().
void TransformFactory::populateFeatureExtractionPlugins | ( | TransformDescriptionMap & | transforms | ) | [protected] |
Definition at line 403 of file TransformFactory.cpp.
References TransformDescription::Analysis, FeatureExtractionPluginFactory::getAllPluginIdentifiers(), FeatureExtractionPluginFactory::getPluginCategory(), FeatureExtractionPluginFactory::instanceFor(), FeatureExtractionPluginFactory::instantiatePlugin(), and m_exiting.
Referenced by populateTransforms().
void TransformFactory::populateRealTimePlugins | ( | TransformDescriptionMap & | transforms | ) | [protected] |
!! if (descriptor->controlOutputPortCount == 0 ||
Definition at line 502 of file TransformFactory.cpp.
References RealTimePluginDescriptor::audioInputPortCount, RealTimePluginDescriptor::audioOutputPortCount, RealTimePluginDescriptor::controlOutputPortCount, RealTimePluginDescriptor::controlOutputPortNames, TransformDescription::Effects, TransformDescription::EffectsData, TransformDescription::Generator, RealTimePluginFactory::getAllPluginIdentifiers(), RealTimePluginFactory::getPluginCategory(), RealTimePluginFactory::getPluginDescriptor(), RealTimePluginFactory::instanceFor(), RealTimePluginDescriptor::isSynth, m_exiting, RealTimePluginDescriptor::maker, RealTimePluginDescriptor::name, and RealTimePluginDescriptor::parameterCount.
Referenced by populateTransforms().
Vamp::PluginBase * TransformFactory::instantiateDefaultPluginFor | ( | TransformId | id, |
int | rate | ||
) | [protected] |
Definition at line 785 of file TransformFactory.cpp.
References Transform::FeatureExtraction, Transform::getPluginIdentifier(), Transform::getType(), FeatureExtractionPluginFactory::instanceFor(), RealTimePluginFactory::instanceFor(), FeatureExtractionPluginFactory::instantiatePlugin(), RealTimePluginFactory::instantiatePlugin(), and Transform::setIdentifier().
Referenced by getDefaultTransformFor(), getPluginConfigurationXml(), getTransformInputDomain(), instantiatePluginFor(), and setParametersFromPluginConfigurationXml().
Definition at line 202 of file TransformFactory.h.
Referenced by getAllTransformDescriptions(), getAllTransformTypes(), getTransformCategories(), getTransformDescription(), getTransformFriendlyName(), getTransformInfoUrl(), getTransformInstallStatus(), getTransformMakers(), getTransformName(), getTransformUnits(), haveInstalledTransforms(), haveTransform(), isTransformConfigurable(), populateTransforms(), populateUninstalledTransforms(), and search().
bool TransformFactory::m_transformsPopulated [protected] |
Definition at line 203 of file TransformFactory.h.
Referenced by populateTransforms().
Definition at line 205 of file TransformFactory.h.
Referenced by getTransformInstallStatus(), getUninstalledTransformDescription(), getUninstalledTransformDescriptions(), haveUninstalledTransforms(), populateUninstalledTransforms(), and search().
bool TransformFactory::m_uninstalledTransformsPopulated [protected] |
Definition at line 206 of file TransformFactory.h.
Referenced by getTransformInstallStatus(), haveUninstalledTransforms(), populateUninstalledTransforms(), and search().
QMutex TransformFactory::m_transformsMutex [protected] |
Definition at line 214 of file TransformFactory.h.
Referenced by populateTransforms().
QMutex TransformFactory::m_uninstalledTransformsMutex [protected] |
Definition at line 215 of file TransformFactory.h.
Referenced by getTransformInstallStatus(), haveUninstalledTransforms(), populateUninstalledTransforms(), search(), and startPopulationThread().
Definition at line 227 of file TransformFactory.h.
Referenced by startPopulationThread(), and ~TransformFactory().
bool TransformFactory::m_exiting [protected] |
Definition at line 228 of file TransformFactory.h.
Referenced by populateFeatureExtractionPlugins(), populateRealTimePlugins(), populateTransforms(), populateUninstalledTransforms(), and ~TransformFactory().
bool TransformFactory::m_populatingSlowly [protected] |
Definition at line 229 of file TransformFactory.h.
Referenced by getTransformInstallStatus(), getUninstalledTransformDescription(), getUninstalledTransformDescriptions(), TransformFactory::UninstalledTransformsPopulateThread::run(), and search().
TransformFactory * TransformFactory::m_instance = new TransformFactory [static, protected] |
Definition at line 231 of file TransformFactory.h.
Referenced by deleteInstance(), and getInstance().