Browse Source

Fixed Bug 787272 - Rewritten distributorPlugin

master
edgeeffect 21 years ago
parent
commit
6e2a8c7f6f
3 changed files with 71 additions and 121 deletions
  1. +55
    -96
      SpiralSound/Plugins/DistributorPlugin/DistributorPlugin.C
  2. +15
    -24
      SpiralSound/Plugins/DistributorPlugin/DistributorPlugin.h
  3. +1
    -1
      SpiralSynthModular.C

+ 55
- 96
SpiralSound/Plugins/DistributorPlugin/DistributorPlugin.C View File

@@ -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; n<m_HostInfo->BUFSIZE; 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; n<m_HostInfo->BUFSIZE; 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);
}
}





+ 15
- 24
SpiralSound/Plugins/DistributorPlugin/DistributorPlugin.h View File

@@ -16,33 +16,24 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#include "../SpiralPlugin.h"
#include <FL/Fl_Pixmap.H>

#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 <FL/Fl_Pixmap.H>

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


+ 1
- 1
SpiralSynthModular.C View File

@@ -874,7 +874,7 @@ istream &operator>>(istream &s, SynthModular &o)
s>>*o.m_Canvas;

o.ResumeAudio();
return s;
return s;
}

//////////////////////////////////////////////////////////


Loading…
Cancel
Save