A first little report on some preparations and a night work to read the Jack connection information (Linux Audio) from a saved "Carla" state and putting it into a [BWise] connected block form. I used the first procedure from [A little XML parser] to read and somewhat verify the integrity of the XML data. # # read the (test) "Carla" input file with as the last part the "patchbay" # XML information describing the Jack (audio) connections # as "source/target" pairs with additional pin names set xmltext "" set xmlf [open test.carxp] while {[eof $xmlf] == 0} { append xmltext "[gets $xmlf]\n" } close $xmlf # Use [RS]'s "xml2list" procedure to read all the connections in "xmlo" set count 0; set xmlo "" foreach i [lindex [lrange [ xml2list [string range $xmltext [string first "" $xmltext] [ expr [string first "" $xmltext] + [string length ""]]] ] 1 end] 1] { if {[lindex [lindex [lindex $i 2] 1] 0] == "Target" && [lindex [lindex [lindex $i 2] 0] 0] == "Source"} { append xmlo "[lindex [lindex [lindex [lindex [lindex $i 2] 0] end] 0] end],[lindex [lindex [lindex [lindex [lindex $i 2] 1] end] 0] end]\n" incr count } } # Jack(d) named audio connection can contain most characters (no . and ! I think) # BWise block and pin names want only alnums and _s proc stringtoblockname { {str} } { set o "" foreach i [split $str {}] { if {[string is alnum $i] || $i == "_"} { append o $i } { append o "_" } } return [string tolower $o] } # Read through the xmlo lines with 4 names for a connection # (2 blocks, 2 pins) and create array entries per unique # block name and list all the connected pins (in or out) array unset xmlins array unset xmlouts foreach i [split $xmlo '\n'] { if {$i != "" } { lappend xmlouts([lindex [split [lindex [split $i ','] 0] ':'] 0]) [lindex [split [lindex [split $i ','] 0] ':'] 1] lappend xmlins([lindex [split [lindex [split $i ','] 1] ':'] 0]) [lindex [split [lindex [split $i ','] 1] ':'] 1] } } # Create BWise blocks from the above gathered info # simply all on a row, but with the correct number of # pins and simplified block names # and a special "testxml" additional canvas tag set ix 50 foreach i [lsort -uni [concat [array names xmlins] [array names xmlouts]]] { set ins {}; set outs {} if [info exists xmlins($i) ] { foreach j [lsort -unique $xmlins($i)] { lappend ins [stringtoblockname $j] } } if [info exist xmlouts($i)] { foreach j [lsort -unique $xmlouts($i)] { lappend outs [stringtoblockname $j] } } if {[llength $ins] > [llength $outs]} { set height [expr 17+ 18 * [llength $ins]] } { set height [expr 17+ 18 * [llength $outs]] } eval newblock [stringtoblockname $i] $ix 50 40 $height "\{$ins\}" "\{$outs\}" testxml ; set ix [expr $ix + 50] } # and connect the blocks according to the XML spec foreach i [split $xmlo '\n'] { if {$i != "" } { connect {} [stringtoblockname [lindex [split [lindex [split $i ','] 0] ':'] 0]] [stringtoblockname [lindex [split [lindex [split $i ','] 0] ':'] 1]] [stringtoblockname [lindex [split [lindex [split $i ','] 1] ':'] 0]] [stringtoblockname [lindex [split [lindex [split $i ','] 1] ':'] 1]] } } <>BWise