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.

112 lines
2.4KB

  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 "KeyboardPlugin.h"
  19. #include "KeyboardPluginGUI.h"
  20. #include "../../NoteTable.h"
  21. #include "SpiralIcon.xpm"
  22. extern "C" {
  23. SpiralPlugin* SpiralPlugin_CreateInstance()
  24. {
  25. return new KeyboardPlugin;
  26. }
  27. char** SpiralPlugin_GetIcon()
  28. {
  29. return SpiralIcon_xpm;
  30. }
  31. int SpiralPlugin_GetID()
  32. {
  33. return 40;
  34. }
  35. string SpiralPlugin_GetGroupName()
  36. {
  37. return "InputOutput";
  38. }
  39. }
  40. ///////////////////////////////////////////////////////
  41. KeyboardPlugin::KeyboardPlugin() :
  42. m_NoteLevel(0),
  43. m_TriggerLevel(0)
  44. {
  45. m_Version=0;
  46. m_PluginInfo.Name="Keyboard";
  47. m_PluginInfo.Width=300;
  48. m_PluginInfo.Height=90;
  49. m_PluginInfo.NumInputs=0;
  50. m_PluginInfo.NumOutputs=2;
  51. m_PluginInfo.PortTips.push_back("Note CV");
  52. m_PluginInfo.PortTips.push_back("Trigger CV");
  53. m_AudioCH->Register("Note",&m_GUIArgs.Note);
  54. }
  55. KeyboardPlugin::~KeyboardPlugin()
  56. {
  57. }
  58. SpiralGUIType *KeyboardPlugin::CreateGUI()
  59. {
  60. return new KeyboardPluginGUI(m_PluginInfo.Width,
  61. m_PluginInfo.Height,
  62. this,m_AudioCH,m_HostInfo);
  63. }
  64. void KeyboardPlugin::Execute()
  65. {
  66. for (int n=0; n<m_HostInfo->BUFSIZE; n++)
  67. {
  68. SetOutputPitch(0,n,m_NoteLevel);
  69. SetOutput(1,n,m_TriggerLevel);
  70. }
  71. }
  72. void KeyboardPlugin::ExecuteCommands()
  73. {
  74. // Process any commands from the GUI
  75. if (m_AudioCH->IsCommandWaiting())
  76. {
  77. switch (m_AudioCH->GetCommand())
  78. {
  79. case NOTE_ON :
  80. m_NoteLevel=NoteTable[m_GUIArgs.Note];
  81. m_TriggerLevel=1.0f;
  82. break;
  83. case NOTE_OFF : m_TriggerLevel=0.0f; break;
  84. };
  85. }
  86. }
  87. void KeyboardPlugin::StreamOut(ostream &s)
  88. {
  89. s<<m_Version<<endl;
  90. }
  91. void KeyboardPlugin::StreamIn(istream &s)
  92. {
  93. int version;
  94. s>>version;
  95. }