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.

112 lines
2.3KB

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