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.

160 lines
4.1KB

  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. struct PortSetting
  28. {
  29. float Min;
  30. float Max;
  31. bool Clamp;
  32. float LogBase; // >1.0 -> Logarithmic, otherwise linear
  33. bool Integer;
  34. };
  35. struct PortValue
  36. {
  37. float Value;
  38. bool Connected;
  39. };
  40. class LADSPAPlugin : public SpiralPlugin
  41. {
  42. public:
  43. LADSPAPlugin();
  44. virtual ~LADSPAPlugin();
  45. virtual PluginInfo &Initialise(const HostInfo *Host);
  46. virtual SpiralGUIType *CreateGUI();
  47. virtual void Execute();
  48. virtual void ExecuteCommands();
  49. virtual void StreamOut(std::ostream &s);
  50. virtual void StreamIn(std::istream &s);
  51. unsigned long GetUniqueID() { return m_UniqueID; }
  52. const char *GetName() { return (const char *)m_Name; }
  53. const char *GetMaker() { return (const char *)m_Maker; }
  54. int GetPage() { return m_Page; }
  55. bool GetUpdateInputs() { return m_UpdateInputs; }
  56. unsigned long GetInputPortCount() { return m_InputPortCount; }
  57. unsigned long GetUnconnectedInputs() { return m_UnconnectedInputs; }
  58. const char *GetInputPortName(unsigned long p)
  59. {
  60. return (const char *)(m_OutData.InputPortNames + p * 256);
  61. }
  62. PortSetting GetInputPortSetting(unsigned long p)
  63. {
  64. return m_OutData.InputPortSettings[p];
  65. }
  66. float GetInputPortDefault(unsigned long p)
  67. {
  68. return m_OutData.InputPortDefaults[p];
  69. }
  70. PortValue GetInputPortValue(unsigned long p)
  71. {
  72. return m_OutData.InputPortValues[p];
  73. }
  74. enum GUICommands
  75. {
  76. NONE,
  77. SETPAGE,
  78. SELECTPLUGIN,
  79. CLEARPLUGIN,
  80. SETUPDATEINPUTS,
  81. SETDEFAULT,
  82. SETMIN,
  83. SETMAX,
  84. SETCLAMP
  85. };
  86. private:
  87. bool UpdatePlugin(unsigned long UniqueID);
  88. bool SelectPlugin(unsigned long UniqueID);
  89. void ClearPlugin(void);
  90. void ResetPortSettings(void);
  91. void SetGUIExports(void);
  92. const LADSPA_Descriptor *m_PlugDesc;
  93. std::vector<LADSPA_Data*> m_LADSPABufVec;
  94. LADSPA_Handle m_PlugInstHandle;
  95. std::vector<int> m_PortID;
  96. std::vector<float> m_InputPortMin;
  97. std::vector<float> m_InputPortMax;
  98. std::vector<bool> m_InputPortClamp;
  99. std::vector<float> m_InputPortDefault;
  100. int m_Version;
  101. static LADSPAInfo *m_LADSPAInfo;
  102. static int InstanceCount;
  103. unsigned long m_PluginIndex;
  104. unsigned long m_UniqueID;
  105. int m_Page;
  106. bool m_UpdateInputs;
  107. unsigned long m_MaxInputPortCount;
  108. unsigned long m_InputPortCount;
  109. char m_Name[256];
  110. char m_Maker[256];
  111. // This is stored in the patch file, and retreived by the GUI
  112. // on patch load, since we won't know this until the whole patch
  113. // is loaded and connected.
  114. unsigned long m_UnconnectedInputs;
  115. // Data sent to GUI
  116. struct OutputChannelData
  117. {
  118. char *InputPortNames;
  119. PortSetting *InputPortSettings;
  120. PortValue *InputPortValues;
  121. float *InputPortDefaults;
  122. };
  123. // Data received from GUI
  124. struct InputChannelData
  125. {
  126. unsigned long UniqueID;
  127. int Page;
  128. bool UpdateInputs;
  129. unsigned long InputPortIndex;
  130. float InputPortDefault;
  131. float InputPortMin;
  132. float InputPortMax;
  133. bool InputPortClamp;
  134. };
  135. OutputChannelData m_OutData;
  136. InputChannelData m_InData;
  137. };
  138. #endif // __ladspa_plugin_h__