You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

164 lines
4.2KB

  1. /* LADSPAPlugin.h
  2. * Copyleft (C) 2001 David Griffiths <dave@pawfal.org>
  3. * LADSPA Plugin by Nicolas Noble <nicolas@nobis-crew.org>
  4. * Modified by Mike Rawes <myk@waxfrenzy.org>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. */
  20. #ifndef __ladspa_plugin_h__
  21. #define __ladspa_plugin_h__
  22. #include <config.h>
  23. #include <FL/Fl_Pixmap.H>
  24. #include <ladspa.h>
  25. #include "../SpiralPlugin.h"
  26. #include "LADSPAInfo.h"
  27. #ifdef USE_POSIX_SHM
  28. #include <sys/types.h> // For pid_t data member
  29. #include <unistd.h>
  30. #endif
  31. struct PortSetting
  32. {
  33. float Min;
  34. float Max;
  35. bool Clamp;
  36. float LogBase; // >1.0 -> Logarithmic, otherwise linear
  37. bool Integer;
  38. };
  39. struct PortValue
  40. {
  41. float Value;
  42. bool Connected;
  43. };
  44. class LADSPAPlugin : public SpiralPlugin
  45. {
  46. public:
  47. LADSPAPlugin();
  48. virtual ~LADSPAPlugin();
  49. virtual PluginInfo &Initialise(const HostInfo *Host);
  50. virtual SpiralGUIType *CreateGUI();
  51. virtual void Execute();
  52. virtual void ExecuteCommands();
  53. virtual void StreamOut(ostream &s);
  54. virtual void StreamIn(istream &s);
  55. unsigned long GetUniqueID() { return m_UniqueID; }
  56. const char *GetName() { return (const char *)m_Name; }
  57. const char *GetMaker() { return (const char *)m_Maker; }
  58. int GetTabIndex() { return m_TabIndex; }
  59. bool GetUpdateInputs() { return m_UpdateInputs; }
  60. unsigned long GetInputPortCount() { return m_InputPortCount; }
  61. const char *GetInputPortName(unsigned long p)
  62. {
  63. return (const char *)(m_OutData.InputPortNames + p * 256);
  64. }
  65. PortSetting GetInputPortSetting(unsigned long p)
  66. {
  67. return m_OutData.InputPortSettings[p];
  68. }
  69. float GetInputPortDefault(unsigned long p)
  70. {
  71. return m_OutData.InputPortDefaults[p];
  72. }
  73. enum GUICommands
  74. {
  75. NONE,
  76. SETTABINDEX,
  77. SELECTPLUGIN,
  78. CLEARPLUGIN,
  79. SETUPDATEINPUTS,
  80. SETDEFAULT,
  81. SETMIN,
  82. SETMAX,
  83. SETCLAMP
  84. };
  85. private:
  86. bool UpdatePlugin(unsigned long UniqueID);
  87. bool SelectPlugin(unsigned long UniqueID);
  88. void ClearPlugin(void);
  89. void ResetPortSettings(void);
  90. void SetGUIExports(void);
  91. const LADSPA_Descriptor *m_PlugDesc;
  92. vector<LADSPA_Data*> m_LADSPABufVec;
  93. LADSPA_Handle m_PlugInstHandle;
  94. vector<int> m_PortID;
  95. vector<float> m_InputPortMin;
  96. vector<float> m_InputPortMax;
  97. vector<bool> m_InputPortClamp;
  98. vector<float> m_InputPortDefault;
  99. int m_Version;
  100. // our database of ladspa plugins
  101. LADSPAInfo *m_LADSPAInfo;
  102. unsigned long m_PluginIndex;
  103. unsigned long m_UniqueID;
  104. int m_TabIndex;
  105. bool m_UpdateInputs;
  106. unsigned long m_MaxInputPortCount;
  107. unsigned long m_InputPortCount;
  108. char m_Name[256];
  109. char m_Maker[256];
  110. // Data sent to GUI
  111. struct OutputChannelData
  112. {
  113. char *InputPortNames;
  114. PortSetting *InputPortSettings;
  115. PortValue *InputPortValues;
  116. float *InputPortDefaults;
  117. };
  118. // Data received from GUI
  119. struct InputChannelData
  120. {
  121. unsigned long UniqueID;
  122. int TabIndex;
  123. bool UpdateInputs;
  124. unsigned long InputPortIndex;
  125. float InputPortDefault;
  126. float InputPortMin;
  127. float InputPortMax;
  128. bool InputPortClamp;
  129. };
  130. OutputChannelData m_OutData;
  131. InputChannelData m_InData;
  132. #ifdef USE_POSIX_SHM
  133. // SHM stuff - for sharing the LADSPA Plugin database
  134. static const char * const m_SHMRefCountPath = "/SpiralSynthModular-LADSPAPlugin-RefCount";
  135. static const char * const m_SHMLDBPath = "/SpiralSynthModular-LADSPAPlugin-Database";
  136. unsigned long *m_SHMRefCount;
  137. LADSPAInfo **m_SHMLDB;
  138. #endif
  139. };
  140. #endif // __ladspa_plugin_h__