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.

120 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 "SwitchPlugin.h"
  19. #include "SwitchPluginGUI.h"
  20. #include <FL/Fl_Button.H>
  21. #include "SpiralIcon.xpm"
  22. #include "../../NoteTable.h"
  23. using namespace std;
  24. extern "C" {
  25. SpiralPlugin* SpiralPlugin_CreateInstance()
  26. {
  27. return new SwitchPlugin;
  28. }
  29. char** SpiralPlugin_GetIcon()
  30. {
  31. return SpiralIcon_xpm;
  32. }
  33. int SpiralPlugin_GetID()
  34. {
  35. return 47;
  36. }
  37. string SpiralPlugin_GetGroupName()
  38. {
  39. return "Maths/Logic";
  40. }
  41. }
  42. ///////////////////////////////////////////////////////
  43. SwitchPlugin::SwitchPlugin() :
  44. m_Mix(false)
  45. {
  46. m_PluginInfo.Name="Switch";
  47. m_PluginInfo.Width=80;
  48. m_PluginInfo.Height=50;
  49. m_PluginInfo.NumInputs=3;
  50. m_PluginInfo.NumOutputs=1;
  51. m_PluginInfo.PortTips.push_back("Input 1");
  52. m_PluginInfo.PortTips.push_back("Input 2");
  53. m_PluginInfo.PortTips.push_back("CV");
  54. m_PluginInfo.PortTips.push_back("Output");
  55. m_AudioCH->Register("Mix",&m_Mix);
  56. }
  57. SwitchPlugin::~SwitchPlugin()
  58. {
  59. }
  60. PluginInfo &SwitchPlugin::Initialise(const HostInfo *Host)
  61. {
  62. return SpiralPlugin::Initialise(Host);
  63. }
  64. SpiralGUIType *SwitchPlugin::CreateGUI()
  65. {
  66. return new SwitchPluginGUI(m_PluginInfo.Width,
  67. m_PluginInfo.Height,
  68. this,m_AudioCH,m_HostInfo);
  69. }
  70. void SwitchPlugin::Execute()
  71. {
  72. for (int n=0; n<m_HostInfo->BUFSIZE; n++)
  73. {
  74. if (!m_Mix)
  75. {
  76. if (GetInput(2,n)<=0)
  77. {
  78. SetOutput(0,n,GetInput(0,n));
  79. }
  80. else
  81. {
  82. SetOutput(0,n,GetInput(1,n));
  83. }
  84. }
  85. else
  86. {
  87. SetOutput(0,n,Linear(-1.0f,1.0f,GetInput(2,n),GetInput(0,n),GetInput(1,n)));
  88. }
  89. }
  90. }
  91. void SwitchPlugin::ExecuteCommands()
  92. {
  93. }
  94. void SwitchPlugin::StreamOut(ostream &s)
  95. {
  96. s<<m_Version<<endl;
  97. s<<m_Mix<<" ";
  98. }
  99. void SwitchPlugin::StreamIn(istream &s)
  100. {
  101. int version;
  102. s>>version;
  103. s>>m_Mix;
  104. }