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.

116 lines
2.9KB

  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. #include "../SpiralPlugin.h"
  19. #include <FL/Fl_Pixmap.H>
  20. #include "ladspa.h"
  21. #include "utils.h"
  22. #ifndef LADSPAPLUGIN
  23. #define LADSPAPLUGIN
  24. static const unsigned int NUM_PORTS = 8;
  25. class LPluginInfo {
  26. public:
  27. string Filename;
  28. string Label;
  29. string Name;
  30. string Maker;
  31. struct LPortDetails
  32. {
  33. string Name;
  34. float Min,Max;
  35. bool Clamped;
  36. };
  37. vector<LPortDetails> Ports;
  38. bool operator<(const LPluginInfo & li) { return (Name < li.Name); }
  39. bool operator==(const LPluginInfo& li) { return (Name == li.Name); }
  40. };
  41. // For sorting vectors of LPluginInfo's
  42. struct LPluginInfoSortAsc
  43. {
  44. bool operator()(const LPluginInfo & begin, const LPluginInfo & end)
  45. {
  46. return begin.Name < end.Name;
  47. }
  48. };
  49. class LADSPAPlugin : public SpiralPlugin
  50. {
  51. public:
  52. LADSPAPlugin();
  53. virtual ~LADSPAPlugin();
  54. virtual PluginInfo &Initialise(const HostInfo *Host);
  55. virtual SpiralGUIType *CreateGUI();
  56. virtual void Execute();
  57. virtual void ExecuteCommands();
  58. virtual void StreamOut(ostream &s);
  59. virtual void StreamIn(istream &s);
  60. float GetGain() { return m_Gain; }
  61. bool GetAmped() { return m_Amped; }
  62. enum GUICommands{NONE,SETMIN,SETMAX,SETCLAMP,UPDATEPLUGIN};
  63. struct GUIArgs
  64. {
  65. int Num;
  66. float Value;
  67. bool Clamp;
  68. char Filename[256];
  69. char Label[256];
  70. };
  71. private:
  72. GUIArgs m_GUIArgs;
  73. void SetMin(int n,float min) { m_PortMin[n]=min; }
  74. void SetMax(int n,float max) { m_PortMax[n]=max; }
  75. void SetPortClamp(int n,bool i) { m_PortClamp[n]=i; }
  76. bool UpdatePlugin(int n);
  77. bool UpdatePlugin(const char * filename, const char * label, bool PortClampReset=true);
  78. friend void describePluginLibrary(const char * pcFullFilename, void * pvPluginHandle, LADSPA_Descriptor_Function pfDescriptorFunction);
  79. void LoadPluginList(void);
  80. void * PlugHandle;
  81. const LADSPA_Descriptor * PlugDesc;
  82. vector<LADSPA_Data*> m_LADSPABufVec;
  83. LADSPA_Handle PlugInstHandle;
  84. vector<int> m_PortID;
  85. vector<float> m_PortMin;
  86. vector<float> m_PortMax;
  87. vector<bool> m_PortClamp;
  88. // our database of ladspa plugins
  89. vector<LPluginInfo> m_LADSPAList;
  90. LPluginInfo m_CurrentPlugin;
  91. float m_Gain;
  92. bool m_Amped;
  93. };
  94. #endif