Fix Save/Version informationmaster
@@ -49,45 +49,144 @@ string SpiralPlugin_GetGroupName() | |||||
SplitterPlugin::SplitterPlugin() | SplitterPlugin::SplitterPlugin() | ||||
{ | { | ||||
m_PluginInfo.Name="Splitter"; | m_PluginInfo.Name="Splitter"; | ||||
m_PluginInfo.Width=220; | |||||
m_PluginInfo.Height=125; | |||||
m_PluginInfo.NumInputs=1; | |||||
m_PluginInfo.NumOutputs=4; | |||||
m_PluginInfo.PortTips.push_back("Input"); | |||||
m_PluginInfo.PortTips.push_back("Out one"); | |||||
m_PluginInfo.PortTips.push_back("Out two"); | |||||
m_PluginInfo.PortTips.push_back("Out three"); | |||||
m_PluginInfo.PortTips.push_back("Out four"); | |||||
m_PluginInfo.Width=80; | |||||
m_PluginInfo.Height=40; | |||||
m_Version = 2; | |||||
m_GUIArgs.ChannelCount = 4; | |||||
CreatePorts (); | |||||
m_AudioCH->Register ("ChannelCount", &m_GUIArgs.ChannelCount); | |||||
} | } | ||||
SplitterPlugin::~SplitterPlugin() | SplitterPlugin::~SplitterPlugin() | ||||
{ | { | ||||
} | } | ||||
void SplitterPlugin::CreatePorts (int n, bool AddPorts) | |||||
{ | |||||
int c; | |||||
char t[256]; | |||||
m_PluginInfo.NumInputs = 1; | |||||
m_PluginInfo.PortTips.push_back ("Input"); | |||||
m_PluginInfo.NumOutputs = n; | |||||
for (c=1; c<=n; c++) { | |||||
sprintf (t, "Out %d", c); | |||||
m_PluginInfo.PortTips.push_back (t); | |||||
} | |||||
if (AddPorts) { | |||||
for (int c=0; c<m_PluginInfo.NumInputs; c++) AddInput(); | |||||
for (int c=0; c<m_PluginInfo.NumOutputs; c++) AddOutput(); | |||||
} | |||||
} | |||||
void SplitterPlugin::SetChannelCount (int count) | |||||
{ | |||||
m_GUIArgs.ChannelCount = count; | |||||
UpdatePluginInfoWithHost(); | |||||
RemoveAllInputs (); | |||||
RemoveAllOutputs (); | |||||
m_PluginInfo.NumInputs = 0; | |||||
m_PluginInfo.NumOutputs = 0; | |||||
m_PluginInfo.PortTips.clear (); | |||||
CreatePorts (count, true); | |||||
UpdatePluginInfoWithHost (); | |||||
} | |||||
PluginInfo &SplitterPlugin::Initialise(const HostInfo *Host) | PluginInfo &SplitterPlugin::Initialise(const HostInfo *Host) | ||||
{ | { | ||||
return SpiralPlugin::Initialise(Host); | |||||
return SpiralPlugin::Initialise( Host); | |||||
} | } | ||||
SpiralGUIType *SplitterPlugin::CreateGUI() | SpiralGUIType *SplitterPlugin::CreateGUI() | ||||
{ | { | ||||
return NULL; | |||||
return new SplitterPluginGUI (m_PluginInfo.Width, m_PluginInfo.Height, this, m_AudioCH, m_HostInfo); | |||||
} | } | ||||
void SplitterPlugin::Execute() | void SplitterPlugin::Execute() | ||||
{ | { | ||||
// Just copy the data through. | // Just copy the data through. | ||||
GetOutputBuf(0)->Zero(); | |||||
GetOutputBuf(3)->Zero(); | |||||
GetOutputBuf(2)->Zero(); | |||||
GetOutputBuf(1)->Zero(); | |||||
for (int i=0; i<GetChannelCount(); i++) | |||||
{ | |||||
GetOutputBuf(i)->Zero(); | |||||
} | |||||
if (InputExists(0)) | if (InputExists(0)) | ||||
{ | { | ||||
GetOutputBuf(0)->Mix(*GetInput(0),0); | |||||
GetOutputBuf(1)->Mix(*GetInput(0),0); | |||||
GetOutputBuf(2)->Mix(*GetInput(0),0); | |||||
GetOutputBuf(3)->Mix(*GetInput(0),0); | |||||
for (int i=0; i<GetChannelCount(); i++) | |||||
{ | |||||
GetOutputBuf(i)->Mix(*GetInput(0),0); | |||||
} | |||||
} | } | ||||
} | } | ||||
void SplitterPlugin::ExecuteCommands () | |||||
{ | |||||
if (m_AudioCH->IsCommandWaiting ()) | |||||
{ | |||||
switch (m_AudioCH->GetCommand()) { | |||||
case SETCHANNELCOUNT : | |||||
{ | |||||
UpdatePluginInfoWithHost(); | |||||
RemoveAllInputs (); | |||||
RemoveAllOutputs (); | |||||
m_PluginInfo.NumInputs = 0; | |||||
m_PluginInfo.NumOutputs = 0; | |||||
m_PluginInfo.PortTips.clear (); | |||||
CreatePorts (m_GUIArgs.ChannelCount, true); | |||||
UpdatePluginInfoWithHost (); | |||||
} | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
void SplitterPlugin::StreamOut (ostream &s) | |||||
{ | |||||
s << m_Version << " " << GetChannelCount() << " "; | |||||
} | |||||
void SplitterPlugin::StreamIn (istream &s) | |||||
{ | |||||
char Test; | |||||
int Version, Channels; | |||||
s.seekg (2, ios_base::cur );//skip to next line | |||||
Test = s.peek();//peek first char | |||||
s.seekg (-2, ios_base::cur );//jump back to prior line | |||||
if ( (Test >= '0') && (Test <= '9') ) | |||||
{ | |||||
s >> Version; | |||||
} | |||||
else | |||||
{ | |||||
//No Version, so use Version 1 | |||||
Version = 1; | |||||
} | |||||
switch (Version) | |||||
{ | |||||
case 2: | |||||
{ | |||||
s >> Channels; | |||||
SetChannelCount (Channels); | |||||
} | |||||
break; | |||||
case 1: | |||||
{ | |||||
//use original fixed defaults | |||||
SetChannelCount (4); | |||||
} | |||||
break; | |||||
} | |||||
} |
@@ -29,12 +29,27 @@ public: | |||||
virtual ~SplitterPlugin(); | virtual ~SplitterPlugin(); | ||||
virtual PluginInfo& Initialise(const HostInfo *Host); | virtual PluginInfo& Initialise(const HostInfo *Host); | ||||
virtual SpiralGUIType* CreateGUI(); | |||||
virtual SpiralGUIType* CreateGUI (); | |||||
virtual void Execute(); | virtual void Execute(); | ||||
virtual void StreamOut(std::ostream &s) {} | |||||
virtual void StreamIn(std::istream &s) {} | |||||
virtual void ExecuteCommands(); | |||||
virtual void StreamOut(std::ostream &s); | |||||
virtual void StreamIn(std::istream &s); | |||||
int GetChannelCount (void) { return m_GUIArgs.ChannelCount; } | |||||
void SetChannelCount (int count); | |||||
enum GUICommands { NONE, SETCHANNELCOUNT }; | |||||
struct GUIArgs { | |||||
int ChannelCount; | |||||
}; | |||||
private: | private: | ||||
GUIArgs m_GUIArgs; | |||||
int m_Version; | |||||
void CreatePorts (int n = 4, bool AddPorts = false); | |||||
}; | }; | ||||
#endif | #endif |
@@ -27,18 +27,50 @@ using namespace std; | |||||
SplitterPluginGUI::SplitterPluginGUI(int w, int h,SplitterPlugin *o,ChannelHandler *ch,const HostInfo *Info) : | SplitterPluginGUI::SplitterPluginGUI(int w, int h,SplitterPlugin *o,ChannelHandler *ch,const HostInfo *Info) : | ||||
SpiralPluginGUI(w,h,o,ch) | SpiralPluginGUI(w,h,o,ch) | ||||
{ | { | ||||
m_Channels = new Fl_Counter (15, 20, 50, 15, "Channels"); | |||||
m_Channels->labelsize (8); | |||||
m_Channels->textsize (8); | |||||
m_Channels->type (FL_SIMPLE_COUNTER); | |||||
m_Channels->box (FL_PLASTIC_UP_BOX); | |||||
m_Channels->color (Info->GUI_COLOUR); | |||||
m_Channels->selection_color (Info->GUI_COLOUR); | |||||
m_Channels->step (1); | |||||
m_Channels->value (4); | |||||
m_Channels->callback ((Fl_Callback*) cb_Channels, this); | |||||
add (m_Channels); | |||||
end(); | end(); | ||||
} | } | ||||
void SplitterPluginGUI::Update() | |||||
{ | |||||
} | |||||
void SplitterPluginGUI::UpdateValues(SpiralPlugin *o) | void SplitterPluginGUI::UpdateValues(SpiralPlugin *o) | ||||
{ | { | ||||
SplitterPlugin* Plugin = (SplitterPlugin*)o; | |||||
m_Channels->value (Plugin->GetChannelCount()); | |||||
} | } | ||||
const string SplitterPluginGUI::GetHelpText(const string &loc){ | |||||
return string("") | |||||
+ "The simplest plugin - the splitter simply takes the input,\n" | |||||
+ "and duplicates it into it's outputs. Simple, but difficult\n" | |||||
+ "to do without.\n"; | |||||
inline void SplitterPluginGUI::cb_Channels_i (Fl_Counter* o) | |||||
{ | |||||
if (o->value() < 2) | |||||
{ | |||||
o->value(2); | |||||
} | |||||
else { | |||||
m_GUICH->Set ("ChannelCount", int (o->value ())); | |||||
m_GUICH->SetCommand (SplitterPlugin::SETCHANNELCOUNT); | |||||
m_GUICH->Wait (); | |||||
Resize (w(), h()); | |||||
} | |||||
} | |||||
const string SplitterPluginGUI::GetHelpText(const string &loc) | |||||
{ | |||||
return string("") | |||||
+ "The simplest plugin - the splitter simply takes the input,\n" | |||||
+ "and duplicates it into it's outputs. Simple, but difficult\n" | |||||
+ "to do without.\n"; | |||||
} | } |
@@ -17,6 +17,7 @@ | |||||
*/ | */ | ||||
#include <FL/Fl.H> | #include <FL/Fl.H> | ||||
#include <FL/Fl_Counter.H> | |||||
#include "SplitterPlugin.h" | #include "SplitterPlugin.h" | ||||
#include "../SpiralPluginGUI.h" | #include "../SpiralPluginGUI.h" | ||||
@@ -29,13 +30,16 @@ public: | |||||
SplitterPluginGUI(int w, int h, SplitterPlugin *o, ChannelHandler *ch, const HostInfo *Info); | SplitterPluginGUI(int w, int h, SplitterPlugin *o, ChannelHandler *ch, const HostInfo *Info); | ||||
virtual void UpdateValues(SpiralPlugin *o); | virtual void UpdateValues(SpiralPlugin *o); | ||||
virtual void Update (); | |||||
protected: | protected: | ||||
const std::string GetHelpText(const std::string &loc); | |||||
const std::string GetHelpText(const std::string &loc); | |||||
private: | private: | ||||
Fl_Counter *m_Channels; | |||||
//// Callbacks //// | |||||
inline void cb_Channels_i (Fl_Counter* o); | |||||
static void cb_Channels(Fl_Counter* o, SplitterPluginGUI* v) {v->cb_Channels_i(o);} | |||||
}; | }; | ||||
#endif | #endif |