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.

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