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.

141 lines
3.3KB

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