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.

119 lines
2.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 "FlipflopPlugin.h"
  19. #include "FlipflopPluginGUI.h"
  20. #include <FL/Fl_Button.h>
  21. #include "SpiralIcon.xpm"
  22. #include "../../NoteTable.h"
  23. extern "C" {
  24. SpiralPlugin* CreateInstance()
  25. {
  26. return new FlipflopPlugin;
  27. }
  28. char** GetIcon()
  29. {
  30. return SpiralIcon_xpm;
  31. }
  32. int GetID()
  33. {
  34. return 46;
  35. }
  36. string GetGroupName()
  37. {
  38. return "Maths/Logic";
  39. }
  40. }
  41. ///////////////////////////////////////////////////////
  42. FlipflopPlugin::FlipflopPlugin() :
  43. m_Count(4),
  44. m_Current(0),
  45. m_Triggered(false),
  46. m_CurrentLevel(1.0f)
  47. {
  48. m_PluginInfo.Name="Flipflop";
  49. m_PluginInfo.Width=90;
  50. m_PluginInfo.Height=80;
  51. m_PluginInfo.NumInputs=1;
  52. m_PluginInfo.NumOutputs=1;
  53. m_PluginInfo.PortTips.push_back("Input");
  54. m_PluginInfo.PortTips.push_back("Output");
  55. m_AudioCH->Register("Count",&m_Count);
  56. }
  57. FlipflopPlugin::~FlipflopPlugin()
  58. {
  59. }
  60. PluginInfo &FlipflopPlugin::Initialise(const HostInfo *Host)
  61. {
  62. return SpiralPlugin::Initialise(Host);
  63. }
  64. SpiralGUIType *FlipflopPlugin::CreateGUI()
  65. {
  66. return NULL;
  67. }
  68. void FlipflopPlugin::Execute()
  69. {
  70. bool Triggered;
  71. for (int n=0; n<m_HostInfo->BUFSIZE; n++)
  72. {
  73. if (GetInput(0,n)>0)
  74. {
  75. if(!m_Triggered)
  76. {
  77. m_Triggered=true;
  78. m_CurrentLevel=-m_CurrentLevel;
  79. }
  80. }
  81. else
  82. {
  83. if (m_Triggered)
  84. {
  85. m_Triggered=false;
  86. }
  87. }
  88. SetOutput(0,n,m_CurrentLevel);
  89. }
  90. }
  91. void FlipflopPlugin::ExecuteCommands()
  92. {
  93. }
  94. void FlipflopPlugin::StreamOut(ostream &s)
  95. {
  96. s<<m_Version<<endl;
  97. }
  98. void FlipflopPlugin::StreamIn(istream &s)
  99. {
  100. int version;
  101. s>>version;
  102. }