DummyEffect.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. * DummyEffect.h - effect used as fallback if an effect couldn't be loaded
  3. *
  4. * Copyright (c) 2006-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
  5. *
  6. * This file is part of LMMS - https://lmms.io
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2 of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public
  19. * License along with this program (see COPYING); if not, write to the
  20. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  21. * Boston, MA 02110-1301 USA.
  22. *
  23. */
  24. #ifndef DUMMY_EFFECT_H
  25. #define DUMMY_EFFECT_H
  26. #include "Effect.h"
  27. #include "EffectControls.h"
  28. #include "EffectControlDialog.h"
  29. class DummyEffectControlDialog : public EffectControlDialog
  30. {
  31. public:
  32. DummyEffectControlDialog( EffectControls * _controls ) :
  33. EffectControlDialog( _controls )
  34. {
  35. }
  36. } ;
  37. class DummyEffectControls : public EffectControls
  38. {
  39. public:
  40. DummyEffectControls( Effect * _eff ) :
  41. EffectControls( _eff )
  42. {
  43. }
  44. virtual ~DummyEffectControls()
  45. {
  46. }
  47. int controlCount() override
  48. {
  49. return 0;
  50. }
  51. void saveSettings( QDomDocument &, QDomElement & ) override
  52. {
  53. }
  54. void loadSettings( const QDomElement & ) override
  55. {
  56. }
  57. QString nodeName() const override
  58. {
  59. return "DummyControls";
  60. }
  61. EffectControlDialog * createView() override
  62. {
  63. return new DummyEffectControlDialog( this );
  64. }
  65. } ;
  66. class DummyEffect : public Effect
  67. {
  68. Q_OBJECT
  69. public:
  70. DummyEffect( Model * _parent, const QDomElement& originalPluginData ) :
  71. Effect( nullptr, _parent, nullptr ),
  72. m_controls( this ),
  73. m_originalPluginData( originalPluginData )
  74. {
  75. setName();
  76. }
  77. virtual ~DummyEffect()
  78. {
  79. }
  80. EffectControls * controls() override
  81. {
  82. return &m_controls;
  83. }
  84. bool processAudioBuffer( sampleFrame *, const fpp_t ) override
  85. {
  86. return false;
  87. }
  88. const QDomElement& originalPluginData() const
  89. {
  90. return m_originalPluginData;
  91. }
  92. private:
  93. DummyEffectControls m_controls;
  94. const QDomElement m_originalPluginData;
  95. // Parse the display name from the dom
  96. virtual void setName()
  97. {
  98. QDomNodeList keys = originalPluginData().elementsByTagName( "key" );
  99. for( int i = 0; !keys.item( i ).isNull(); ++i )
  100. {
  101. QDomNodeList attributes = keys.item( i ).toElement().elementsByTagName( "attribute" );
  102. for( int j = 0; !attributes.item( j ).isNull(); ++j )
  103. {
  104. QDomElement attribute = attributes.item( j ).toElement();
  105. if( attribute.hasAttribute( "value" ) )
  106. {
  107. QString name = tr("NOT FOUND") + " (" + attribute.attribute( "value" ) + ")";
  108. setDisplayName(name);
  109. return;
  110. }
  111. }
  112. }
  113. }
  114. } ;
  115. #endif