Browse Source

More work for patchbay, now working for JACK driver

tags/1.9.4
falkTX 11 years ago
parent
commit
00f912dcff
8 changed files with 290 additions and 16 deletions
  1. +8
    -0
      resources/resources.qrc
  2. +13
    -0
      source/backend/CarlaEngine.hpp
  3. +3
    -0
      source/backend/CarlaStandalone.hpp
  4. +13
    -0
      source/backend/engine/CarlaEngine.cpp
  5. +190
    -14
      source/backend/engine/CarlaEngineJack.cpp
  6. +20
    -0
      source/backend/standalone/CarlaStandalone.cpp
  7. +31
    -2
      source/carla.py
  8. +12
    -0
      source/carla_backend.py

+ 8
- 0
resources/resources.qrc View File

@@ -71,5 +71,13 @@
<file>bitmaps/led_yellow.png</file>
<file>bitmaps/led-big_on.png</file>
<file>bitmaps/led-big_off.png</file>

<file>scalable/pb_generic.svg</file>
<file>scalable/pb_hardware.svg</file>
<file>scalable/pb_audacious.svg</file>
<file>scalable/pb_clementine.svg</file>
<file>scalable/pb_jamin.svg</file>
<file>scalable/pb_mplayer.svg</file>
<file>scalable/pb_vlc.svg</file>
</qresource>
</RCC>

+ 13
- 0
source/backend/CarlaEngine.hpp View File

@@ -854,6 +854,19 @@ public:
*/
void setCallback(const CallbackFunc func, void* const ptr);

// -------------------------------------------------------------------
// Patchbay

/*!
* TODO.
*/
virtual void patchbayConnect(int portA, int portB);

/*!
* TODO.
*/
virtual void patchbayDisconnect(int connectionId);

// -------------------------------------------------------------------
// Transport



+ 3
- 0
source/backend/CarlaStandalone.hpp View File

@@ -170,6 +170,9 @@ CARLA_EXPORT void carla_set_engine_option(CarlaOptionsType option, int value, co
CARLA_EXPORT bool carla_load_project(const char* filename);
CARLA_EXPORT bool carla_save_project(const char* filename);

CARLA_EXPORT void carla_patchbay_connect(int portA, int portB);
CARLA_EXPORT void carla_patchbay_disconnect(int connectionId);

CARLA_EXPORT void carla_transport_play();
CARLA_EXPORT void carla_transport_pause();
CARLA_EXPORT void carla_transport_relocate(uint32_t frames);


+ 13
- 0
source/backend/engine/CarlaEngine.cpp View File

@@ -1138,6 +1138,19 @@ void CarlaEngine::setCallback(const CallbackFunc func, void* const ptr)
kData->callbackPtr = ptr;
}

// -----------------------------------------------------------------------
// Patchbay

void CarlaEngine::patchbayConnect(int portA, int portB)
{
// TODO
}

void CarlaEngine::patchbayDisconnect(int connectionId)
{
// TODO
}

// -----------------------------------------------------------------------
// Transport



+ 190
- 14
source/backend/engine/CarlaEngineJack.cpp View File

@@ -578,6 +578,18 @@ public:
jackbridge_set_latency_callback(fClient, carla_jack_latency_callback, this);
jackbridge_on_shutdown(fClient, carla_jack_shutdown_callback, this);

const char* const jackClientName = jackbridge_get_client_name(fClient);

initJackPatchbay(jackClientName);

// TODO - update jackbridge
jack_set_client_registration_callback(fClient, carla_jack_client_registration_callback, this);
jack_set_port_registration_callback(fClient, carla_jack_port_registration_callback, this);
jack_set_port_connect_callback(fClient, carla_jack_port_connect_callback, this);

if (jack_set_port_rename_callback)
jack_set_port_rename_callback(fClient, carla_jack_port_rename_callback, this);

if (fOptions.processMode == PROCESS_MODE_CONTINUOUS_RACK)
{
fRackPorts[rackPortAudioIn1] = jackbridge_port_register(fClient, "audio-in1", JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0);
@@ -588,18 +600,8 @@ public:
fRackPorts[rackPortEventOut] = jackbridge_port_register(fClient, "events-out", JACK_DEFAULT_MIDI_TYPE, JackPortIsOutput, 0);
}

// TODO - update jackbridge
jack_set_client_registration_callback(fClient, carla_jack_client_registration_callback, this);
jack_set_port_registration_callback(fClient, carla_jack_port_registration_callback, this);
jack_set_port_connect_callback(fClient, carla_jack_port_connect_callback, this);

if (jack_set_port_rename_callback)
jack_set_port_rename_callback(fClient, carla_jack_port_rename_callback, this);

if (jackbridge_activate(fClient) == 0)
{
const char* const jackClientName = jackbridge_get_client_name(fClient);

return CarlaEngine::init(jackClientName);
}
else
@@ -723,6 +725,40 @@ public:
return new CarlaEngineJackClient(kEngineTypeJack, fOptions.processMode, client);
}

#ifndef BUILD_BRIDGE
// -------------------------------------------------------------------
// Patchbay

void patchbayConnect(int portA, int portB)
{
if (fClient == nullptr)
return;

const char* const portNameA = getFullPortName(portA).toUtf8().constData();
const char* const portNameB = getFullPortName(portB).toUtf8().constData();

jack_connect(fClient, portNameA, portNameB);
}

void patchbayDisconnect(int connectionId)
{
if (fClient == nullptr)
return;

for (int i=0, count=fUsedConnections.count(); i < count; i++)
{
if (fUsedConnections[i].id == connectionId)
{
const char* const portNameA = getFullPortName(fUsedConnections[i].portOut).toUtf8().constData();
const char* const portNameB = getFullPortName(fUsedConnections[i].portIn).toUtf8().constData();

jack_disconnect(fClient, portNameA, portNameB);
break;
}
}
}
#endif

// -------------------------------------------------------------------
// Transport

@@ -1108,6 +1144,8 @@ protected:
QString groupName = fullName.split(":").at(0);
int groupId = getGroupId(groupName);

carla_stderr2("---------------------------------------------------- groupName: \"%s\", ID: %i", groupName.toUtf8().constData(), groupId);

const char* portName = jack_port_short_name(jackPort);

if (reg)
@@ -1120,9 +1158,10 @@ protected:
portFlags |= portIsAudio ? PATCHBAY_PORT_IS_AUDIO : PATCHBAY_PORT_IS_MIDI;

PortNameToId portNameToId;
portNameToId.groupId = groupId;
portNameToId.portId = fLastPortId;
portNameToId.name = portName;
portNameToId.groupId = groupId;
portNameToId.portId = fLastPortId;
portNameToId.name = portName;
portNameToId.fullName = fullName;

fUsedPortNames.append(portNameToId);
callback(CALLBACK_PATCHBAY_PORT_ADDED, 0, groupId, fLastPortId, portFlags, portName);
@@ -1175,8 +1214,25 @@ protected:
}
}

int handleJackPortRenameCallback(jack_port_id_t port, const char* oldName, const char* newName)
void handleJackPortRenameCallback(jack_port_id_t port, const char* oldName, const char* newName)
{
jack_port_t* jackPort = jack_port_by_id(fClient, port);

QString fullName(oldName);
QString groupName = fullName.split(":").at(0);
int groupId = getGroupId(groupName);

const char* portName = jack_port_short_name(jackPort);

for (int i=0, count=fUsedPortNames.count(); i < count; i++)
{
if (fUsedPortNames[i].groupId == groupId && fUsedPortNames[i].name == portName)
{
callback(CALLBACK_PATCHBAY_PORT_RENAMED, 0, fUsedPortNames[i].portId, 0, 0.0f, newName);
fUsedPortNames[i].name = newName;
break;
}
}
}
#endif

@@ -1228,6 +1284,7 @@ private:
int groupId;
int portId;
QString name;
QString fullName;
};

struct ConnectionToId {
@@ -1273,6 +1330,125 @@ private:

return -1;
}

QString& getFullPortName(int portId)
{
static QString fallbackString;

for (int i=0, count=fUsedPortNames.count(); i < count; i++)
{
if (fUsedPortNames[i].portId == portId)
{
return fUsedPortNames[i].fullName;
}
}

return fallbackString;
}

void initJackPatchbay(const char* const ourName)
{
// query initial jack ports
QList<QString> parsedGroups;

// our client
{
GroupNameToId groupNameToId;
groupNameToId.id = fLastGroupId;
groupNameToId.name = ourName;

callback(CALLBACK_PATCHBAY_CLIENT_ADDED, 0, fLastGroupId, 0, 0.0f, ourName);
fUsedGroupNames.append(groupNameToId);
fLastGroupId++;

parsedGroups.append(QString(ourName));
}

if (const char** ports = jack_get_ports(fClient, nullptr, nullptr, 0))
{
for (int i=0; ports[i] != nullptr; i++)
{
jack_port_t* jackPort = jack_port_by_name(fClient, ports[i]);
const char* portName = jack_port_short_name(jackPort);

QString fullName(ports[i]);
QString groupName(fullName.split(":").at(0));
int groupId = -1;

if (groupName == ourName)
continue;

if (parsedGroups.contains(groupName))
{
groupId = getGroupId(groupName);
}
else
{
groupId = fLastGroupId++;

GroupNameToId groupNameToId;
groupNameToId.id = groupId;
groupNameToId.name = groupName;

fUsedGroupNames.append(groupNameToId);
parsedGroups.append(groupName);

callback(CALLBACK_PATCHBAY_CLIENT_ADDED, 0, groupId, 0, 0.0f, groupName.toUtf8().constData());
}

bool portIsInput = (jack_port_flags(jackPort) & JackPortIsInput);
bool portIsAudio = (std::strcmp(jack_port_type(jackPort), JACK_DEFAULT_AUDIO_TYPE) == 0);

unsigned int portFlags = 0x0;
portFlags |= portIsInput ? PATCHBAY_PORT_IS_INPUT : PATCHBAY_PORT_IS_OUTPUT;
portFlags |= portIsAudio ? PATCHBAY_PORT_IS_AUDIO : PATCHBAY_PORT_IS_MIDI;

PortNameToId portNameToId;
portNameToId.groupId = groupId;
portNameToId.portId = fLastPortId;
portNameToId.name = portName;
portNameToId.fullName = fullName;

fUsedPortNames.append(portNameToId);
callback(CALLBACK_PATCHBAY_PORT_ADDED, 0, groupId, fLastPortId, portFlags, portName);
fLastPortId++;
}

jack_free(ports);
}

// query connections, after all ports are in place
if (const char** ports = jack_get_ports(fClient, nullptr, nullptr, JackPortIsOutput))
{
for (int i=0; ports[i] != nullptr; i++)
{
jack_port_t* jackPort = jack_port_by_name(fClient, ports[i]);

int thisPortId = getPortId(QString(ports[i]));

if (const char** jackConnections = jack_port_get_connections(jackPort))
{
for (int j=0; jackConnections[j] != nullptr; j++)
{
int targetPortId = getPortId(QString(jackConnections[j]));

ConnectionToId connectionToId;
connectionToId.id = fLastConnectionId;
connectionToId.portOut = thisPortId;
connectionToId.portIn = targetPortId;

fUsedConnections.append(connectionToId);
callback(CALLBACK_PATCHBAY_CONNECTION_ADDED, 0, fLastConnectionId, thisPortId, targetPortId, nullptr);
fLastConnectionId++;
}

jack_free(jackConnections);
}
}

jack_free(ports);
}
}
#endif

// -------------------------------------


+ 20
- 0
source/backend/standalone/CarlaStandalone.cpp View File

@@ -479,6 +479,26 @@ bool carla_save_project(const char* filename)

// -------------------------------------------------------------------------------------------------------------------

void carla_patchbay_connect(int portA, int portB)
{
carla_debug("carla_patchbay_connect(%i, %i)", portA, portB);
CARLA_ASSERT(standalone.engine != nullptr);

if (standalone.engine != nullptr)
return standalone.engine->patchbayConnect(portA, portB);
}

void carla_patchbay_disconnect(int connectionId)
{
carla_debug("carla_patchbay_disconnect(%i)", connectionId);
CARLA_ASSERT(standalone.engine != nullptr);

if (standalone.engine != nullptr)
return standalone.engine->patchbayDisconnect(connectionId);
}

// -------------------------------------------------------------------------------------------------------------------

void carla_transport_play()
{
carla_debug("carla_transport_play()");


+ 31
- 2
source/carla.py View File

@@ -1429,8 +1429,37 @@ class CarlaMainW(QMainWindow):

# ------------------------------------------------------------------------------------------------

def canvasCallback(self, action, value1, value2, valueStr):
print(action, value1, value2, valueStr)
def canvasCallback(action, value1, value2, valueStr):
if action == patchcanvas.ACTION_GROUP_INFO:
pass

elif action == patchcanvas.ACTION_GROUP_RENAME:
pass

elif action == patchcanvas.ACTION_GROUP_SPLIT:
groupId = value1
patchcanvas.splitGroup(groupId)

elif action == patchcanvas.ACTION_GROUP_JOIN:
groupId = value1
patchcanvas.joinGroup(groupId)

elif action == patchcanvas.ACTION_PORT_INFO:
pass

elif action == patchcanvas.ACTION_PORT_RENAME:
pass

elif action == patchcanvas.ACTION_PORTS_CONNECT:
portIdA = value1
portIdB = value2

Carla.host.patchbay_connect(portIdA, portIdB)

elif action == patchcanvas.ACTION_PORTS_DISCONNECT:
connectionId = value1

Carla.host.patchbay_disconnect(connectionId)

def engineCallback(ptr, action, pluginId, value1, value2, value3, valueStr):
if pluginId < 0 or not Carla.gui:


+ 12
- 0
source/carla_backend.py View File

@@ -191,6 +191,12 @@ class Host(object):
self.lib.carla_save_project.argtypes = [c_char_p]
self.lib.carla_save_project.restype = c_bool

self.lib.carla_patchbay_connect.argtypes = [c_int, c_int]
self.lib.carla_patchbay_connect.restype = None

self.lib.carla_patchbay_disconnect.argtypes = [c_int]
self.lib.carla_patchbay_disconnect.restype = None

self.lib.carla_transport_play.argtypes = None
self.lib.carla_transport_play.restype = None

@@ -410,6 +416,12 @@ class Host(object):
def save_project(self, filename):
return self.lib.carla_save_project(filename.encode("utf-8"))

def patchbay_connect(self, portIdA, portIdB):
self.lib.carla_patchbay_connect(portIdA, portIdB)

def patchbay_disconnect(self, connectionId):
self.lib.carla_patchbay_disconnect(connectionId)

def transport_play(self):
self.lib.carla_transport_play()



Loading…
Cancel
Save