@@ -18,6 +18,7 @@ | |||
#include <stdio.h> | |||
#include <limits.h> | |||
#include <math.h> | |||
#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; n<m_JackClient->GetJackInputCount(); n++) | |||
{ | |||
@@ -424,6 +428,7 @@ m_Connected(false) | |||
} | |||
m_PluginInfo.NumOutputs = m_JackClient->GetJackOutputCount(); | |||
m_GUIArgs.NumOutputs = m_PluginInfo.NumOutputs; | |||
for (int n=0; n<m_JackClient->GetJackOutputCount(); 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; | |||
} | |||
} |
@@ -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]; | |||
@@ -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"; | |||
} |