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.

154 lines
3.1KB

  1. /* SpiralSound
  2. * Copyleft (C) 2002 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 "SpiralPlugin.h"
  19. SpiralPlugin::SpiralPlugin()
  20. {
  21. m_Version=1;
  22. m_PluginInfo.Name="BasePlugin";
  23. m_PluginInfo.Width=100;
  24. m_PluginInfo.Height=100;
  25. m_PluginInfo.NumInputs=0;
  26. m_PluginInfo.NumOutputs=0;
  27. UpdateInfo=NULL;
  28. cb_Update=NULL;
  29. m_Parent=NULL;
  30. m_HostID=-1;
  31. m_AudioCH = new ChannelHandler;
  32. }
  33. SpiralPlugin::~SpiralPlugin()
  34. {
  35. for (int n=0; n<m_PluginInfo.NumOutputs; n++)
  36. {
  37. delete m_Output[n];
  38. }
  39. delete m_AudioCH;
  40. }
  41. PluginInfo &SpiralPlugin::Initialise(const HostInfo *Host)
  42. {
  43. m_HostInfo=Host;
  44. for (int n=0; n<m_PluginInfo.NumInputs; n++)
  45. {
  46. m_Input.push_back(NULL);
  47. }
  48. for (int n=0; n<m_PluginInfo.NumOutputs; n++)
  49. {
  50. m_Output.push_back(new Sample(Host->BUFSIZE));
  51. }
  52. for (int n=0; n<m_PluginInfo.NumInputs+m_PluginInfo.NumOutputs; n++)
  53. {
  54. m_PluginInfo.PortTypes.push_back(0);
  55. }
  56. return m_PluginInfo;
  57. }
  58. bool SpiralPlugin::GetOutput(unsigned int n, Sample **s)
  59. {
  60. if (n>=m_Output.size()) return false;
  61. *s = m_Output[n];
  62. return true;
  63. }
  64. bool SpiralPlugin::SetInput(unsigned int n, const Sample *s)
  65. {
  66. if (n>=m_Input.size()) return false;
  67. m_Input[n]=s;
  68. return true;
  69. }
  70. void SpiralPlugin::UpdateChannelHandler()
  71. {
  72. m_AudioCH->UpdateDataNow();
  73. }
  74. void SpiralPlugin::AddOutput()
  75. {
  76. Sample* NewSample = new Sample(m_HostInfo->BUFSIZE);
  77. m_Output.push_back(NewSample);
  78. }
  79. void SpiralPlugin::RemoveOutput()
  80. {
  81. vector<Sample*>::iterator si=m_Output.end();
  82. si--;
  83. delete *si;
  84. m_Output.erase(si);
  85. }
  86. void SpiralPlugin::RemoveAllOutputs()
  87. {
  88. for (vector<Sample*>::iterator i=m_Output.begin();
  89. i!=m_Output.end(); i++)
  90. {
  91. delete *i;
  92. }
  93. m_Output.clear();
  94. }
  95. void SpiralPlugin::AddInput()
  96. {
  97. m_Input.push_back(NULL);
  98. }
  99. void SpiralPlugin::RemoveInput()
  100. {
  101. vector<const Sample*>::iterator si=m_Input.end();
  102. si--;
  103. m_Input.erase(si);
  104. }
  105. void SpiralPlugin::RemoveAllInputs()
  106. {
  107. m_Input.clear();
  108. }
  109. void SpiralPlugin::UpdatePluginInfoWithHost()
  110. {
  111. if (UpdateInfo!=NULL)
  112. {
  113. UpdateInfo(m_HostID,(void*)&m_PluginInfo);
  114. }
  115. }
  116. void SpiralPlugin::SetUpdateInfoCallback(int ID, void(*s)(int, void *))
  117. {
  118. m_HostID=ID;
  119. UpdateInfo=s;
  120. }
  121. void SpiralPlugin::SetInPortType(PluginInfo &pinfo, int port, Sample::SampleType type)
  122. {
  123. pinfo.PortTypes[port] = type;
  124. }
  125. void SpiralPlugin::SetOutPortType(PluginInfo &pinfo, int port, Sample::SampleType type)
  126. {
  127. pinfo.PortTypes[port+m_PluginInfo.NumInputs] = type;
  128. GetOutputBuf(port)->setSampleType(type);
  129. }