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.

109 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 "SmoothPlugin.h"
  19. #include "SmoothPluginGUI.h"
  20. #include <FL/Fl_Button.h>
  21. #include "SpiralIcon.xpm"
  22. using namespace std;
  23. extern "C" {
  24. SpiralPlugin* SpiralPlugin_CreateInstance()
  25. {
  26. return new SmoothPlugin;
  27. }
  28. char** SpiralPlugin_GetIcon()
  29. {
  30. return SpiralIcon_xpm;
  31. }
  32. int SpiralPlugin_GetID()
  33. {
  34. return 0x0014;
  35. }
  36. string SpiralPlugin_GetGroupName()
  37. {
  38. return "Control";
  39. }
  40. }
  41. ///////////////////////////////////////////////////////
  42. SmoothPlugin::SmoothPlugin() :
  43. m_Up(0.5),
  44. m_Down(0.5),
  45. m_Value(0)
  46. {
  47. m_PluginInfo.Name="Smooth";
  48. m_PluginInfo.Width=120;
  49. m_PluginInfo.Height=80;
  50. m_PluginInfo.NumInputs=1;
  51. m_PluginInfo.NumOutputs=1;
  52. m_PluginInfo.PortTips.push_back("Input");
  53. m_PluginInfo.PortTips.push_back("Output");
  54. m_AudioCH->Register("Up",&m_Up);
  55. m_AudioCH->Register("Down",&m_Down);
  56. }
  57. SmoothPlugin::~SmoothPlugin()
  58. {
  59. }
  60. PluginInfo &SmoothPlugin::Initialise(const HostInfo *Host)
  61. {
  62. return SpiralPlugin::Initialise(Host);
  63. }
  64. SpiralGUIType *SmoothPlugin::CreateGUI()
  65. {
  66. return new SmoothPluginGUI(m_PluginInfo.Width,
  67. m_PluginInfo.Height,
  68. this,m_AudioCH,m_HostInfo);
  69. }
  70. void SmoothPlugin::Execute()
  71. {
  72. float Value;
  73. for (int n=0; n<m_HostInfo->BUFSIZE; n++)
  74. {
  75. Value = GetInput(0,n);
  76. if (Value>m_Value) m_Value+=m_Up*0.0001f;
  77. else m_Value-=m_Down*0.0001f;
  78. SetOutput(0,n,m_Value);
  79. }
  80. }
  81. void SmoothPlugin::StreamOut(ostream &s)
  82. {
  83. s<<m_Version<<" ";
  84. s<<m_Up<<" "<<m_Down;
  85. }
  86. void SmoothPlugin::StreamIn(istream &s)
  87. {
  88. s>>m_Version;
  89. s>>m_Up>>m_Down;
  90. }