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.

118 lines
3.2KB

  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. unsigned long InputPortCount;
  32. struct LPortDetails
  33. {
  34. string Name;
  35. float Min,Max;
  36. bool Clamped;
  37. };
  38. vector<LPortDetails> Ports;
  39. bool operator<(const LPluginInfo & li) { return (Name < li.Name); }
  40. bool operator==(const LPluginInfo& li) { return (Name == li.Name); }
  41. };
  42. // For sorting vectors of LPluginInfo's
  43. struct LPluginInfoSortAsc
  44. {
  45. bool operator()(const LPluginInfo & begin, const LPluginInfo & end)
  46. {
  47. return begin.Name < end.Name;
  48. }
  49. };
  50. class LADSPAPlugin : public SpiralPlugin
  51. {
  52. public:
  53. LADSPAPlugin();
  54. virtual ~LADSPAPlugin();
  55. virtual PluginInfo &Initialise(const HostInfo *Host);
  56. virtual SpiralGUIType *CreateGUI();
  57. virtual void Execute();
  58. virtual void ExecuteCommands();
  59. virtual void StreamOut(ostream &s);
  60. virtual void StreamIn(istream &s);
  61. float GetGain() { return m_Gain; }
  62. bool GetAmped() { return m_Amped; }
  63. enum GUICommands{NONE,UPDATERANGES,UPDATEPLUGIN};
  64. private:
  65. void UpdatePortRange(void);
  66. bool UpdatePlugin(int n);
  67. bool UpdatePlugin(const char * filename, const char * label, bool PortClampReset=true);
  68. friend void describePluginLibrary(const char * pcFullFilename, void * pvPluginHandle, LADSPA_Descriptor_Function pfDescriptorFunction);
  69. void LoadPluginList(void);
  70. void * PlugHandle;
  71. const LADSPA_Descriptor * PlugDesc;
  72. vector<LADSPA_Data*> m_LADSPABufVec;
  73. LADSPA_Handle PlugInstHandle;
  74. vector<int> m_PortID;
  75. vector<float> m_PortMin;
  76. vector<float> m_PortMax;
  77. vector<bool> m_PortClamp;
  78. // our database of ladspa plugins
  79. vector<LPluginInfo> m_LADSPAList;
  80. LPluginInfo m_CurrentPlugin;
  81. float m_Gain;
  82. bool m_Amped;
  83. unsigned long m_PluginIndex;
  84. char *m_Name;
  85. char *m_Maker;
  86. unsigned long m_InputPortCountMax; // Maximum number of input ports
  87. // Corresponds to input port count of one
  88. // (or more) plugins found
  89. unsigned long m_InputPortCount; // Number of input ports in current plugin
  90. float *m_InputPortMin; // Input port range minima
  91. float *m_InputPortMax; // Input port range maxima
  92. bool *m_InputPortClamp; // Input port clamp state
  93. char *m_InputPortNames; // Input port names
  94. };
  95. #endif