VstPlugin.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. inline const QString& allParameterLabels() const
  77. {
  78. return m_allParameterLabels;
  79. }
  80. inline const QString& allParameterDisplays() const
  81. {
  82. return m_allParameterDisplays;
  83. }
  84. int currentProgram();
  85. const QMap<QString, QString> & parameterDump();
  86. void setParameterDump( const QMap<QString, QString> & _pdump );
  87. QWidget * pluginWidget();
  88. void loadSettings( const QDomElement & _this ) override;
  89. void saveSettings( QDomDocument & _doc, QDomElement & _this ) override;
  90. virtual QString nodeName() const override
  91. {
  92. return "vstplugin";
  93. }
  94. virtual void createUI(QWidget *parent);
  95. bool eventFilter(QObject *obj, QEvent *event) override;
  96. QString embedMethod() const;
  97. public slots:
  98. void setTempo( bpm_t _bpm );
  99. void updateSampleRate();
  100. void openPreset( void );
  101. void setProgram( int index );
  102. void rotateProgram( int offset );
  103. void loadProgramNames();
  104. void loadParameterLabels();
  105. void loadParameterDisplays();
  106. void savePreset( void );
  107. void setParam( int i, float f );
  108. void idleUpdate();
  109. void showUI() override;
  110. void hideUI() override;
  111. void toggleUI() override;
  112. void handleClientEmbed();
  113. private:
  114. void loadChunk( const QByteArray & _chunk );
  115. QByteArray saveChunk();
  116. void toggleEditorVisibility(int visible = -1);
  117. QString m_plugin;
  118. QPointer<QWidget> m_pluginWidget;
  119. int m_pluginWindowID;
  120. QSize m_pluginGeometry;
  121. const QString m_embedMethod;
  122. QString m_name;
  123. int m_version;
  124. QString m_vendorString;
  125. QString m_productString;
  126. QString m_currentProgramName;
  127. QString m_allProgramNames;
  128. QString m_allParameterLabels;
  129. QString m_allParameterDisplays;
  130. QString p_name;
  131. QMap<QString, QString> m_parameterDump;
  132. int m_currentProgram;
  133. QTimer m_idleTimer;
  134. } ;
  135. #endif