LadspaSubPluginFeatures.cpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. * LadspaSubPluginFeatures.cpp - derivation from
  3. * Plugin::Descriptor::SubPluginFeatures for
  4. * hosting LADSPA-plugins
  5. *
  6. * Copyright (c) 2006-2007 Danny McRae <khjklujn/at/users.sourceforge.net>
  7. * Copyright (c) 2006-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
  8. *
  9. * This file is part of LMMS - https://lmms.io
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public
  13. * License as published by the Free Software Foundation; either
  14. * version 2 of the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public
  22. * License along with this program (see COPYING); if not, write to the
  23. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  24. * Boston, MA 02110-1301 USA.
  25. *
  26. */
  27. #include <QHBoxLayout>
  28. #include <QLabel>
  29. #include "LadspaSubPluginFeatures.h"
  30. #include "AudioDevice.h"
  31. #include "AudioEngine.h"
  32. #include "Engine.h"
  33. #include "Ladspa2LMMS.h"
  34. #include "LadspaBase.h"
  35. LadspaSubPluginFeatures::LadspaSubPluginFeatures( Plugin::PluginTypes _type ) :
  36. SubPluginFeatures( _type )
  37. {
  38. }
  39. QString LadspaSubPluginFeatures::displayName(const Plugin::Descriptor::SubPluginFeatures::Key &k) const
  40. {
  41. const ladspa_key_t & lkey = subPluginKeyToLadspaKey(&k);
  42. Ladspa2LMMS * lm = Engine::getLADSPAManager();
  43. return lm->getName(lkey);
  44. }
  45. void LadspaSubPluginFeatures::fillDescriptionWidget( QWidget * _parent,
  46. const Key * _key ) const
  47. {
  48. const ladspa_key_t & lkey = subPluginKeyToLadspaKey( _key );
  49. Ladspa2LMMS * lm = Engine::getLADSPAManager();
  50. QLabel * label = new QLabel( _parent );
  51. label->setText( QWidget::tr( "Name: " ) + lm->getName( lkey ) );
  52. QLabel* fileInfo = new QLabel( _parent );
  53. fileInfo->setText( QWidget::tr( "File: %1" ).arg( lkey.first ) );
  54. QWidget * maker = new QWidget( _parent );
  55. QHBoxLayout * l = new QHBoxLayout( maker );
  56. l->setMargin( 0 );
  57. l->setSpacing( 0 );
  58. QLabel * maker_label = new QLabel( maker );
  59. maker_label->setText( QWidget::tr( "Maker: " ) );
  60. maker_label->setAlignment( Qt::AlignTop );
  61. QLabel * maker_content = new QLabel( maker );
  62. maker_content->setText( lm->getMaker( lkey ) );
  63. maker_content->setWordWrap( true );
  64. l->addWidget( maker_label );
  65. l->addWidget( maker_content, 1 );
  66. QWidget * copyright = new QWidget( _parent );
  67. l = new QHBoxLayout( copyright );
  68. l->setMargin( 0 );
  69. l->setSpacing( 0 );
  70. copyright->setMinimumWidth( _parent->minimumWidth() );
  71. QLabel * copyright_label = new QLabel( copyright );
  72. copyright_label->setText( QWidget::tr( "Copyright: " ) );
  73. copyright_label->setAlignment( Qt::AlignTop );
  74. QLabel * copyright_content = new QLabel( copyright );
  75. copyright_content->setText( lm->getCopyright( lkey ) );
  76. copyright_content->setWordWrap( true );
  77. l->addWidget( copyright_label );
  78. l->addWidget( copyright_content, 1 );
  79. QLabel * requiresRealTime = new QLabel( _parent );
  80. requiresRealTime->setText( QWidget::tr( "Requires Real Time: " ) +
  81. ( lm->hasRealTimeDependency( lkey ) ?
  82. QWidget::tr( "Yes" ) :
  83. QWidget::tr( "No" ) ) );
  84. QLabel * realTimeCapable = new QLabel( _parent );
  85. realTimeCapable->setText( QWidget::tr( "Real Time Capable: " ) +
  86. ( lm->isRealTimeCapable( lkey ) ?
  87. QWidget::tr( "Yes" ) :
  88. QWidget::tr( "No" ) ) );
  89. QLabel * inplaceBroken = new QLabel( _parent );
  90. inplaceBroken->setText( QWidget::tr( "In Place Broken: " ) +
  91. ( lm->isInplaceBroken( lkey ) ?
  92. QWidget::tr( "Yes" ) :
  93. QWidget::tr( "No" ) ) );
  94. QLabel * channelsIn = new QLabel( _parent );
  95. channelsIn->setText( QWidget::tr( "Channels In: " ) +
  96. QString::number( lm->getDescription( lkey )->inputChannels ) );
  97. QLabel * channelsOut = new QLabel( _parent );
  98. channelsOut->setText( QWidget::tr( "Channels Out: " ) +
  99. QString::number( lm->getDescription( lkey )->outputChannels ) );
  100. }
  101. void LadspaSubPluginFeatures::listSubPluginKeys(
  102. const Plugin::Descriptor * _desc, KeyList & _kl ) const
  103. {
  104. Ladspa2LMMS * lm = Engine::getLADSPAManager();
  105. l_sortable_plugin_t plugins;
  106. switch( m_type )
  107. {
  108. case Plugin::Instrument:
  109. plugins = lm->getInstruments();
  110. break;
  111. case Plugin::Effect:
  112. plugins = lm->getValidEffects();
  113. //plugins += lm->getInvalidEffects();
  114. break;
  115. case Plugin::Tool:
  116. plugins = lm->getAnalysisTools();
  117. break;
  118. case Plugin::Other:
  119. plugins = lm->getOthers();
  120. break;
  121. default:
  122. break;
  123. }
  124. for( l_sortable_plugin_t::const_iterator it = plugins.begin();
  125. it != plugins.end(); ++it )
  126. {
  127. if( lm->getDescription( ( *it ).second )->inputChannels <= Engine::audioEngine()->audioDev()->channels() )
  128. {
  129. _kl.push_back( ladspaKeyToSubPluginKey( _desc, ( *it ).first, ( *it ).second ) );
  130. }
  131. }
  132. }
  133. ladspa_key_t LadspaSubPluginFeatures::subPluginKeyToLadspaKey(
  134. const Key * _key )
  135. {
  136. QString file = _key->attributes["file"];
  137. return( ladspa_key_t( file.remove( QRegExp( "\\.so$" ) ).
  138. remove( QRegExp( "\\.dll$" ) ) +
  139. #ifdef LMMS_BUILD_WIN32
  140. ".dll"
  141. #else
  142. ".so"
  143. #endif
  144. , _key->attributes["plugin"] ) );
  145. }