25#if defined(H2CORE_HAVE_LADSPA) || _DOXYGEN_
38#ifdef H2CORE_HAVE_LRDF
49 : m_pRootGroup( nullptr )
50 , m_pRecentGroup( nullptr )
54 for (
int nFX = 0; nFX <
MAX_FX; ++nFX ) {
84 for (
int nFX = 0; nFX <
MAX_FX; ++nFX ) {
114 if ( pFX !=
nullptr ) {
138 INFOLOG(
"*** [getPluginList] reading directory: " + sPluginDir );
140 QDir dir( sPluginDir );
141 if ( !dir.exists() ) {
142 INFOLOG(
"Directory " + sPluginDir +
" not found" );
146 QFileInfoList list = dir.entryInfoList();
147 for (
int i = 0; i < list.size(); ++i ) {
148 QString sPluginName = list.at( i ).fileName();
150 if ( ( sPluginName ==
"." ) || ( sPluginName ==
".." ) ) {
156 int pos = sPluginName.indexOf(
".dll" );
159 int pos = sPluginName.indexOf(
".dylib" );
161 int pos = sPluginName.indexOf(
".so" );
169 QString sAbsPath = QString(
"%1/%2" ).arg( sPluginDir ).arg( sPluginName );
171 QLibrary lib( sAbsPath );
172 LADSPA_Descriptor_Function desc_func = ( LADSPA_Descriptor_Function )lib.resolve(
"ladspa_descriptor" );
173 if ( desc_func ==
nullptr ) {
174 ERRORLOG(
"Error loading the library. (" + sAbsPath +
")" );
177 const LADSPA_Descriptor * d;
179 for (
unsigned i = 0; ( d = desc_func ( i ) ) !=
nullptr; i++ ) {
182 pFX->
m_sLabel = QString::fromLocal8Bit(d->Label);
183 pFX->
m_sID = QString::number(d->UniqueID);
184 pFX->
m_sMaker = QString::fromLocal8Bit(d->Maker);
185 pFX->
m_sCopyright = QString::fromLocal8Bit(d->Copyright);
189 for (
unsigned j = 0; j < d->PortCount; j++ ) {
190 LADSPA_PortDescriptor pd = d->PortDescriptors[j];
191 if ( LADSPA_IS_PORT_INPUT( pd ) && LADSPA_IS_PORT_CONTROL( pd ) ) {
193 }
else if ( LADSPA_IS_PORT_INPUT( pd ) && LADSPA_IS_PORT_AUDIO( pd ) ) {
195 }
else if ( LADSPA_IS_PORT_OUTPUT( pd ) && LADSPA_IS_PORT_CONTROL( pd ) ) {
197 }
else if ( LADSPA_IS_PORT_OUTPUT( pd ) && LADSPA_IS_PORT_AUDIO( pd ) ) {
202 ERRORLOG( QString(
"%1::%2 unknown port type" ).arg( pFX->
m_sLabel ).arg( sPortName ) );
215 ERRORLOG(
"Error loading: " + sPluginName );
229 INFOLOG(
"[getLadspaFXGroup]" );
250 char ch = (*i)->
m_sName.toLocal8Bit().at(0);
254 pUncategorizedGroup->
addChild( pGroup );
263#ifdef H2CORE_HAVE_LRDF
284 if ( sRecent == (*i)->m_sName ) {
293#ifdef H2CORE_HAVE_LRDF
300 QString sDir =
"/usr/share/ladspa/rdf";
303 if ( !dir.exists() ) {
304 WARNINGLOG( QString(
"Directory %1 not found" ).arg( sDir ) );
308 QFileInfoList list = dir.entryInfoList();
309 for (
int i = 0; i < list.size(); ++i ) {
310 QString sFilename = list.at( i ).fileName();
311 int pos = sFilename.indexOf(
".rdf" );
316 QString sRDFFile = QString(
"file://%1/%2" ).arg( sDir ).arg( sFilename );
318 int err = lrdf_read_file( sRDFFile.toLocal8Bit() );
320 ERRORLOG(
"Error parsing rdf file " + sFilename );
323 QString sBase =
"http://ladspa.org/ontology#Plugin";
331void Effects::RDFDescend(
const QString& sBase, LadspaFXGroup *pGroup, std::vector<LadspaFXInfo*> pluginList )
335 lrdf_uris* uris = lrdf_get_subclasses( sBase.toLocal8Bit() );
337 for (
int i = 0; i < ( int )uris->count; i++ ) {
338 QString sGroup = QString::fromLocal8Bit(lrdf_get_label( uris->items[ i ] ));
340 LadspaFXGroup *pNewGroup =
nullptr;
342 std::vector<LadspaFXGroup*> childGroups = pGroup-> getChildList();
343 for (
unsigned nGroup = 0; nGroup < childGroups.size(); nGroup++ ) {
344 LadspaFXGroup *pOldGroup = childGroups[nGroup];
345 if ( pOldGroup->getName() == sGroup ) {
346 pNewGroup = pOldGroup;
350 if ( pNewGroup ==
nullptr ) {
351 pNewGroup =
new LadspaFXGroup( sGroup );
352 pGroup->addChild( pNewGroup );
354 RDFDescend( QString::fromLocal8Bit(uris->items[i]), pNewGroup, pluginList );
356 lrdf_free_uris ( uris );
359 uris = lrdf_get_instances( sBase.toLocal8Bit() );
361 for (
int i = 0; i < ( int )uris->count; i++ ) {
362 int uid = lrdf_get_uid ( uris->items[i] );
365 bool bExists =
false;
366 std::vector<LadspaFXInfo*> fxVect = pGroup->getLadspaInfo();
367 for (
unsigned nFX = 0; nFX < fxVect.size(); nFX++ ) {
368 LadspaFXInfo *pFX = fxVect[nFX];
369 if ( pFX->m_sID.toInt() == uid ) {
375 if ( bExists ==
false ) {
377 for (
unsigned i = 0; i < pluginList.size(); i++ ) {
378 LadspaFXInfo *pInfo = pluginList[i];
380 if ( pInfo->m_sID.toInt() == uid ) {
381 pGroup->addLadspaInfo( pInfo );
386 lrdf_free_uris ( uris );
#define RIGHT_HERE
Macro intended to be used for the logging of the locking of the H2Core::AudioEngine.
void unlock()
Mutex unlocking of the AudioEngine.
void lock(const char *file, unsigned int line, const char *function)
Mutex locking of the AudioEngine.
std::vector< LadspaFXInfo * > m_pluginList
LadspaFXGroup * m_pRecentGroup
LadspaFXGroup * getLadspaFXGroup()
std::vector< LadspaFXInfo * > getPluginList()
Loads only usable plugins.
LadspaFXGroup * m_pRootGroup
static void create_instance()
If __instance equals 0, a new Effects singleton will be created and stored in it.
void setLadspaFX(LadspaFX *pFX, int nFX)
LadspaFX * getLadspaFX(int nFX) const
void RDFDescend(const QString &sBase, LadspaFXGroup *pGroup, std::vector< LadspaFXInfo * > pluginList)
static Effects * __instance
Object holding the current Effects singleton.
void getRDF(LadspaFXGroup *pGroup, std::vector< LadspaFXInfo * > pluginList)
LadspaFX * m_FXList[MAX_FX]
static QStringList ladspa_paths()
returns user ladspa paths
static Hydrogen * get_instance()
Returns the current Hydrogen instance __instance.
AudioEngine * getAudioEngine() const
void setIsModified(bool bIsModified)
Wrapper around Song::setIsModified() that checks whether a song is set.
void addChild(LadspaFXGroup *pChild)
void addLadspaInfo(LadspaFXInfo *pInfo)
QString m_sFilename
plugin filename
unsigned m_nIAPorts
input audio port
unsigned m_nOAPorts
output audio port
static bool alphabeticOrder(LadspaFXInfo *a, LadspaFXInfo *b)
unsigned m_nICPorts
input control port
unsigned m_nOCPorts
output control port
const QString & getPluginName() const
static Preferences * get_instance()
Returns a pointer to the current Preferences singleton stored in __instance.
void setMostRecentFX(QString)
#define MAX_FX
Maximum number of effects.