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.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 "XFadePlugin.h"
  20. #include "XFadePluginGUI.h"
  21. #include <FL/Fl_Button.h>
  22. #include "SpiralIcon.xpm"
  23. #define PI 3.141592654
  24. extern "C" {
  25. SpiralPlugin* CreateInstance()
  26. {
  27. return new XFadePlugin;
  28. }
  29. char** GetIcon()
  30. {
  31. return SpiralIcon_xpm;
  32. }
  33. int GetID()
  34. {
  35. return 0x001b;
  36. }
  37. }
  38. ///////////////////////////////////////////////////////
  39. XFadePlugin::XFadePlugin() :
  40. m_Mix(0.5f)
  41. {
  42. m_PluginInfo.Name="XFade";
  43. m_PluginInfo.Width=210;
  44. m_PluginInfo.Height=45;
  45. m_PluginInfo.NumInputs=5;
  46. m_PluginInfo.NumOutputs=2;
  47. m_PluginInfo.PortTips.push_back("XFade CV");
  48. m_PluginInfo.PortTips.push_back("A Left");
  49. m_PluginInfo.PortTips.push_back("A Right");
  50. m_PluginInfo.PortTips.push_back("B Left");
  51. m_PluginInfo.PortTips.push_back("B Right");
  52. m_PluginInfo.PortTips.push_back("Left");
  53. m_PluginInfo.PortTips.push_back("Right");
  54. m_AudioCH->Register("Mix",&m_Mix);
  55. }
  56. XFadePlugin::~XFadePlugin()
  57. {
  58. }
  59. PluginInfo &XFadePlugin::Initialise(const HostInfo *Host)
  60. {
  61. return SpiralPlugin::Initialise(Host);;
  62. }
  63. SpiralGUIType *XFadePlugin::CreateGUI()
  64. {
  65. return new XFadePluginGUI(m_PluginInfo.Width,
  66. m_PluginInfo.Height,
  67. this,m_AudioCH,m_HostInfo);
  68. }
  69. void XFadePlugin::Execute()
  70. {
  71. float x;
  72. for (int n=0; n<m_HostInfo->BUFSIZE; n++)
  73. {
  74. if (InputExists(0)) x=(1+GetInput(0,n))/2.0f;
  75. else x=m_Mix;
  76. SetOutput(0,n,GetInput(1,n)*x + GetInput(3,n)*(1-x));
  77. SetOutput(1,n,GetInput(2,n)*x + GetInput(4,n)*(1-x));
  78. }
  79. }
  80. void XFadePlugin::Randomise()
  81. {
  82. }
  83. void XFadePlugin::StreamOut(ostream &s)
  84. {
  85. s<<m_Version<<" "<<m_Mix<<" "<<endl;
  86. }
  87. void XFadePlugin::StreamIn(istream &s)
  88. {
  89. int version;
  90. s>>version;
  91. s>>m_Mix;
  92. }