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.

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