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.

157 lines
3.2KB

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