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.
set xmltext ""; set xmlf [open test.carxp] ; while {[eof $xmlf] == 0} { append xmltext "[gets $xmlf]\n" } ; close $xmlf
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} }
proc stringtoblockname { {str} } {
set o ""
foreach i [split $str {}] {
if {[string is alnum $i] || $i == "_"} {
append o $i
} {
append o "_"
}
}
return [string tolower $o]
}
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] } }
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]] } ; newblock [stringtoblockname $i] $ix 50 40 $height "{$ins}" "{$outs}" testxml ; set ix [expr $ix + 50]}
285 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]] } ; newblock [stringtoblockname $i] $ix 50 40 $height "\{$ins\}" "\{$outs\}" testxml ; set ix [expr $ix + 50]}
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]}
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