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.

102 lines
3.1KB

  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. return new DistributorPlugin;
  26. }
  27. char** SpiralPlugin_GetIcon() {
  28. return SpiralIcon_xpm;
  29. }
  30. int SpiralPlugin_GetID() {
  31. return 0x0056;
  32. }
  33. string SpiralPlugin_GetGroupName() {
  34. return "Control";
  35. }
  36. }
  37. ///////////////////////////////////////////////////////
  38. DistributorPlugin::DistributorPlugin() :
  39. m_Triggered (false),
  40. m_ChannelSelect (0),
  41. m_TrigDelay (0)
  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");
  49. m_PluginInfo.PortTips.push_back ("Switcher");
  50. m_PluginInfo.PortTips.push_back ("Stream 1");
  51. m_PluginInfo.PortTips.push_back ("Switcher 1");
  52. m_PluginInfo.PortTips.push_back ("Stream 2");
  53. m_PluginInfo.PortTips.push_back ("Switcher 2");
  54. m_PluginInfo.PortTips.push_back ("Stream 3");
  55. m_PluginInfo.PortTips.push_back ("Switcher 3");
  56. m_PluginInfo.PortTips.push_back ("Stream 4");
  57. m_PluginInfo.PortTips.push_back ("Switcher 4");
  58. }
  59. DistributorPlugin::~DistributorPlugin() {
  60. }
  61. PluginInfo &DistributorPlugin::Initialise (const HostInfo *Host) {
  62. return SpiralPlugin::Initialise (Host);
  63. }
  64. SpiralGUIType *DistributorPlugin::CreateGUI() {
  65. return NULL;
  66. }
  67. void DistributorPlugin::Execute() {
  68. const int Stream = 0;
  69. const int Switch = 1;
  70. for (int n=0; n<m_HostInfo->BUFSIZE; n++) {
  71. float InpStream = InputExists (Stream) ? GetInput (Stream, n) : 0.0;
  72. float InpSwitch = InputExists (Switch) ? GetInput (Switch, n) : 0.0;
  73. if (InpSwitch <= 0.0) m_Triggered = false;
  74. if (! m_Triggered && (InpSwitch > 0.0)) {
  75. m_Triggered = true;
  76. SetOutput (m_ChannelSelect+Switch, n, 0);
  77. m_ChannelSelect = m_ChannelSelect + 2;
  78. if (m_ChannelSelect > 6) m_ChannelSelect = 0;
  79. m_TrigDelay = 0;
  80. }
  81. SetOutput (m_ChannelSelect+Stream, n, InpStream);
  82. if (m_TrigDelay < 10) {
  83. m_TrigDelay++;
  84. SetOutput (m_ChannelSelect+Switch, n, InpSwitch);
  85. }
  86. else SetOutput (m_ChannelSelect+Switch, n, 0);
  87. }
  88. }