Skip to content

Commit

Permalink
Send position updates to metadata, matching carla
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <falktx@falktx.com>
  • Loading branch information
falkTX committed Aug 5, 2020
1 parent fde86f1 commit b54f8b3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
29 changes: 21 additions & 8 deletions src/catia.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,14 @@ def canvasCallback(self, action, value1, value2, valueStr):
elif action == patchcanvas.ACTION_GROUP_POSITION:
groupId = value1
x1, y1, x2, y2 = tuple(int(i) for i in valueStr.split(":"))
#host.patchbay_set_group_pos(gCarla.gui.fExternalPatchbay, groupId, x1, y1, x2, y2)
groupName, groupType = self.canvas_getGroupNameAndType(groupId)
if groupType != GROUP_TYPE_JACK:
return
uuidstr = jacklib.get_uuid_for_client_name(gJack.client, groupName)
if uuidstr is None:
return
value = "%i:%i:%i:%i" % (x1, y1, x2, y2)
jacklib.set_property(gJack.client, jacklib.uuid_parse(uuidstr), URI_POSITION, value, "text/plain")

elif action == patchcanvas.ACTION_PORT_INFO:
portId = value1
Expand Down Expand Up @@ -358,7 +365,7 @@ def canvasCallback(self, action, value1, value2, valueStr):
portPtr = jacklib.port_by_name(gJack.client, portNameR)
portFlags = jacklib.port_flags(portPtr)
groupName = portNameR.split(":", 1)[0]
portShortName = str(jacklib.port_short_name(portPtr), encoding="utf-8")
portShortName = jacklib.port_short_name(portPtr)

aliases = jacklib.port_get_aliases(portPtr)
if aliases[0] == 1:
Expand All @@ -385,7 +392,7 @@ def canvasCallback(self, action, value1, value2, valueStr):

flagsText = " | ".join(flags)

portTypeStr = str(jacklib.port_type(portPtr), encoding="utf-8")
portTypeStr = jacklib.port_type(portPtr)
if portTypeStr == jacklib.JACK_DEFAULT_AUDIO_TYPE:
typeText = self.tr("JACK Audio")
elif portTypeStr == jacklib.JACK_DEFAULT_MIDI_TYPE:
Expand Down Expand Up @@ -737,6 +744,12 @@ def canvas_getGroupId(self, groupName):
return group[iGroupId]
return -1

def canvas_getGroupNameAndType(self, groupId):
for group in self.fGroupList:
if group[iGroupId] == groupId:
return group[iGroupName], group[iGroupType]
return "", GROUP_TYPE_NULL

def canvas_addAlsaGroup(self, alsaGroupId, groupName, hwSplit):
groupId = self.fLastGroupId

Expand Down Expand Up @@ -872,7 +885,7 @@ def canvas_addJackPort(self, portPtr, portName):
else:
portShortName = portName.replace("%s:" % groupName, "", 1)

portTypeStr = str(jacklib.port_type(portPtr), encoding="utf-8")
portTypeStr = jacklib.port_type(portPtr)
if portTypeStr == jacklib.JACK_DEFAULT_AUDIO_TYPE:
portType = patchcanvas.PORT_TYPE_AUDIO_JACK
elif portTypeStr == jacklib.JACK_DEFAULT_MIDI_TYPE:
Expand Down Expand Up @@ -1204,7 +1217,7 @@ def slot_ClientRenameCallback(self, oldName, newName):
@pyqtSlot(int, bool)
def slot_PortRegistrationCallback(self, portIdJack, registerYesNo):
portPtr = jacklib.port_by_id(gJack.client, portIdJack)
portNameR = str(jacklib.port_name(portPtr), encoding="utf-8")
portNameR = jacklib.port_name(portPtr)

if registerYesNo:
self.canvas_addJackPort(portPtr, portNameR)
Expand All @@ -1222,8 +1235,8 @@ def slot_PortRegistrationCallback(self, portIdJack, registerYesNo):
def slot_PortConnectCallback(self, portIdJackA, portIdJackB, connectYesNo):
portPtrA = jacklib.port_by_id(gJack.client, portIdJackA)
portPtrB = jacklib.port_by_id(gJack.client, portIdJackB)
portRealNameA = str(jacklib.port_name(portPtrA), encoding="utf-8")
portRealNameB = str(jacklib.port_name(portPtrB), encoding="utf-8")
portRealNameA = jacklib.port_name(portPtrA)
portRealNameB = jacklib.port_name(portPtrB)

if connectYesNo:
self.canvas_connectPortsByName(portRealNameA, portRealNameB)
Expand All @@ -1233,7 +1246,7 @@ def slot_PortConnectCallback(self, portIdJackA, portIdJackB, connectYesNo):
@pyqtSlot(int, str, str)
def slot_PortRenameCallback(self, portIdJack, oldName, newName):
portPtr = jacklib.port_by_id(gJack.client, portIdJack)
portShortName = str(jacklib.port_short_name(portPtr), encoding="utf-8")
portShortName = jacklib.port_short_name(portPtr)

for port in self.fPortList:
if port[iPortNameR] == oldName:
Expand Down
10 changes: 5 additions & 5 deletions src/jacklib/jacklib.py
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ def port_flags(port):


def port_type(port):
return jlib.jack_port_type(port)
return _d(jlib.jack_port_type(port))


# JACK2 only:
Expand Down Expand Up @@ -1911,12 +1911,12 @@ def remove_port_property(client, port, key, encoding=ENCODING):


def set_property(client, subject, key, value, type=None, encoding=ENCODING):
if type and encoding:
type = _e(type, encoding)

if value and encoding:
if value is not None and encoding:
value = _e(value, encoding)

if type is not None and encoding:
type = _e(type, encoding)

return jlib.jack_set_property(client, subject, _e(key, encoding), value, type)


Expand Down

0 comments on commit b54f8b3

Please sign in to comment.