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.

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