#
# Controls via sliders for csound in tcl/tk
# John ffitch 2000 May 14
#  Modified for stdin/out use May 21
#

# Create a new slider
proc displayslider num {
  set sl ".s$num"
  set ex [winfo exists $sl]
  if {$ex == 0} {
    scale $sl -label Control$num -from 0 -to 127 -orient horizontal -length 10c
    pack $sl
  }
  puts "OK"
}

# Read value
proc value which {
 set sl ".s$which"
 displayslider $which
 set v [$sl get]
 puts "VALUE $v"
}

# Output controls
proc setparm {which num val} {
        set sl ".s$which"
        displayslider $which
        if {$num == 0} {
           $sl set $val
        } elseif {$num == 1} {
           $sl configure -from $val
        } elseif {$num == 2} {
           $sl configure -to $val
        }
        puts "OK"
}

proc setvalue {which val} {
        set sl ".s$which"
        displayslider $which
        $sl set $val
        puts "OK"
}

proc setmin {which val} {
        set sl ".s$which"
        displayslider $which
        $sl configure -from $val
        puts "OK"
}

proc setmax {which val} {
        set sl ".s$which"
        displayslider $which
        $sl configure -to $val
        puts "OK"
}

displayslider 1
displayslider 2

puts "Ready"
