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