VstPlugin.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. * VstPlugin.h - declaration of VstPlugin class
  3. *
  4. * Copyright (c) 2005-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 _VST_PLUGIN_H
  25. #define _VST_PLUGIN_H
  26. #include <QMap>
  27. #include <QMutex>
  28. #include <QPointer>
  29. #include <QString>
  30. #include <QTimer>
  31. #include <QWidget>
  32. #include "JournallingObject.h"
  33. #include "RemotePlugin.h"
  34. #include "vstbase_export.h"
  35. class vstSubWin;
  36. class VSTBASE_EXPORT VstPlugin : public RemotePlugin, public JournallingObject
  37. {
  38. Q_OBJECT
  39. public:
  40. VstPlugin( const QString & _plugin );
  41. virtual ~VstPlugin();
  42. void tryLoad( const QString &remoteVstPluginExecutable );
  43. bool processMessage( const message & _m ) override;
  44. inline bool hasEditor() const
  45. {
  46. return m_pluginWindowID != 0;
  47. }
  48. /// Same as pluginWidget(), but can be overwritten in sub-classes to modify
  49. /// behavior the UI. This is used in VstInstrumentPlugin to wrap the VST UI
  50. /// in a QMdiSubWindow
  51. virtual QWidget* editor();
  52. inline const QString & name() const
  53. {
  54. return m_name;
  55. }
  56. inline int version() const
  57. {
  58. return m_version;
  59. }
  60. inline const QString & vendorString() const
  61. {
  62. return m_vendorString;
  63. }
  64. inline const QString & productString() const
  65. {
  66. return m_productString;
  67. }
  68. inline const QString& currentProgramName() const
  69. {
  70. return m_currentProgramName;
  71. }
  72. inline const QString& allProgramNames() const
  73. {
  74. return m_allProgramNames;
  75. }
  76. int currentProgram();
  77. const QMap<QString, QString> & parameterDump();
  78. void setParameterDump( const QMap<QString, QString> & _pdump );
  79. QWidget * pluginWidget();
  80. void loadSettings( const QDomElement & _this ) override;
  81. void saveSettings( QDomDocument & _doc, QDomElement & _this ) override;
  82. virtual QString nodeName() const override
  83. {
  84. return "vstplugin";
  85. }
  86. virtual void createUI(QWidget *parent);
  87. bool eventFilter(QObject *obj, QEvent *event) override;
  88. QString embedMethod() const;
  89. public slots:
  90. void setTempo( bpm_t _bpm );
  91. void updateSampleRate();
  92. void openPreset( void );
  93. void setProgram( int index );
  94. void rotateProgram( int offset );
  95. void loadProgramNames();
  96. void savePreset( void );
  97. void setParam( int i, float f );
  98. void idleUpdate();
  99. void showUI() override;
  100. void hideUI() override;
  101. void toggleUI() override;
  102. void handleClientEmbed();
  103. private:
  104. void loadChunk( const QByteArray & _chunk );
  105. QByteArray saveChunk();
  106. void toggleEditorVisibility(int visible = -1);
  107. QString m_plugin;
  108. QPointer<QWidget> m_pluginWidget;
  109. int m_pluginWindowID;
  110. QSize m_pluginGeometry;
  111. const QString m_embedMethod;
  112. QString m_name;
  113. int m_version;
  114. QString m_vendorString;
  115. QString m_productString;
  116. QString m_currentProgramName;
  117. QString m_allProgramNames;
  118. QString p_name;
  119. QMap<QString, QString> m_parameterDump;
  120. int m_currentProgram;
  121. QTimer m_idleTimer;
  122. } ;
  123. #endif