proc slidsend { {n} {v} } { set w [format "%.2x" [expr $v+191]] send "00$w$w$w" } proc slidsendupdate { } { # send update } set sock {} proc send { {line {\n}} } { global sock if {$sock == -1} { # log "(failed attempt to send:\n$line)\n" return } puts $sock $line flush $sock # log $line\n } proc log a {puts -nonewline $a} set sock [socket 192.168.1.38 4448] #sliders {{vol 255}} wm geometry . 88x478 scale .sl .sl conf -from 64 -to -191 -tickinterval 32 -command {slidsend 0 } pack .sl -expand y -fill yThe slider above is shown on the screen, moving it immedeately changes the volume of the single text channel of the mixer.The ticks are in 0.5 dB steps ( a small volume change), which is not to lose resolution, when the slider values would be in Decibels, (-96 .. 31.5) the accuracy would become a decibel per slider step.The send command computes the hardware setting and assumes exactly 4 bytes must be send over the socket per volume change. The local IP address is of the mixer machine.The following picture shows the machinery setup:
set sock [socket -server connect 4448] set s1 {} proc connect {s host port} { global s1 set s1 $s fconfigure $s1 -blocking 0 -buffering line fileevent $s1 readable [list handleSocket $s1] } proc handleSocket {s} { gets $s line if {[eof $s]} { close $s set s -1 return } if {$line eq ""} return w $line } set fh [open /dev/ttyS2 RDWR] fconfigure $fh -blocking 0 -mode 115200,n,8,1 -translation binary \ -buffering full fileevent $fh readable { set w [read $fh] ; foreach c [split $w {}] { binary scan $c H* a; set v $a if {$s1 != {}} {puts $s1 "$v"} # flush stdout } } proc w h { global fh puts -nonewline $fh [binary format H* "$h"] ; flush $fh } w 00 ; w C0 ; w C0 ; w C0 # after 500 exit vwait foreverI'm not sure this machine will be all open source, thus far they're simple but very well working (and fast) programs and free to use.May 8 '07 TV I've added a 'auto-slider' facility, see this picture:
proc slidsend { {n} {v} } { set w [format "%.2x" [expr $v+191]] send "00$w$w$w" } proc slidsendupdate { } { # send update } proc send { {line {}} } {
global sock if {$sock == -1} { # log "(failed attempt to send:\n$line)\n" return } puts $sock $line flush $sock # log $line\n } proc log a {puts -nonewline $a} proc volset { {v 1} } { set w [format "%.2x" [expr $v+191]] send "00$w$w$w" } proc e {a} {} proc updatevol {v w} { set d [expr $v-$w] ; if {$d < 0} {set d -1} { if {$d == 0} {return done} {set d 1} } ; return $d } proc doupdatevol {} { set w [.s.sl get] ; set v [.s.sl1 get] ; set u [updatevol $v $w] ; if {"done" == "$u"} {return} ; set w [expr $w + $u] ; volset $w ; .s.sl set $w ; after [.s.sl2 get] {doupdatevol} } set sock {} set sock [socket 192.168.1.38 4448] toplevel .s scale .s.sl -from 64 -to -191 -tickinterval 32 -command {slidsend 0 } pack .s.sl -expand y -fill y -side left wm geometry .s 253x478 scale .s.sl1 -from 64 -to -191 -tickinterval 32 -command { e } pack .s.sl1 -expand y -fill y -side left scale .s.sl2 -from 100 -to 0 -tickinterval 20 -command { e } pack .s.sl2 -expand y -fill y -side left bind .s.sl1 <ButtonRelease-1> {doupdatevol}
TV (29-5-08) I changed the fax board processor such that it better startup on a random network with dhcp and also that it easily can run wget to browse the internet when connected to it, but now it is sometimes a bit slow with the tcl script to pass data from a PC over the intranet to the board. I'll have to find out how to fix this, the mixer is already limited by the 10kilobyte/sec link with the (extremely fast so probably for future use as interpolator) FPGA, but is normally totally apt responsive and with one slider completely immideate, and this is how it should be of course.The change has made it possible to connect up the board with web server and a working tcl-cgi script to a router/modem connected to the internet and to use a mobile phone with internet browser to directly change the volume on the machine without using a PC, and using the simple tcl-cgi directly, so I could walk outside, click the phone and change the volume directly, which is cool.