[SCM] calf/master: Update jackvis to keep up with times. Disable spring-mass layout for now.

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:40:14 UTC 2013


The following commit has been merged in the master branch:
commit 3a94de050550a8cd6069759690653cca536135e8
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Tue May 11 23:15:46 2010 +0100

    Update jackvis to keep up with times. Disable spring-mass layout for now.

diff --git a/bigbull/conndiagram.py b/bigbull/conndiagram.py
index 3d2030f..8303cf1 100644
--- a/bigbull/conndiagram.py
+++ b/bigbull/conndiagram.py
@@ -382,6 +382,7 @@ class ConnectionGraphEditor:
         return k * sign * (b1.x2 - b2.x1 + 1j * (b1.y1 - b2.y1))
         
     def blow_up(self):
+        return
         for m in self.modules:
             m.velocity = 0+0j
             m.bounds = m.group.get_bounds()
@@ -417,7 +418,8 @@ class ConnectionGraphEditor:
             for m1 in self.modules:
                 print "Velocity is (%s, %s)" % (m1.velocity.real, m1.velocity.imag)
                 m1.group.translate(step * m1.velocity.real, step * m1.velocity.imag)
-                m1.group.update(True, cr, m1.bounds)
+                m1.group.update(True, cr)
+                #m1.group.update(True, cr, m1.bounds)
                 m1.update_wires()
             damping *= 0.99
             temperature *= 0.99
diff --git a/bigbull/jackvis.py b/bigbull/jackvis.py
index 795e7cf..8acfdfd 100755
--- a/bigbull/jackvis.py
+++ b/bigbull/jackvis.py
@@ -1,32 +1,95 @@
 #!/usr/bin/python
 import pygtk
 pygtk.require('2.0')
+import dbus
 import gtk
-import calfpytools
 import conndiagram
 from calfgtkutils import *
-Colors = conndiagram.Colors        
+Colors = conndiagram.Colors
 
-class JACKGraphParser():
+class JACKPortInfo(object):
+    id = 0
+    name = ""
+    flags = 0
+    format = 0
+    
+    def __init__(self, full_name, id, name, flags, format):
+        self.full_name = full_name
+        self.client_name = full_name.split(":")[0]
+        self.id = int(id)
+        self.name = str(name)
+        self.flags = int(flags)
+        self.format = int(format)
+        
+    def get_name(self):
+        return self.name
+        
+    def get_full_name(self):
+        return self.full_name
+        
+    def get_type(self):
+        return self.format
+        
+    def is_port_input(self):
+        return (self.flags & 1) != 0
+    
+    def is_port_output(self):
+        return (self.flags & 2) != 0
+    
+class JACKClientInfo(object):
+    id = 0
+    name = ""
+    def __init__(self, id, name, ports):
+        self.id = id
+        self.name = name
+        self.ports = [JACKPortInfo("%s:%s" % (name, p[1]), *p) for p in ports]
+    
+class JACKGraphInfo(object):
+    version = 0
+    clients = []
+    client_map = {}
+    connections_id = set()
+    connections_name = set()
+    def __init__(self, version, clients, connections):
+        self.version = version
+        self.clients = [JACKClientInfo(*c) for c in clients]
+        self.client_map = {}
+        for c in self.clients:
+            self.client_map[c.name] = c
+        self.connections_id = set()
+        self.connections_name = set()
+        for (cid1, cname1, pid1, pname1, cid2, cname2, pid2, pname2, something) in connections:
+            self.connections_name.add(("%s:%s" % (cname1, pname1), "%s:%s" % (cname2, pname2)))
+            self.connections_id.add(("%s:%s" % (cid1, pid1), "%s:%s" % (cid2, pid2)))
+
+class JACKGraphParser(object):
     def __init__(self):
-        self.client = calfpytools.JackClient()
-        self.client.open("jackvis")
+        self.bus = dbus.SessionBus()
+        self.service = self.bus.get_object("org.jackaudio.service", "/org/jackaudio/Controller")
+        self.patchbay = dbus.Interface(self.service, "org.jackaudio.JackPatchbay")
+        self.graph = None
+        self.fetch_graph()
     def get_port_color(self, portData):
-        if portData.get_type() == calfpytools.JACK_DEFAULT_AUDIO_TYPE:
+        if portData.get_type() == 0:
             color = Colors.audioPort
-        if portData.get_type() == calfpytools.JACK_DEFAULT_MIDI_TYPE:
+        elif portData.get_type() == 1:
             color = Colors.eventPort
+        else:
+            print "Unknown type %s" % portData.get_type()
         return color
     def is_port_input(self, portData):
-        return (portData.get_flags() & calfpytools.JackPortIsInput) != 0
+        return portData.is_port_input()
     def get_port_name(self, portData):
         return portData.get_name()
     def get_port_id(self, portData):
         return portData.get_full_name()
     def get_module_name(self, moduleData):
         return moduleData.name
+    def fetch_graph(self):
+        self.graph = JACKGraphInfo(*self.patchbay.GetGraph(self.graph.known_version if self.graph is not None else 0))
     def get_module_port_list(self, moduleData):
-        return [(port, self.client.get_port(port)) for port in self.client.get_ports(moduleData.name+":.*", moduleData.type, moduleData.flags)]
+        g = self.graph.client_map[moduleData.name]
+        return [(port.get_full_name(), port) for port in g.ports if moduleData.checker(port)]
     def can_connect(self, first, second):
         if self.is_port_input(first) == self.is_port_input(second):
             return False
@@ -34,14 +97,15 @@ class JACKGraphParser():
             return False
         return True
     def connect(self, first, second):
-        if self.client.connect(first.get_full_name(), second.get_full_name()) != True:
-            raise RuntimeError, "Connection error"
+        self.patchbay.ConnectPortsByName(first.client_name, first.name, second.client_name, second.name)
     def disconnect(self, name_first, name_second):
-        self.client.disconnect(name_first, name_second)
+        first = name_first.split(":")
+        second = name_second.split(":")
+        self.patchbay.DisconnectPortsByName(first[0], first[1], second[0], second[1])
         
-class JACKClientData():
-    def __init__(self, name, type, flags):
-        (self.name, self.type, self.flags) = (name, type, flags)
+class ClientBoxInfo():
+    def __init__(self, name, checker):
+        (self.name, self.checker) = (name, checker)
 
 class App:
     def __init__(self):
@@ -90,29 +154,24 @@ class App:
         self.main_vbox.connect("popup-menu", self.canvas_popup_menu_handler)
         self.cgraph.canvas.connect("button-press-event", self.canvas_button_press_handler)
         self.cgraph.canvas.update()
-        self.add_clients(0.0, 0.0, calfpytools.JackPortIsOutput)
-        self.add_clients(200, 0.0, calfpytools.JackPortIsInput)
+        self.add_clients(0.0, 0.0, lambda port: port.is_port_output())
+        self.add_clients(200, 0.0, lambda port: port.is_port_input())
         self.cgraph.canvas.update()
         self.add_wires()
         self.cgraph.blow_up()
         
-    def add_clients(self, x, y, flags):
-        ports = self.parser.client.get_ports("", "", flags)
-        clients = set([p.split(":")[0] for p in ports])
-        for cl in clients:
-            y += self.cgraph.add_module(JACKClientData(cl, "", flags), x, y).rect.props.height
+    def add_clients(self, x, y, checker):
+        for cl in self.parser.graph.clients:
+            y += self.cgraph.add_module(ClientBoxInfo(cl.name, checker), x, y).rect.props.height
         
     def add_wires(self):
-        ports = self.parser.client.get_ports("", "", calfpytools.JackPortIsInput)
         pmap = self.cgraph.get_port_map()
-        for p in ports:
-            conns = self.parser.client.get_port(p).get_connections()
-            for c in conns:
-                if p in pmap and c in pmap:
-                    print "Connect %s to %s" % (c, p)
-                    self.cgraph.connect(pmap[c], pmap[p])
-                else:
-                    print "Connect %s to %s - not found" % (c, p)
+        for (c, p) in self.parser.graph.connections_name:
+            if p in pmap and c in pmap:
+                print "Connect %s to %s" % (c, p)
+                self.cgraph.connect(pmap[c], pmap[p])
+            else:
+                print "Connect %s to %s - not found" % (c, p)
 
     def create_main_menu(self):
         self.menu_bar = gtk.MenuBar()

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list