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.

136 lines
3.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 "DistributorPlugin.h"
  19. #include "DistributorPluginGUI.h"
  20. #include <FL/Fl_Button.h>
  21. #include "SpiralIcon.xpm"
  22. extern "C" {
  23. SpiralPlugin* CreateInstance()
  24. {
  25. return new DistributorPlugin;
  26. }
  27. char** GetIcon()
  28. {
  29. return SpiralIcon_xpm;
  30. }
  31. int GetID()
  32. {
  33. return 0x0056;
  34. }
  35. }
  36. ///////////////////////////////////////////////////////
  37. DistributorPlugin::DistributorPlugin()
  38. {
  39. m_PluginInfo.Name="Distributor";
  40. m_PluginInfo.Width=220;
  41. m_PluginInfo.Height=250;
  42. m_PluginInfo.NumInputs=2;
  43. m_PluginInfo.NumOutputs=8;
  44. m_PluginInfo.PortTips.push_back("Stream (A)");
  45. m_PluginInfo.PortTips.push_back("Switcher (B)");
  46. m_PluginInfo.PortTips.push_back("Out A1");
  47. m_PluginInfo.PortTips.push_back("Out B1");
  48. m_PluginInfo.PortTips.push_back("Out A2");
  49. m_PluginInfo.PortTips.push_back("Out B2");
  50. m_PluginInfo.PortTips.push_back("Out A3");
  51. m_PluginInfo.PortTips.push_back("Out B3");
  52. m_PluginInfo.PortTips.push_back("Out A4");
  53. m_PluginInfo.PortTips.push_back("Out B4");
  54. }
  55. DistributorPlugin::~DistributorPlugin()
  56. {
  57. }
  58. PluginInfo &DistributorPlugin::Initialise(const HostInfo *Host)
  59. {
  60. return SpiralPlugin::Initialise(Host);
  61. }
  62. SpiralGUIType *DistributorPlugin::CreateGUI()
  63. {
  64. return NULL;
  65. }
  66. void DistributorPlugin::Execute()
  67. {
  68. if (! m_Defined)
  69. {
  70. m_Triggeronce=false;
  71. m_Previous=0;
  72. m_Now=0;
  73. m_Defined=true;
  74. m_ChannelSelect=0;
  75. m_trigdelay=0;
  76. }
  77. for (int n=0; n<m_HostInfo->BUFSIZE; n++)
  78. {
  79. // detect the trigger
  80. if ((GetInput(1,n))!=0)
  81. {
  82. if (GetInput(0,n)!=m_Previous)
  83. {
  84. GetOutputBuf(m_ChannelSelect+1)->Zero();
  85. m_ChannelSelect=m_ChannelSelect+2;
  86. if (m_ChannelSelect>6)
  87. {
  88. m_ChannelSelect=0;
  89. }
  90. //zero the outputs first...
  91. GetOutputBuf(m_ChannelSelect)->Zero();
  92. GetOutputBuf(m_ChannelSelect+1)->Zero();
  93. //and copy the inputs as well
  94. if (InputExists(0)) //unless you want segmentation faults...
  95. GetOutputBuf(m_ChannelSelect)->Mix(*GetInput(0),0);
  96. GetOutputBuf(m_ChannelSelect+1)->Mix(*GetInput(1),0);
  97. //now save the present pitch value, because we'll need it next time around.
  98. m_Previous=GetInput(0,n);
  99. m_Triggeronce=true;
  100. }
  101. else if (m_Triggeronce==false)
  102. {
  103. //just copy the trigger in this case.
  104. GetOutputBuf(m_ChannelSelect+1)->Zero();
  105. GetOutputBuf(m_ChannelSelect+1)->Mix(*GetInput(1),0);
  106. m_Triggeronce=true;
  107. }
  108. }
  109. else
  110. {
  111. m_Triggeronce=false;
  112. m_trigdelay++;
  113. if (m_trigdelay>=10)
  114. {
  115. GetOutputBuf(m_ChannelSelect+1)->Zero();
  116. m_trigdelay=0;
  117. }
  118. }
  119. }
  120. }