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.

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