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.

155 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 "SeqSelectorPlugin.h"
  19. #include "SeqSelectorPluginGUI.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 SeqSelectorPlugin;
  27. }
  28. char** GetIcon()
  29. {
  30. return SpiralIcon_xpm;
  31. }
  32. int GetID()
  33. {
  34. return 0x0015;
  35. }
  36. }
  37. ///////////////////////////////////////////////////////
  38. SeqSelectorPlugin::SeqSelectorPlugin()
  39. {
  40. m_PluginInfo.Name="SeqSelector";
  41. m_PluginInfo.Width=400;
  42. m_PluginInfo.Height=300;
  43. m_PluginInfo.NumInputs=1;
  44. m_PluginInfo.NumOutputs=8;
  45. m_PluginInfo.PortTips.push_back("Trigger");
  46. m_PluginInfo.PortTips.push_back("CV One");
  47. m_PluginInfo.PortTips.push_back("CV Two");
  48. m_PluginInfo.PortTips.push_back("CV Three");
  49. m_PluginInfo.PortTips.push_back("CV Four");
  50. m_PluginInfo.PortTips.push_back("CV Five");
  51. m_PluginInfo.PortTips.push_back("CV Six");
  52. m_PluginInfo.PortTips.push_back("CV Seven");
  53. m_PluginInfo.PortTips.push_back("CV Eight");
  54. m_Pos=0;
  55. m_Triggered=false;
  56. m_UseRange=false;
  57. for(int i=0; i<8; i++)
  58. {
  59. m_OutTemp[i]=0;
  60. }
  61. }
  62. SeqSelectorPlugin::~SeqSelectorPlugin()
  63. {
  64. }
  65. PluginInfo &SeqSelectorPlugin::Initialise(const HostInfo *Host)
  66. {
  67. return SpiralPlugin::Initialise(Host);
  68. }
  69. SpiralGUIType *SeqSelectorPlugin::CreateGUI()
  70. {
  71. m_GUI = new SeqSelectorPluginGUI(m_PluginInfo.Width,
  72. m_PluginInfo.Height,
  73. this,m_HostInfo);
  74. m_GUI->hide();
  75. return m_GUI;
  76. }
  77. void SeqSelectorPlugin::Execute()
  78. {
  79. SeqSelectorPluginGUI *ssp=(SeqSelectorPluginGUI*)m_GUI;
  80. for (int n=0; n<m_HostInfo->BUFSIZE; n++)
  81. {
  82. // Sends momentary spike of value when triggered,
  83. // works on the note off, rather than the first
  84. // detection of a trigger value
  85. if (GetInput(0,n)>0.1)
  86. {
  87. m_Triggered=true;
  88. }
  89. else
  90. {
  91. if (m_Triggered==true && ssp->GetNumLines()>0)
  92. {
  93. m_Pos++;
  94. if (m_UseRange)
  95. {
  96. if (m_Pos>=m_End)
  97. {
  98. m_Pos=m_Begin;
  99. }
  100. }
  101. else
  102. {
  103. if (m_Pos>=ssp->GetNumLines())
  104. {
  105. m_Pos=0;
  106. }
  107. }
  108. for(int i=0; i<8; i++)
  109. {
  110. SetOutputPitch(i,n,NoteTable[(int)ssp->GetVal(m_Pos,i)]);
  111. }
  112. ssp->SetLED(m_Pos);
  113. }
  114. else
  115. {
  116. for(int i=0; i<8; i++)
  117. {
  118. // zero frequency
  119. SetOutputPitch(i,n,-1);
  120. }
  121. }
  122. m_Triggered=false;
  123. }
  124. }
  125. }
  126. void SeqSelectorPlugin::StreamOut(ostream &s)
  127. {
  128. s<<m_Version<<" ";
  129. ((SeqSelectorPluginGUI*)m_GUI)->StreamOut(s);
  130. }
  131. void SeqSelectorPlugin::StreamIn(istream &s)
  132. {
  133. int version;
  134. s>>version;
  135. ((SeqSelectorPluginGUI*)m_GUI)->StreamIn(s);
  136. }