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.

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