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.

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