コード例 #1
0
ファイル: pd-patchwatch.py プロジェクト: valrus/pd-patchwatch
    def removeObjectAt(self, index):
        objectToRemove = self.objects[index]
        # Remove this object's inbound connections from other objects
        for outSocket in objectToRemove.inlets.values():
            self.objects[outSocket.index].outlets.pop(outSocket.position)
        # Remove this object's outbound connections from other objects
        for inSocket in objectToRemove.outlets.values():
            self.objects[inSocket.index].inlets.pop(inSocket.position)

        # Find this object and remove it
        self.pd.send(" ".join(["find", objectToRemove.name, "1"]))
        for i in range(sum(obj.name == objectToRemove.name
                       for obj in self.objects[:index])):
            self.pd.send("findagain")
        self.pd.send("cut")

        # Adjust indices of removed object's outgoing sockets to higher indices
        for pos, outgoingSocket in objectToRemove.outlets.items():
            if outgoingSocket.index >= index:
                fixedSocket = pdgui.socket(outgoingSocket.index - 1,
                                           outgoingSocket.position)
                self._connectSockets(pdgui.socket(index, pos), fixedSocket,
                                     twoWay=False)

        # Adjust all incoming connections to objects after the removed one
        for i, obj in enumerate(self.objects[index + 1:]):
            for pos, incomingSocket in obj.inlets.items():
                fixedSocket = pdgui.socket(i + index, pos)
                self._connectSockets(incomingSocket, fixedSocket,
                                     twoWay=False)

        return self.objects.pop(index)
コード例 #2
0
ファイル: pd-patchwatch.py プロジェクト: valrus/pd-patchwatch
 def _chainConnect(self, newObjIndex, channel):
     # disconnect dac from previous patch
     toIndex = self.outs[channel]
     outObj = self.patch.getObj(toIndex)
     previousOutlet = outObj.inlets[0]
     self.patch.disconnect(previousOutlet,
                           pdgui.socket(toIndex, 0))
     # connect previous patch to new patch
     self.patch.connect(previousOutlet,
                        pdgui.socket(newObjIndex, 0))
     # connect new patch to dac
     self.patch.connect(pdgui.socket(newObjIndex, 0),
                        pdgui.socket(self.outs[channel], 0))
コード例 #3
0
ファイル: pd-patchwatch.py プロジェクト: valrus/pd-patchwatch
 def found_connect(self, canvasStack, type, action, args):
     obj1, outlet, obj2, inlet = map(int, args.split())
     self._connectSockets(pdgui.socket(obj1, outlet),
                          pdgui.socket(obj2, inlet))