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.

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