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.

121 lines
2.7KB

  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 "MixerPlugin.h"
  19. #include "MixerPluginGUI.h"
  20. #include <FL/Fl_Button.h>
  21. #include "SpiralIcon.xpm"
  22. extern "C" {
  23. SpiralPlugin* CreateInstance()
  24. {
  25. return new MixerPlugin;
  26. }
  27. char** GetIcon()
  28. {
  29. return SpiralIcon_xpm;
  30. }
  31. int GetID()
  32. {
  33. return 0x0007;
  34. }
  35. }
  36. ///////////////////////////////////////////////////////
  37. MixerPlugin::MixerPlugin()
  38. {
  39. m_PluginInfo.Name="Mixer";
  40. m_PluginInfo.Width=100;
  41. m_PluginInfo.Height=125;
  42. m_PluginInfo.NumInputs=4;
  43. m_PluginInfo.NumOutputs=1;
  44. m_PluginInfo.PortTips.push_back("Input one");
  45. m_PluginInfo.PortTips.push_back("Input two");
  46. m_PluginInfo.PortTips.push_back("Input three");
  47. m_PluginInfo.PortTips.push_back("Input four");
  48. m_PluginInfo.PortTips.push_back("Output");
  49. for (int n=0; n<NUM_CHANNELS; n++)
  50. {
  51. m_ChannelVal[n]=1.0f;
  52. }
  53. m_AudioCH->Register("Value",&m_GUIArgs.Value);
  54. m_AudioCH->Register("Num",&m_GUIArgs.Num);
  55. }
  56. MixerPlugin::~MixerPlugin()
  57. {
  58. }
  59. PluginInfo &MixerPlugin::Initialise(const HostInfo *Host)
  60. {
  61. return SpiralPlugin::Initialise(Host);
  62. }
  63. SpiralGUIType *MixerPlugin::CreateGUI()
  64. {
  65. return new MixerPluginGUI(m_PluginInfo.Width,
  66. m_PluginInfo.Height,
  67. this,m_AudioCH,m_HostInfo);
  68. }
  69. void MixerPlugin::Execute()
  70. {
  71. // Mix the inputs
  72. for (int n=0; n<m_HostInfo->BUFSIZE; n++)
  73. {
  74. SetOutput(0,n,(GetInput(0,n)*m_ChannelVal[0])+
  75. (GetInput(1,n)*m_ChannelVal[1])+
  76. (GetInput(2,n)*m_ChannelVal[2])+
  77. (GetInput(3,n)*m_ChannelVal[3]));
  78. }
  79. }
  80. void MixerPlugin::ExecuteCommands()
  81. {
  82. if (m_AudioCH->IsCommandWaiting())
  83. {
  84. switch (m_AudioCH->GetCommand())
  85. {
  86. case (SETCH) : SetChannel(m_GUIArgs.Num,m_GUIArgs.Value); break;
  87. }
  88. }
  89. }
  90. void MixerPlugin::StreamOut(ostream &s)
  91. {
  92. s<<m_Version<<" ";
  93. for (int n=0; n<NUM_CHANNELS; n++)
  94. {
  95. s<<m_ChannelVal[n]<<" ";
  96. }
  97. }
  98. void MixerPlugin::StreamIn(istream &s)
  99. {
  100. int version;
  101. s>>version;
  102. for (int n=0; n<NUM_CHANNELS; n++)
  103. {
  104. s>>m_ChannelVal[n];
  105. }
  106. }