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.

90 lines
2.6KB

  1. /* SpiralSound
  2. * Copyleft (C) 2002 Andy Preston <andy@clublinux.co.uk>
  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 "MeterPlugin.h"
  19. #include "MeterPluginGUI.h"
  20. #include "SpiralIcon.xpm"
  21. extern "C" {
  22. SpiralPlugin* SpiralPlugin_CreateInstance() { return new MeterPlugin; }
  23. char** SpiralPlugin_GetIcon() { return SpiralIcon_xpm; }
  24. int SpiralPlugin_GetID() { return 123; }
  25. string SpiralPlugin_GetGroupName()
  26. {
  27. return "Control";
  28. }
  29. }
  30. MeterPlugin::MeterPlugin() {
  31. m_PluginInfo.Name = "Meter";
  32. m_PluginInfo.Width = 230;
  33. m_PluginInfo.Height = 128;
  34. m_PluginInfo.NumInputs = 1;
  35. m_PluginInfo.NumOutputs = 1;
  36. m_PluginInfo.PortTips.push_back ("Input");
  37. m_PluginInfo.PortTips.push_back ("Output");
  38. m_Data = NULL;
  39. }
  40. MeterPlugin::~MeterPlugin() {
  41. if (m_Data != NULL) delete m_Data;
  42. }
  43. PluginInfo &MeterPlugin::Initialise (const HostInfo *Host) {
  44. PluginInfo& Info = SpiralPlugin::Initialise (Host);
  45. m_Data = new float[Host->BUFSIZE];
  46. m_AudioCH->RegisterData ("AudioData", ChannelHandler::OUTPUT, m_Data, Host->BUFSIZE * sizeof (float));
  47. return Info;
  48. }
  49. SpiralGUIType *MeterPlugin::CreateGUI() {
  50. return new MeterPluginGUI (m_PluginInfo.Width, m_PluginInfo.Height, this, m_AudioCH, m_HostInfo);
  51. }
  52. void MeterPlugin::Execute() {
  53. // Just copy the data through.
  54. if (GetOutputBuf (0)) GetOutputBuf (0)->Zero();
  55. if (GetInput (0)) {
  56. GetOutputBuf (0)->Mix (*GetInput(0), 0);
  57. memcpy (m_Data, GetInput (0)->GetBuffer (), m_HostInfo->BUFSIZE * sizeof (float));
  58. }
  59. }
  60. void MeterPlugin::ExecuteCommands () {
  61. if (m_AudioCH->IsCommandWaiting ()) {
  62. switch (m_AudioCH->GetCommand()) {
  63. case (SETVU) : m_VUMode = true;
  64. break;
  65. case (SETMM) : m_VUMode = false;
  66. break;
  67. }
  68. }
  69. }
  70. void MeterPlugin::StreamOut (ostream &s) {
  71. s << m_Version << " " << m_VUMode << " ";
  72. }
  73. void MeterPlugin::StreamIn (istream &s) {
  74. int Version;
  75. s >> Version >> m_VUMode;
  76. }