From 6e2a8c7f6f491f76e3d142dd5b6e0462375da474 Mon Sep 17 00:00:00 2001 From: edgeeffect Date: Sat, 22 Nov 2003 20:40:13 +0000 Subject: [PATCH] Fixed Bug 787272 - Rewritten distributorPlugin --- .../DistributorPlugin/DistributorPlugin.C | 151 +++++++----------- .../DistributorPlugin/DistributorPlugin.h | 39 ++--- SpiralSynthModular.C | 2 +- 3 files changed, 71 insertions(+), 121 deletions(-) diff --git a/SpiralSound/Plugins/DistributorPlugin/DistributorPlugin.C b/SpiralSound/Plugins/DistributorPlugin/DistributorPlugin.C index 068b434..a3ffe3d 100644 --- a/SpiralSound/Plugins/DistributorPlugin/DistributorPlugin.C +++ b/SpiralSound/Plugins/DistributorPlugin/DistributorPlugin.C @@ -23,120 +23,79 @@ using namespace std; extern "C" { -SpiralPlugin* SpiralPlugin_CreateInstance() -{ - return new DistributorPlugin; + +SpiralPlugin* SpiralPlugin_CreateInstance() { + return new DistributorPlugin; } -char** SpiralPlugin_GetIcon() -{ - return SpiralIcon_xpm; +char** SpiralPlugin_GetIcon() { + return SpiralIcon_xpm; } -int SpiralPlugin_GetID() -{ - return 0x0056; +int SpiralPlugin_GetID() { + return 0x0056; } -string SpiralPlugin_GetGroupName() -{ - return "Control"; +string SpiralPlugin_GetGroupName() { + return "Control"; } + } /////////////////////////////////////////////////////// -DistributorPlugin::DistributorPlugin() +DistributorPlugin::DistributorPlugin() : +m_Triggered (false), +m_ChannelSelect (0), +m_TrigDelay (0) { - m_PluginInfo.Name="Distributor"; - m_PluginInfo.Width=220; - m_PluginInfo.Height=250; - m_PluginInfo.NumInputs=2; - m_PluginInfo.NumOutputs=8; - m_PluginInfo.PortTips.push_back("Stream (A)"); - m_PluginInfo.PortTips.push_back("Switcher (B)"); - m_PluginInfo.PortTips.push_back("Out A1"); - m_PluginInfo.PortTips.push_back("Out B1"); - m_PluginInfo.PortTips.push_back("Out A2"); - m_PluginInfo.PortTips.push_back("Out B2"); - m_PluginInfo.PortTips.push_back("Out A3"); - m_PluginInfo.PortTips.push_back("Out B3"); - m_PluginInfo.PortTips.push_back("Out A4"); - m_PluginInfo.PortTips.push_back("Out B4"); + m_PluginInfo.Name = "Distributor"; + m_PluginInfo.Width = 220; + m_PluginInfo.Height = 250; + m_PluginInfo.NumInputs = 2; + m_PluginInfo.NumOutputs = 8; + m_PluginInfo.PortTips.push_back ("Stream"); + m_PluginInfo.PortTips.push_back ("Switcher"); + m_PluginInfo.PortTips.push_back ("Stream 1"); + m_PluginInfo.PortTips.push_back ("Switcher 1"); + m_PluginInfo.PortTips.push_back ("Stream 2"); + m_PluginInfo.PortTips.push_back ("Switcher 2"); + m_PluginInfo.PortTips.push_back ("Stream 3"); + m_PluginInfo.PortTips.push_back ("Switcher 3"); + m_PluginInfo.PortTips.push_back ("Stream 4"); + m_PluginInfo.PortTips.push_back ("Switcher 4"); } -DistributorPlugin::~DistributorPlugin() -{ +DistributorPlugin::~DistributorPlugin() { } -PluginInfo &DistributorPlugin::Initialise(const HostInfo *Host) -{ - return SpiralPlugin::Initialise(Host); +PluginInfo &DistributorPlugin::Initialise (const HostInfo *Host) { + return SpiralPlugin::Initialise (Host); } -SpiralGUIType *DistributorPlugin::CreateGUI() -{ - return NULL; +SpiralGUIType *DistributorPlugin::CreateGUI() { + return NULL; } -void DistributorPlugin::Execute() -{ - if (! m_Defined) - { - m_Triggeronce=false; - m_Previous=0; - m_Now=0; - m_Defined=true; - m_ChannelSelect=0; - m_trigdelay=0; - } - for (int n=0; nBUFSIZE; n++) - { - // detect the trigger - if ((GetInput(1,n))!=0) - { - if (GetInput(0,n)!=m_Previous) - { - GetOutputBuf(m_ChannelSelect+1)->Zero(); - m_ChannelSelect=m_ChannelSelect+2; - if (m_ChannelSelect>6) - { - m_ChannelSelect=0; - } - //zero the outputs first... - GetOutputBuf(m_ChannelSelect)->Zero(); - GetOutputBuf(m_ChannelSelect+1)->Zero(); - //and copy the inputs as well - if (InputExists(0)) //unless you want segmentation faults... - GetOutputBuf(m_ChannelSelect)->Mix(*GetInput(0),0); - GetOutputBuf(m_ChannelSelect+1)->Mix(*GetInput(1),0); - //now save the present pitch value, because we'll need it next time around. - m_Previous=GetInput(0,n); - m_Triggeronce=true; - } - else if (m_Triggeronce==false) - { - //just copy the trigger in this case. - GetOutputBuf(m_ChannelSelect+1)->Zero(); - GetOutputBuf(m_ChannelSelect+1)->Mix(*GetInput(1),0); - m_Triggeronce=true; - } - } - else - { - m_Triggeronce=false; - m_trigdelay++; - if (m_trigdelay>=10) - { - GetOutputBuf(m_ChannelSelect+1)->Zero(); - m_trigdelay=0; - } - } - - } - +void DistributorPlugin::Execute() { + const int Stream = 0; + const int Switch = 1; + for (int n=0; nBUFSIZE; n++) { + float InpStream = InputExists (Stream) ? GetInput (Stream, n) : 0.0; + float InpSwitch = InputExists (Switch) ? GetInput (Switch, n) : 0.0; + if (InpSwitch <= 0.0) m_Triggered = false; + if (! m_Triggered && (InpSwitch > 0.0)) { + m_Triggered = true; + SetOutput (m_ChannelSelect+Switch, n, 0); + m_ChannelSelect = m_ChannelSelect + 2; + if (m_ChannelSelect > 6) m_ChannelSelect = 0; + m_TrigDelay = 0; + } + SetOutput (m_ChannelSelect+Stream, n, InpStream); + if (m_TrigDelay < 10) { + m_TrigDelay++; + SetOutput (m_ChannelSelect+Switch, n, InpSwitch); + } + else SetOutput (m_ChannelSelect+Switch, n, 0); + } } - - - - diff --git a/SpiralSound/Plugins/DistributorPlugin/DistributorPlugin.h b/SpiralSound/Plugins/DistributorPlugin/DistributorPlugin.h index 9b5d496..72167c4 100644 --- a/SpiralSound/Plugins/DistributorPlugin/DistributorPlugin.h +++ b/SpiralSound/Plugins/DistributorPlugin/DistributorPlugin.h @@ -16,33 +16,24 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../SpiralPlugin.h" -#include - #ifndef DistributorPLUGIN #define DistributorPLUGIN -class DistributorPlugin : public SpiralPlugin -{ -public: - DistributorPlugin(); - virtual ~DistributorPlugin(); - - virtual PluginInfo& Initialise(const HostInfo *Host); - virtual SpiralGUIType* CreateGUI(); - virtual void Execute(); - virtual void StreamOut(std::ostream &s) {} - virtual void StreamIn(std::istream &s) {} - -private: -bool m_Triggered; -bool m_Switch; -bool m_Triggeronce; -int m_ChannelSelect; -int m_trigdelay; -bool m_Defined; -float m_Previous; -float m_Now; +#include "../SpiralPlugin.h" +#include + +class DistributorPlugin : public SpiralPlugin { + public: + DistributorPlugin(); + virtual ~DistributorPlugin(); + virtual PluginInfo& Initialise (const HostInfo *Host); + virtual SpiralGUIType* CreateGUI(); + virtual void Execute(); + virtual void StreamOut (std::ostream &s) { } + virtual void StreamIn (std::istream &s) { } + private: + bool m_Triggered; + int m_ChannelSelect, m_TrigDelay; }; #endif diff --git a/SpiralSynthModular.C b/SpiralSynthModular.C index 866cef4..ad2283d 100644 --- a/SpiralSynthModular.C +++ b/SpiralSynthModular.C @@ -874,7 +874,7 @@ istream &operator>>(istream &s, SynthModular &o) s>>*o.m_Canvas; o.ResumeAudio(); - return s; + return s; } //////////////////////////////////////////////////////////