diff --git a/SpiralSound/Plugins/JackPlugin/JackPlugin.C b/SpiralSound/Plugins/JackPlugin/JackPlugin.C index 05be8d6..53d6dce 100644 --- a/SpiralSound/Plugins/JackPlugin/JackPlugin.C +++ b/SpiralSound/Plugins/JackPlugin/JackPlugin.C @@ -18,6 +18,7 @@ #include #include +#include #include "JackPlugin.h" #include "JackPluginGUI.h" @@ -99,8 +100,8 @@ JackClient::JackClient() m_Attached = false; m_SampleRate = 0; m_BufferSize = 0; - m_JackInputCount = 8; - m_JackOutputCount = 8; + m_JackInputCount = 4; + m_JackOutputCount = 4; m_Client=NULL; } @@ -406,6 +407,8 @@ m_Connected(false) // we are an output m_IsTerminal = true; + m_Version = 2; + m_PluginInfo.Name="Jack"; m_PluginInfo.Width=225; m_PluginInfo.Height=230; @@ -415,6 +418,7 @@ m_Connected(false) m_PluginInfo.PortTips.clear(); m_PluginInfo.NumInputs = m_JackClient->GetJackOutputCount(); + m_GUIArgs.NumInputs = m_PluginInfo.NumInputs; for (int n=0; nGetJackInputCount(); n++) { @@ -424,6 +428,7 @@ m_Connected(false) } m_PluginInfo.NumOutputs = m_JackClient->GetJackOutputCount(); + m_GUIArgs.NumOutputs = m_PluginInfo.NumOutputs; for (int n=0; nGetJackOutputCount(); n++) { @@ -606,3 +611,51 @@ void JackPlugin::ExecuteCommands() } m_Connected=m_JackClient->IsAttached(); } + +void JackPlugin::StreamOut (ostream &s) +{ + s << m_Version << " " << m_GUIArgs.NumInputs << " " << m_GUIArgs.NumOutputs << " "; +} + +void JackPlugin::StreamIn (istream &s) +{ + char Test; + int Version, NumInputs, NumOutputs; + + 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 >> NumInputs >> NumOutputs; + m_GUIArgs.NumOutputs = min(max(NumOutputs, MIN_PORTS), MAX_PORTS); + m_GUIArgs.NumInputs = min(max(NumInputs, MIN_PORTS), MAX_PORTS); + + SetNumberPorts (m_GUIArgs.NumInputs, m_GUIArgs.NumOutputs); + } + break; + + case 1: + { + //use original fixed defaults + m_GUIArgs.NumInputs = 16; + m_GUIArgs.NumOutputs = 16; + + SetNumberPorts (m_GUIArgs.NumInputs, m_GUIArgs.NumOutputs); + } + break; + } +} diff --git a/SpiralSound/Plugins/JackPlugin/JackPlugin.h b/SpiralSound/Plugins/JackPlugin/JackPlugin.h index bf8b394..c9b052d 100644 --- a/SpiralSound/Plugins/JackPlugin/JackPlugin.h +++ b/SpiralSound/Plugins/JackPlugin/JackPlugin.h @@ -123,10 +123,12 @@ public: virtual PluginInfo& Initialise(const HostInfo *Host); virtual SpiralGUIType* CreateGUI(); + virtual void Execute(); virtual void ExecuteCommands(); - virtual void StreamOut(std::ostream &s) {} - virtual void StreamIn(std::istream &s) {} + + virtual void StreamOut(std::ostream &s); + virtual void StreamIn(std::istream &s); JackClient *GetJackClient() { return m_JackClient; } @@ -137,7 +139,6 @@ public: { int NumInputs; int NumOutputs; - int Num; char Port[256]; }; @@ -148,6 +149,8 @@ private: GUIArgs m_GUIArgs; + int m_Version; + // slightly clumsy, but we have to share this data with the gui int m_NumInputPortNames; char m_InputPortNames[MAX_PORTS][256]; diff --git a/SpiralSound/Plugins/JackPlugin/JackPluginGUI.C b/SpiralSound/Plugins/JackPlugin/JackPluginGUI.C index be0c857..747f310 100644 --- a/SpiralSound/Plugins/JackPlugin/JackPluginGUI.C +++ b/SpiralSound/Plugins/JackPlugin/JackPluginGUI.C @@ -144,6 +144,29 @@ SpiralPluginGUI(w,h,o,ch) void JackPluginGUI::UpdateValues(SpiralPlugin *o) { + //To make sure buttons match ports on loading a patch + if (! m_GUICH->GetBool("Connected")) + { + int i, numbuttons = (int) m_InputName.size(), numports = m_JackClient->GetJackInputCount(); + + if (numbuttons > numports) + { + for (int i=numbuttons-numports; i > 0; i--) + { + RemoveOutput() ; + RemoveInput() ; + } + } + + if (numbuttons < numports) + { + for (int i=0; i < numports-numbuttons; i++) + { + AddOutput() ; + AddInput() ; + } + } + } } void JackPluginGUI::Update() @@ -501,16 +524,17 @@ inline void JackPluginGUI::cb_InputConnect_i(Fl_Button* o) } } -const string JackPluginGUI::GetHelpText(const string &loc){ - return string("") - + "JACK is the Jack Audio Connection Kit, and allows multiple Linux audio\n" - + "apps to be connected together and run simultaneously in a low latency.\n" - + "environment.\n\n" - + "This plugin allows you to connect up to 64 inputs and outputs to other\n" - + "JACK apps (providing a server is running and your system can handle it)\n" - + "You can use the JackPlugin to connect the ports, or an external program\n" - + "such as the excellent qjackconnect app.\n\n" - + "When using JACK, make sure the buffer size and samplerate are set to\n" - + "match the JACK server, otherwise glitchy playback, and/or crashes may\n" - + "result"; +const string JackPluginGUI::GetHelpText(const string &loc) +{ + return string("") + + "JACK is the Jack Audio Connection Kit, and allows multiple Linux audio\n" + + "apps to be connected together and run simultaneously in a low latency.\n" + + "environment.\n\n" + + "This plugin allows you to connect up to 64 inputs and outputs to other\n" + + "JACK apps (providing a server is running and your system can handle it)\n" + + "You can use the JackPlugin to connect the ports, or an external program\n" + + "such as the excellent qjackconnect app.\n\n" + + "When using JACK, make sure the buffer size and samplerate are set to\n" + + "match the JACK server, otherwise glitchy playback, and/or crashes may\n" + + "result"; }