| @@ -37,19 +37,25 @@ extern "C" { | |||||
| /////////////////////////////////////////////////////// | /////////////////////////////////////////////////////// | ||||
| MixSwitchPlugin::MixSwitchPlugin () : | MixSwitchPlugin::MixSwitchPlugin () : | ||||
| m_SwitchPos (0), | |||||
| m_SwitchPos (1), | |||||
| m_Triggered (false) | m_Triggered (false) | ||||
| { | { | ||||
| m_GUIArgs.Chans = 2; | m_GUIArgs.Chans = 2; | ||||
| m_GUIArgs.Switch = 1; | m_GUIArgs.Switch = 1; | ||||
| m_GUIArgs.Echo = 1; | m_GUIArgs.Echo = 1; | ||||
| m_GUIArgs.Auto = false; | |||||
| m_PluginInfo.Name = "MixSwitch"; | m_PluginInfo.Name = "MixSwitch"; | ||||
| m_PluginInfo.Width = 80; | m_PluginInfo.Width = 80; | ||||
| m_PluginInfo.Height = 80; | m_PluginInfo.Height = 80; | ||||
| CreatePorts (); | CreatePorts (); | ||||
| // Number of channels <- GUI | |||||
| m_AudioCH->Register ("Chans", &m_GUIArgs.Chans); | m_AudioCH->Register ("Chans", &m_GUIArgs.Chans); | ||||
| // Switch Position <- GUI | |||||
| m_AudioCH->Register ("Switch", &m_GUIArgs.Switch); | m_AudioCH->Register ("Switch", &m_GUIArgs.Switch); | ||||
| // Switch Position -> GUI | |||||
| m_AudioCH->Register ("Echo", &m_GUIArgs.Echo, ChannelHandler::OUTPUT); | m_AudioCH->Register ("Echo", &m_GUIArgs.Echo, ChannelHandler::OUTPUT); | ||||
| // Auto Mode (Switch position is controlled by CV or Clock = True, Switch Position controlled by GUI = False | |||||
| m_AudioCH->Register ("Auto", &m_GUIArgs.Auto, ChannelHandler::OUTPUT); | |||||
| } | } | ||||
| MixSwitchPlugin::~MixSwitchPlugin () { | MixSwitchPlugin::~MixSwitchPlugin () { | ||||
| @@ -109,15 +115,17 @@ void MixSwitchPlugin::SetChans (int n) { | |||||
| } | } | ||||
| void MixSwitchPlugin::Execute() { | void MixSwitchPlugin::Execute() { | ||||
| int n; | |||||
| float f; | float f; | ||||
| int p; | |||||
| int NumChans = m_PluginInfo.NumInputs - 2; | int NumChans = m_PluginInfo.NumInputs - 2; | ||||
| for (n=0; n<m_HostInfo->BUFSIZE; n++) { | |||||
| for (int n=0; n<m_HostInfo->BUFSIZE; n++) { | |||||
| if (InputExists (0)) { | if (InputExists (0)) { | ||||
| m_GUIArgs.Auto = true; | |||||
| // Check the Switch Pos CV Value | // Check the Switch Pos CV Value | ||||
| m_SwitchPos = abs (int (GetInput (0, n) - 1)) % NumChans; | |||||
| m_SwitchPos = int (GetInput (0, n)); | |||||
| } | } | ||||
| else if (InputExists (1)) { | else if (InputExists (1)) { | ||||
| m_GUIArgs.Auto = true; | |||||
| // Check the trigger CV value | // Check the trigger CV value | ||||
| if (GetInput (1, n) < 0.01) { | if (GetInput (1, n) < 0.01) { | ||||
| m_Triggered = false; | m_Triggered = false; | ||||
| @@ -125,16 +133,19 @@ void MixSwitchPlugin::Execute() { | |||||
| else { | else { | ||||
| if (!m_Triggered) { | if (!m_Triggered) { | ||||
| m_Triggered = true; | m_Triggered = true; | ||||
| m_SwitchPos = (m_SwitchPos+1) % NumChans; | |||||
| m_SwitchPos = m_SwitchPos + 1; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else m_SwitchPos=(m_GUIArgs.Switch - 1) % NumChans; | |||||
| int o = m_SwitchPos+1; | |||||
| m_GUIArgs.Echo = o; | |||||
| SetOutput (0, n, o); | |||||
| o++; | |||||
| if (InputExists (o)) f=GetInput (o, n); | |||||
| else { | |||||
| m_GUIArgs.Auto = false; | |||||
| m_SwitchPos = m_GUIArgs.Switch; | |||||
| } | |||||
| if (m_SwitchPos > NumChans) m_SwitchPos = 1; | |||||
| m_GUIArgs.Echo = m_SwitchPos; | |||||
| SetOutput (0, n, m_SwitchPos); | |||||
| p = m_SwitchPos + 1; // SwitchPos 1 = Port 2, and so on | |||||
| if (InputExists (p)) f=GetInput (p, n); | |||||
| else f=0.0; | else f=0.0; | ||||
| SetOutput (1, n, f); | SetOutput (1, n, f); | ||||
| } | } | ||||
| @@ -32,13 +32,12 @@ class MixSwitchPlugin : public SpiralPlugin { | |||||
| virtual void ExecuteCommands(); | virtual void ExecuteCommands(); | ||||
| virtual void StreamOut (std::ostream &s); | virtual void StreamOut (std::ostream &s); | ||||
| virtual void StreamIn (std::istream &s); | virtual void StreamIn (std::istream &s); | ||||
| int GetSwitch (void) { return m_SwitchPos + 1; } | |||||
| int GetSwitch (void) { return m_SwitchPos; } | |||||
| int GetChans (void) { return m_PluginInfo.NumInputs - 2; } | int GetChans (void) { return m_PluginInfo.NumInputs - 2; } | ||||
| enum GUICommands {NONE, SETCHANS}; | |||||
| enum GUICommands { NONE, SETCHANS }; | |||||
| struct GUIArgs { | struct GUIArgs { | ||||
| int Chans; | |||||
| int Switch; | |||||
| int Echo; | |||||
| int Chans, Switch, Echo; | |||||
| bool Auto; | |||||
| }; | }; | ||||
| private: | private: | ||||
| GUIArgs m_GUIArgs; | GUIArgs m_GUIArgs; | ||||
| @@ -29,7 +29,7 @@ using namespace std; | |||||
| MixSwitchPluginGUI::MixSwitchPluginGUI (int w, int h, MixSwitchPlugin *o, ChannelHandler *ch, const HostInfo *Info) : | MixSwitchPluginGUI::MixSwitchPluginGUI (int w, int h, MixSwitchPlugin *o, ChannelHandler *ch, const HostInfo *Info) : | ||||
| SpiralPluginGUI (w, h, o, ch) | SpiralPluginGUI (w, h, o, ch) | ||||
| { | { | ||||
| m_Switch = new Fl_Counter (15, 14, 50, 20, "Select"); | |||||
| m_Switch = new Fl_Counter (11, 14, 58, 20, "Select"); | |||||
| m_Switch->labelsize (10); | m_Switch->labelsize (10); | ||||
| m_Switch->type (FL_SIMPLE_COUNTER); | m_Switch->type (FL_SIMPLE_COUNTER); | ||||
| m_Switch->box (FL_PLASTIC_UP_BOX); | m_Switch->box (FL_PLASTIC_UP_BOX); | ||||
| @@ -40,8 +40,9 @@ SpiralPluginGUI (w, h, o, ch) | |||||
| m_Switch->callback ((Fl_Callback*) cb_Switch); | m_Switch->callback ((Fl_Callback*) cb_Switch); | ||||
| add (m_Switch); | add (m_Switch); | ||||
| m_Chans = new Fl_Counter (15, 46, 50, 20, "Channels"); | |||||
| m_Chans->labelsize (10); | |||||
| m_Chans = new Fl_Counter (15, 50, 50, 15, "Channels"); | |||||
| m_Chans->labelsize (8); | |||||
| m_Chans->textsize (8); | |||||
| m_Chans->type (FL_SIMPLE_COUNTER); | m_Chans->type (FL_SIMPLE_COUNTER); | ||||
| m_Chans->box (FL_PLASTIC_UP_BOX); | m_Chans->box (FL_PLASTIC_UP_BOX); | ||||
| m_Chans->color (Info->GUI_COLOUR); | m_Chans->color (Info->GUI_COLOUR); | ||||
| @@ -80,8 +81,10 @@ void MixSwitchPluginGUI::cb_Switch (Fl_Counter* o, void* v) { | |||||
| } | } | ||||
| void MixSwitchPluginGUI::Update () { | void MixSwitchPluginGUI::Update () { | ||||
| int e = m_GUICH->GetInt ("Echo"); | |||||
| if (m_Switch->value () != e) m_Switch->value (e); | |||||
| if (m_GUICH->GetBool ("Auto")) { | |||||
| int e = m_GUICH->GetInt ("Echo"); | |||||
| if (m_Switch->value () != e) m_Switch->value (e); | |||||
| } | |||||
| } | } | ||||
| void MixSwitchPluginGUI::UpdateValues (SpiralPlugin *o) { | void MixSwitchPluginGUI::UpdateValues (SpiralPlugin *o) { | ||||
| @@ -40,6 +40,7 @@ public: | |||||
| // called while audio thread is suspended, so direct access to the | // called while audio thread is suspended, so direct access to the | ||||
| // spiralplugin is acceptable | // spiralplugin is acceptable | ||||
| virtual void UpdateValues(SpiralPlugin *o)=0; | virtual void UpdateValues(SpiralPlugin *o)=0; | ||||
| protected: | protected: | ||||
| ChannelHandler *m_GUICH; | ChannelHandler *m_GUICH; | ||||
| @@ -54,9 +54,14 @@ m_Triggered (false) | |||||
| m_PluginInfo.PortTips.push_back ("CV"); | m_PluginInfo.PortTips.push_back ("CV"); | ||||
| m_PluginInfo.PortTips.push_back ("Out 1"); | m_PluginInfo.PortTips.push_back ("Out 1"); | ||||
| m_PluginInfo.PortTips.push_back ("Out 2"); | m_PluginInfo.PortTips.push_back ("Out 2"); | ||||
| // Number of channels <- GUI | |||||
| m_AudioCH->Register ("Chans", &m_GUIArgs.Chans); | m_AudioCH->Register ("Chans", &m_GUIArgs.Chans); | ||||
| // Switch Position <- GUI | |||||
| m_AudioCH->Register ("Switch", &m_GUIArgs.Switch); | m_AudioCH->Register ("Switch", &m_GUIArgs.Switch); | ||||
| // Switch Position -> GUI | |||||
| m_AudioCH->Register ("Echo", &m_GUIArgs.Echo, ChannelHandler::OUTPUT); | m_AudioCH->Register ("Echo", &m_GUIArgs.Echo, ChannelHandler::OUTPUT); | ||||
| // Auto Mode (Switch position is controlled by CV or Clock = True, Switch Position controlled by GUI = False | |||||
| m_AudioCH->Register ("Auto", &m_GUIArgs.Auto, ChannelHandler::OUTPUT); | |||||
| } | } | ||||
| SplitSwitchPlugin::~SplitSwitchPlugin () { | SplitSwitchPlugin::~SplitSwitchPlugin () { | ||||
| @@ -106,10 +111,12 @@ void SplitSwitchPlugin::Execute() { | |||||
| if (InputExists (2)) { | if (InputExists (2)) { | ||||
| for (n=0; n<m_HostInfo->BUFSIZE; n++) { | for (n=0; n<m_HostInfo->BUFSIZE; n++) { | ||||
| if (InputExists (0)) { | if (InputExists (0)) { | ||||
| m_GUIArgs.Auto = true; | |||||
| // Check the Switch Pos CV Value | // Check the Switch Pos CV Value | ||||
| m_SwitchPos = abs (int (GetInput (0, n) - 1)) % NumChans; | |||||
| m_SwitchPos = int (GetInput (0, n)); | |||||
| } | } | ||||
| else if (InputExists (1)) { | else if (InputExists (1)) { | ||||
| m_GUIArgs.Auto = true; | |||||
| // Check the trigger CV value | // Check the trigger CV value | ||||
| if (GetInput (1, n) < 0.01) { | if (GetInput (1, n) < 0.01) { | ||||
| m_Triggered = false; | m_Triggered = false; | ||||
| @@ -117,15 +124,18 @@ void SplitSwitchPlugin::Execute() { | |||||
| else { | else { | ||||
| if (!m_Triggered) { | if (!m_Triggered) { | ||||
| m_Triggered = true; | m_Triggered = true; | ||||
| m_SwitchPos = (m_SwitchPos+1) % NumChans; | |||||
| m_SwitchPos = (m_SwitchPos+1); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else m_SwitchPos=(m_GUIArgs.Switch - 1) % NumChans; | |||||
| int o = m_SwitchPos+1; | |||||
| m_GUIArgs.Echo = o; | |||||
| SetOutput (0, n, o); | |||||
| SetOutput (o, n, GetInput (2, n)); | |||||
| else { | |||||
| m_GUIArgs.Auto = false; | |||||
| m_SwitchPos=(m_GUIArgs.Switch); | |||||
| } | |||||
| if (m_SwitchPos > NumChans) m_SwitchPos = 1; | |||||
| m_GUIArgs.Echo = m_SwitchPos; | |||||
| SetOutput (0, n, m_SwitchPos); | |||||
| SetOutput (m_SwitchPos, n, GetInput (2, n)); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -32,13 +32,12 @@ class SplitSwitchPlugin : public SpiralPlugin { | |||||
| virtual void ExecuteCommands (); | virtual void ExecuteCommands (); | ||||
| virtual void StreamOut (std::ostream &s); | virtual void StreamOut (std::ostream &s); | ||||
| virtual void StreamIn (std::istream &s); | virtual void StreamIn (std::istream &s); | ||||
| int GetSwitch (void) { return m_SwitchPos + 1; } | |||||
| int GetSwitch (void) { return m_SwitchPos; } | |||||
| int GetChans (void) { return m_PluginInfo.NumOutputs - 1; } | int GetChans (void) { return m_PluginInfo.NumOutputs - 1; } | ||||
| enum GUICommands {NONE, SETCHANS}; | |||||
| enum GUICommands { NONE, SETCHANS }; | |||||
| struct GUIArgs { | struct GUIArgs { | ||||
| int Chans; | |||||
| int Switch; | |||||
| int Echo; | |||||
| int Chans, Switch, Echo; | |||||
| bool Auto; | |||||
| }; | }; | ||||
| private: | private: | ||||
| GUIArgs m_GUIArgs; | GUIArgs m_GUIArgs; | ||||
| @@ -38,8 +38,9 @@ SpiralPluginGUI (w, h, o, ch) | |||||
| m_Switch->callback ((Fl_Callback*) cb_Switch); | m_Switch->callback ((Fl_Callback*) cb_Switch); | ||||
| add (m_Switch); | add (m_Switch); | ||||
| m_Chans = new Fl_Counter (15, 46, 50, 20, "Channels"); | |||||
| m_Chans->labelsize (10); | |||||
| m_Chans = new Fl_Counter (15, 50, 50, 15, "Channels"); | |||||
| m_Chans->labelsize (8); | |||||
| m_Chans->textsize (8); | |||||
| m_Chans->type (FL_SIMPLE_COUNTER); | m_Chans->type (FL_SIMPLE_COUNTER); | ||||
| m_Chans->box (FL_PLASTIC_UP_BOX); | m_Chans->box (FL_PLASTIC_UP_BOX); | ||||
| m_Chans->color (Info->GUI_COLOUR); | m_Chans->color (Info->GUI_COLOUR); | ||||
| @@ -77,8 +78,12 @@ void SplitSwitchPluginGUI::cb_Switch (Fl_Counter* o, void* v) { | |||||
| ((SplitSwitchPluginGUI*) (o->parent ())) -> cb_Switch_i (o, v); | ((SplitSwitchPluginGUI*) (o->parent ())) -> cb_Switch_i (o, v); | ||||
| } | } | ||||
| void SplitSwitchPluginGUI::Update () { | void SplitSwitchPluginGUI::Update () { | ||||
| m_Switch->value (m_GUICH->GetInt ("Echo")); | |||||
| if (m_GUICH->GetBool ("Auto")) { | |||||
| int e = m_GUICH->GetInt ("Echo"); | |||||
| if (m_Switch->value () != e) m_Switch->value (e); | |||||
| } | |||||
| } | } | ||||
| void SplitSwitchPluginGUI::UpdateValues (SpiralPlugin *o) { | void SplitSwitchPluginGUI::UpdateValues (SpiralPlugin *o) { | ||||