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.

148 lines
3.7KB

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