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.

182 lines
4.8KB

  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(std::ostream &s);
  54. virtual void StreamIn(std::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 GetPage() { return m_Page; }
  59. bool GetUpdateInputs() { return m_UpdateInputs; }
  60. unsigned long GetInputPortCount() { return m_InputPortCount; }
  61. unsigned long GetUnconnectedInputs() { return m_UnconnectedInputs; }
  62. const char *GetInputPortName(unsigned long p)
  63. {
  64. return (const char *)(m_OutData.InputPortNames + p * 256);
  65. }
  66. PortSetting GetInputPortSetting(unsigned long p)
  67. {
  68. return m_OutData.InputPortSettings[p];
  69. }
  70. float GetInputPortDefault(unsigned long p)
  71. {
  72. return m_OutData.InputPortDefaults[p];
  73. }
  74. PortValue GetInputPortValue(unsigned long p)
  75. {
  76. return m_OutData.InputPortValues[p];
  77. }
  78. enum GUICommands
  79. {
  80. NONE,
  81. SETPAGE,
  82. SELECTPLUGIN,
  83. CLEARPLUGIN,
  84. SETUPDATEINPUTS,
  85. SETDEFAULT,
  86. SETMIN,
  87. SETMAX,
  88. SETCLAMP
  89. };
  90. private:
  91. bool UpdatePlugin(unsigned long UniqueID);
  92. bool SelectPlugin(unsigned long UniqueID);
  93. void ClearPlugin(void);
  94. void ResetPortSettings(void);
  95. void SetGUIExports(void);
  96. const LADSPA_Descriptor *m_PlugDesc;
  97. std::vector<LADSPA_Data*> m_LADSPABufVec;
  98. LADSPA_Handle m_PlugInstHandle;
  99. std::vector<int> m_PortID;
  100. std::vector<float> m_InputPortMin;
  101. std::vector<float> m_InputPortMax;
  102. std::vector<bool> m_InputPortClamp;
  103. std::vector<float> m_InputPortDefault;
  104. int m_Version;
  105. // our database of ladspa plugins
  106. LADSPAInfo *m_LADSPAInfo;
  107. unsigned long m_PluginIndex;
  108. unsigned long m_UniqueID;
  109. int m_Page;
  110. bool m_UpdateInputs;
  111. unsigned long m_MaxInputPortCount;
  112. unsigned long m_InputPortCount;
  113. char m_Name[256];
  114. char m_Maker[256];
  115. // This is stored in the patch file, and retreived by the GUI
  116. // on patch load, since we won't know this until the whole patch
  117. // is loaded and connected.
  118. unsigned long m_UnconnectedInputs;
  119. // Data sent to GUI
  120. struct OutputChannelData
  121. {
  122. char *InputPortNames;
  123. PortSetting *InputPortSettings;
  124. PortValue *InputPortValues;
  125. float *InputPortDefaults;
  126. };
  127. // Data received from GUI
  128. struct InputChannelData
  129. {
  130. unsigned long UniqueID;
  131. int Page;
  132. bool UpdateInputs;
  133. unsigned long InputPortIndex;
  134. float InputPortDefault;
  135. float InputPortMin;
  136. float InputPortMax;
  137. bool InputPortClamp;
  138. };
  139. OutputChannelData m_OutData;
  140. InputChannelData m_InData;
  141. #ifdef USE_POSIX_SHM
  142. // SHM stuff - for sharing the LADSPA Plugin database
  143. // The actual paths are combined with the Process ID for the current SSM audio thread
  144. // to allow multiple instances of SSM to run, and to avoid picking up stale SHMs
  145. // from crashed instances.
  146. static const char * const m_SHMPath = "/SSM-LADSPAPlugin-";
  147. static const char * const m_SHMPathRC = "-RefCount";
  148. static const char * const m_SHMPathDB = "-Database";
  149. char *m_SHMRefCountPath;
  150. char *m_SHMDatabasePath;
  151. pid_t *m_SHMPID;
  152. unsigned long *m_SHMRefCount;
  153. LADSPAInfo **m_SHMDatabase;
  154. #endif
  155. };
  156. #endif // __ladspa_plugin_h__