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.

114 lines
2.4KB

  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 <math.h>
  19. #include "AmpPlugin.h"
  20. #include "AmpPluginGUI.h"
  21. #include <FL/Fl_Button.h>
  22. #include "SpiralIcon.xpm"
  23. #define PI 3.141592654
  24. using namespace std;
  25. extern "C" {
  26. SpiralPlugin* SpiralPlugin_CreateInstance()
  27. {
  28. return new AmpPlugin;
  29. }
  30. char** SpiralPlugin_GetIcon()
  31. {
  32. return SpiralIcon_xpm;
  33. }
  34. int SpiralPlugin_GetID()
  35. {
  36. return 0x0009;
  37. }
  38. string SpiralPlugin_GetGroupName()
  39. {
  40. return "Amps/Mixers";
  41. }
  42. }
  43. ///////////////////////////////////////////////////////
  44. AmpPlugin::AmpPlugin() :
  45. m_Gain(1.0f),
  46. m_DC(0.0f)
  47. {
  48. m_PluginInfo.Name="Amp";
  49. m_PluginInfo.Width = 120;
  50. m_PluginInfo.Height = 140;
  51. m_PluginInfo.NumInputs=3;
  52. m_PluginInfo.NumOutputs=1;
  53. m_PluginInfo.PortTips.push_back("Input");
  54. m_PluginInfo.PortTips.push_back("Gain CV");
  55. m_PluginInfo.PortTips.push_back("DC Offset CV");
  56. m_PluginInfo.PortTips.push_back("Output");
  57. m_AudioCH->Register("Gain",&m_Gain);
  58. m_AudioCH->Register("DC",&m_DC);
  59. }
  60. AmpPlugin::~AmpPlugin()
  61. {
  62. }
  63. PluginInfo &AmpPlugin::Initialise(const HostInfo *Host)
  64. {
  65. return SpiralPlugin::Initialise(Host);
  66. }
  67. SpiralGUIType *AmpPlugin::CreateGUI()
  68. {
  69. return new AmpPluginGUI(m_PluginInfo.Width,
  70. m_PluginInfo.Height,
  71. this,m_AudioCH,m_HostInfo);
  72. }
  73. void AmpPlugin::Execute()
  74. {
  75. float in;
  76. for (int n=0; n<m_HostInfo->BUFSIZE; n++)
  77. {
  78. in = GetInput(0,n);
  79. in *= m_Gain+GetInput(1,n);
  80. in += (-m_DC)+GetInput(2,n);
  81. SetOutput(0,n,in);
  82. }
  83. }
  84. void AmpPlugin::Randomise()
  85. {
  86. }
  87. void AmpPlugin::StreamOut(ostream &s)
  88. {
  89. s<<m_Version<<" "<<m_Gain<<" "<<m_DC<<" ";
  90. }
  91. void AmpPlugin::StreamIn(istream &s)
  92. {
  93. int version;
  94. s>>version;
  95. s>>m_Gain>>m_DC;
  96. }