mirror of
https://github.com/thestk/stk
synced 2026-04-22 23:44:36 +00:00
Version 4.4.4
This commit is contained in:
committed by
Stephen Sinclair
parent
0aec39260a
commit
fc877b87bf
@@ -80,11 +80,11 @@ void processMessage( TickData* data )
|
||||
return;
|
||||
|
||||
case __SK_NoteOn_:
|
||||
if ( value2 == 0.0 ) // velocity is zero ... really a NoteOff
|
||||
data->voicer->noteOff( value1, 64.0 );
|
||||
else // a NoteOn
|
||||
if ( value2 > 0.0 ) { // velocity > 0
|
||||
data->voicer->noteOn( value1, value2 );
|
||||
break;
|
||||
break;
|
||||
}
|
||||
// else a note off, so continue to next case
|
||||
|
||||
case __SK_NoteOff_:
|
||||
data->voicer->noteOff( value1, value2 );
|
||||
|
||||
@@ -127,6 +127,10 @@ SOURCE=..\..\src\Clarinet.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\Fir.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\Delay.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -251,7 +255,7 @@ SOURCE=..\..\src\Plucked.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\PluckTwo.cpp
|
||||
SOURCE=..\..\src\Twang.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -427,6 +431,10 @@ SOURCE=..\..\include\Clarinet.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\Fir.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\Delay.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -571,7 +579,7 @@ SOURCE=..\..\include\Plucked.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\include\PluckTwo.h
|
||||
SOURCE=..\..\include\Twang.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
|
||||
@@ -6,8 +6,6 @@ set cont1 127.0
|
||||
set cont2 0.0
|
||||
set cont4 0.0
|
||||
set cont11 0.0
|
||||
set outID "stdout"
|
||||
set commtype "stdout"
|
||||
set struckbow 0
|
||||
set preset 0
|
||||
|
||||
@@ -16,17 +14,6 @@ wm title . "STK Bowed Bar Controller"
|
||||
wm iconname . "bowedbar"
|
||||
. config -bg black
|
||||
|
||||
# Configure "communications" menu
|
||||
menu .menu -tearoff 0
|
||||
menu .menu.communication -tearoff 0
|
||||
.menu add cascade -label "Communication" -menu .menu.communication \
|
||||
-underline 0
|
||||
.menu.communication add radio -label "Console" -variable commtype \
|
||||
-value "stdout" -command { setComm }
|
||||
.menu.communication add radio -label "Socket" -variable commtype \
|
||||
-value "socket" -command { setComm }
|
||||
. configure -menu .menu
|
||||
|
||||
# Configure preset radio buttons
|
||||
frame .radio1 -bg black
|
||||
|
||||
@@ -116,60 +103,51 @@ pack .right.reson -padx 10 -pady 10
|
||||
pack .left -side left
|
||||
pack .right -side right
|
||||
|
||||
|
||||
|
||||
bind all <KeyPress> {
|
||||
noteOn $pitch $press
|
||||
}
|
||||
bind all <KeyPress> { noteOn $pitch $press }
|
||||
|
||||
# Bind an X windows "close" event with the Exit routine
|
||||
bind . <Destroy> +myExit
|
||||
|
||||
proc myExit {} {
|
||||
global pitch outID
|
||||
puts $outID [format "NoteOff 0.0 1 %f 127" $pitch ]
|
||||
flush $outID
|
||||
puts $outID [format "ExitProgram"]
|
||||
flush $outID
|
||||
close $outID
|
||||
global pitch
|
||||
puts [format "NoteOff 0.0 1 %f 127" $pitch ]
|
||||
flush stdout
|
||||
puts [format "ExitProgram"]
|
||||
flush stdout
|
||||
close stdout
|
||||
exit
|
||||
}
|
||||
|
||||
proc noteOn {pitchVal pressVal} {
|
||||
global outID
|
||||
puts $outID [format "NoteOn 0.0 1 %f %f" $pitchVal $pressVal]
|
||||
flush $outID
|
||||
puts [format "NoteOn 0.0 1 %f %f" $pitchVal $pressVal]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
proc noteOff {pitchVal pressVal} {
|
||||
global outID
|
||||
puts $outID [format "NoteOff 0.0 1 %f %f" $pitchVal $pressVal]
|
||||
flush $outID
|
||||
puts [format "NoteOff 0.0 1 %f %f" $pitchVal $pressVal]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
proc patchChange {value} {
|
||||
global outID patch
|
||||
global patch
|
||||
set patch $value
|
||||
puts $outID [format "ProgramChange 0.0 1 %i" $value]
|
||||
flush $outID
|
||||
puts [format "ProgramChange 0.0 1 %i" $value]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
proc printWhatz {tag value1 value2 } {
|
||||
global outID
|
||||
puts $outID [format "%s %i %f" $tag $value1 $value2]
|
||||
flush $outID
|
||||
puts [format "%s %i %f" $tag $value1 $value2]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
proc changePress {value} {
|
||||
global outID
|
||||
puts $outID [format "AfterTouch 0.0 1 %f" $value]
|
||||
flush $outID
|
||||
puts [format "AfterTouch 0.0 1 %f" $value]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
proc changePitch {value} {
|
||||
global outID
|
||||
puts $outID [format "PitchChange 0.0 1 %.3f" $value]
|
||||
flush $outID
|
||||
puts [format "PitchChange 0.0 1 %.3f" $value]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
proc activateVel {} {
|
||||
@@ -178,69 +156,32 @@ proc activateVel {} {
|
||||
printWhatz "ControlChange 0.0 1 " 65 0
|
||||
}
|
||||
|
||||
bind . <Configure> { center_the_toplevel %W }
|
||||
proc center_the_toplevel { w } {
|
||||
|
||||
# Socket connection procedure
|
||||
set d .socketdialog
|
||||
# Callback on the <Configure> event for a toplevel
|
||||
# that should be centered on the screen
|
||||
|
||||
proc setComm {} {
|
||||
global outID
|
||||
global commtype
|
||||
global d
|
||||
if {$commtype == "stdout"} {
|
||||
if { [string compare "stdout" $outID] } {
|
||||
set i [tk_dialog .dialog "Break Socket Connection?" {You are about to break an existing socket connection ... is this what you want to do?} "" 0 Cancel OK]
|
||||
switch $i {
|
||||
0 {set commtype "socket"}
|
||||
1 {close $outID
|
||||
set outID "stdout"}
|
||||
}
|
||||
}
|
||||
} elseif { ![string compare "stdout" $outID] } {
|
||||
set sockport 2001
|
||||
set sockhost localhost
|
||||
toplevel $d
|
||||
wm title $d "STK Client Socket Connection"
|
||||
wm resizable $d 0 0
|
||||
grab $d
|
||||
label $d.message -text "Specify a socket host and port number below (if different than the STK defaults shown) and then click the \"Connect\" button to invoke a socket-client connection attempt to the STK socket server." \
|
||||
-background white -font {Helvetica 10 bold} \
|
||||
-wraplength 3i -justify left
|
||||
frame $d.sockhost
|
||||
entry $d.sockhost.entry -width 15
|
||||
label $d.sockhost.text -text "Socket Host:" \
|
||||
-font {Helvetica 10 bold}
|
||||
frame $d.sockport
|
||||
entry $d.sockport.entry -width 15
|
||||
label $d.sockport.text -text "Socket Port:" \
|
||||
-font {Helvetica 10 bold}
|
||||
pack $d.message -side top -padx 5 -pady 10
|
||||
pack $d.sockhost.text -side left -padx 1 -pady 2
|
||||
pack $d.sockhost.entry -side right -padx 5 -pady 2
|
||||
pack $d.sockhost -side top -padx 5 -pady 2
|
||||
pack $d.sockport.text -side left -padx 1 -pady 2
|
||||
pack $d.sockport.entry -side right -padx 5 -pady 2
|
||||
pack $d.sockport -side top -padx 5 -pady 2
|
||||
$d.sockhost.entry insert 0 $sockhost
|
||||
$d.sockport.entry insert 0 $sockport
|
||||
frame $d.buttons
|
||||
button $d.buttons.cancel -text "Cancel" -bg grey66 \
|
||||
-command { set commtype "stdout"
|
||||
set outID "stdout"
|
||||
destroy $d }
|
||||
button $d.buttons.connect -text "Connect" -bg grey66 \
|
||||
-command {
|
||||
set sockhost [$d.sockhost.entry get]
|
||||
set sockport [$d.sockport.entry get]
|
||||
set err [catch {socket $sockhost $sockport} outID]
|
||||
# Make sure that we aren't configuring a child window
|
||||
if { [string equal $w [winfo toplevel $w]] } {
|
||||
|
||||
if {$err == 0} {
|
||||
destroy $d
|
||||
} else {
|
||||
tk_dialog $d.error "Socket Error" {Error: Unable to make socket connection. Make sure the STK socket server is first running and that the port number is correct.} "" 0 OK
|
||||
} }
|
||||
pack $d.buttons.cancel -side left -padx 5 -pady 10
|
||||
pack $d.buttons.connect -side right -padx 5 -pady 10
|
||||
pack $d.buttons -side bottom -padx 5 -pady 10
|
||||
}
|
||||
# Calculate the desired geometry
|
||||
set width [winfo reqwidth $w]
|
||||
set height [winfo reqheight $w]
|
||||
set x [expr { ( [winfo vrootwidth $w] - $width ) / 2 }]
|
||||
set y [expr { ( [winfo vrootheight $w] - $height ) / 2 }]
|
||||
#set y 0
|
||||
|
||||
# Hand the geometry off to the window manager
|
||||
wm geometry $w ${width}x${height}+${x}+${y}
|
||||
|
||||
# Unbind <Configure> so that this procedure is
|
||||
# not called again when the window manager finishes
|
||||
# centering the window. Also, revert geometry management
|
||||
# to internal default for subsequent size changes.
|
||||
bind $w <Configure> {}
|
||||
wm geometry $w ""
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Tcl/Tk Demo GUI for the Synthesis Toolkit (STK)
|
||||
# by Gary P. Scavone, CCRMA, Stanford University, 1999-2002.
|
||||
# by Gary P. Scavone, CCRMA, Stanford University, 1999-2012.
|
||||
|
||||
# Set initial control values
|
||||
set pitch 64.0
|
||||
@@ -11,8 +11,6 @@ set cont4 20.0
|
||||
set cont7 128.0
|
||||
set cont11 64.0
|
||||
set cont44 24.0
|
||||
set outID "stdout"
|
||||
set commtype "stdout"
|
||||
set patchnum 0
|
||||
set oldpatch 0
|
||||
set temp 0
|
||||
@@ -22,19 +20,10 @@ wm title . "STK Demo GUI"
|
||||
wm iconname . "demo"
|
||||
. config -bg black
|
||||
|
||||
# Configure "communications" menu
|
||||
menu .menu -tearoff 0
|
||||
menu .menu.communication -tearoff 0
|
||||
.menu add cascade -label "Communication" -menu .menu.communication \
|
||||
-underline 0
|
||||
.menu.communication add radio -label "Console" -variable commtype \
|
||||
-value "stdout" -command { setComm }
|
||||
.menu.communication add radio -label "Socket" -variable commtype \
|
||||
-value "socket" -command { setComm }
|
||||
|
||||
# Configure instrument change menu. Use a unique number for each
|
||||
# voice. The STK program change value is found by dividing by 100,
|
||||
# while the remainder corresponds to within-class preset values.
|
||||
menu .menu -tearoff 0
|
||||
menu .menu.instrument -tearoff 0
|
||||
.menu add cascade -label "Instruments" -menu .menu.instrument \
|
||||
-underline 0
|
||||
@@ -96,45 +85,45 @@ menu .menu.instrument -tearoff 0
|
||||
-value 2301 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "Sekere" -variable patchnum \
|
||||
-value 2302 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "Guiro" -variable patchnum \
|
||||
.menu.instrument add radio -label "Tambourine" -variable patchnum \
|
||||
-value 2303 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "Waterdrop" -variable patchnum \
|
||||
.menu.instrument add radio -label "Sleigh Bells" -variable patchnum \
|
||||
-value 2304 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "Bamboo" -variable patchnum \
|
||||
.menu.instrument add radio -label "Bamboo Chimes" -variable patchnum \
|
||||
-value 2305 -command { patchChange $patchnum } \
|
||||
-columnbreak 1
|
||||
|
||||
.menu.instrument add radio -label "Tambourine" -variable patchnum \
|
||||
.menu.instrument add radio -label "Sandpaper" -variable patchnum \
|
||||
-value 2306 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "Sleigh Bell" -variable patchnum \
|
||||
.menu.instrument add radio -label "Coke Can" -variable patchnum \
|
||||
-value 2307 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "Sticks" -variable patchnum \
|
||||
-value 2308 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "Crunch" -variable patchnum \
|
||||
-value 2309 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "Wrench" -variable patchnum \
|
||||
-value 2310 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "SandPaper" -variable patchnum \
|
||||
-value 2311 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "CokeCan" -variable patchnum \
|
||||
-value 2312 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "NeXT Mug" -variable patchnum \
|
||||
-value 2313 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "Mug & Penny" -variable patchnum \
|
||||
-value 2314 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "Mug & Nickle" -variable patchnum \
|
||||
-value 2315 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "Mug & Dime" -variable patchnum \
|
||||
-value 2316 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "Mug & Quarter" -variable patchnum \
|
||||
-value 2317 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "Mug & Franc" -variable patchnum \
|
||||
-value 2318 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "Mug & Peso" -variable patchnum \
|
||||
-value 2319 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "Big Rocks" -variable patchnum \
|
||||
-value 2320 -command { patchChange $patchnum }
|
||||
-value 2310 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "Little Rocks" -variable patchnum \
|
||||
-value 2311 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "NeXT Mug" -variable patchnum \
|
||||
-value 2312 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "Mug & Penny" -variable patchnum \
|
||||
-value 2313 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "Mug & Nickle" -variable patchnum \
|
||||
-value 2314 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "Mug & Dime" -variable patchnum \
|
||||
-value 2315 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "Mug & Quarter" -variable patchnum \
|
||||
-value 2316 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "Mug & Franc" -variable patchnum \
|
||||
-value 2317 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "Mug & Peso" -variable patchnum \
|
||||
-value 2318 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "Guiro" -variable patchnum \
|
||||
-value 2319 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "Wrench" -variable patchnum \
|
||||
-value 2320 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "Water Drops" -variable patchnum \
|
||||
-value 2321 -command { patchChange $patchnum }
|
||||
.menu.instrument add radio -label "Tuned Bamboo" -variable patchnum \
|
||||
-value 2322 -command { patchChange $patchnum }
|
||||
@@ -183,7 +172,7 @@ button .pretty -bitmap @$bitmappath/Klar.xbm \
|
||||
-background white -foreground black
|
||||
pack .pretty -padx 5 -pady 10
|
||||
|
||||
# Configure "note-on" buttons
|
||||
# Configure "note on" buttons
|
||||
frame .noteOn -bg black
|
||||
|
||||
button .noteOn.on -text NoteOn -bg grey66 -command { noteOn $pitch $press }
|
||||
@@ -200,50 +189,50 @@ frame .left -bg black
|
||||
frame .right -bg black
|
||||
|
||||
scale .left.volume -from 0 -to 128 -length 200 \
|
||||
-command {printWhatz "ControlChange 0.0 1 " 7} \
|
||||
-orient horizontal -label "Volume" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont7
|
||||
-command {printWhatz "ControlChange 0.0 1 " 7} \
|
||||
-orient horizontal -label "Volume" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont7
|
||||
|
||||
scale .left.bPressure -from 0 -to 128 -length 200 \
|
||||
-command {changePress } -variable press \
|
||||
-orient horizontal -label "Breath Pressure" \
|
||||
-tickinterval 32 -showvalue true -bg grey66
|
||||
-command {changePress } -variable press \
|
||||
-orient horizontal -label "Breath Pressure" \
|
||||
-tickinterval 32 -showvalue true -bg grey66
|
||||
|
||||
scale .left.pitch -from 0 -to 128 -length 200 \
|
||||
-command {changePitch } -variable pitch \
|
||||
-orient horizontal -label "MIDI Note Number" \
|
||||
-tickinterval 32 -showvalue true -bg grey66
|
||||
-command {changePitch } -variable pitch \
|
||||
-orient horizontal -label "MIDI Note Number" \
|
||||
-tickinterval 32 -showvalue true -bg grey66
|
||||
|
||||
scale .left.cont2 -from 0 -to 128 -length 200 \
|
||||
-command {printWhatz "ControlChange 0.0 1 " 2} \
|
||||
-orient horizontal -label "Reed Stiffness" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont2
|
||||
-command {printWhatz "ControlChange 0.0 1 " 2} \
|
||||
-orient horizontal -label "Reed Stiffness" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont2
|
||||
|
||||
scale .right.reverb -from 0 -to 128 -length 200 \
|
||||
-command {printWhatz "ControlChange 0.0 1 " 44} \
|
||||
-orient horizontal -label "Reverb Mix" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont44
|
||||
-command {printWhatz "ControlChange 0.0 1 " 44} \
|
||||
-orient horizontal -label "Reverb Mix" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont44
|
||||
|
||||
scale .right.cont4 -from 0 -to 128 -length 200 \
|
||||
-command {printWhatz "ControlChange 0.0 1 " 4} \
|
||||
-orient horizontal -label "Breath Noise" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont4
|
||||
-command {printWhatz "ControlChange 0.0 1 " 4} \
|
||||
-orient horizontal -label "Breath Noise" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont4
|
||||
|
||||
scale .right.cont11 -from 0 -to 128 -length 200 \
|
||||
-command {printWhatz "ControlChange 0.0 1 " 11} \
|
||||
-orient horizontal -label "Vibrato Rate" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont11
|
||||
-command {printWhatz "ControlChange 0.0 1 " 11} \
|
||||
-orient horizontal -label "Vibrato Rate" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont11
|
||||
|
||||
scale .right.cont1 -from 0 -to 128 -length 200 \
|
||||
-command {printWhatz "ControlChange 0.0 1 " 1} \
|
||||
-orient horizontal -label "Vibrato Amount" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont1
|
||||
-command {printWhatz "ControlChange 0.0 1 " 1} \
|
||||
-orient horizontal -label "Vibrato Amount" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont1
|
||||
|
||||
pack .left.volume -padx 10 -pady 10
|
||||
pack .left.bPressure -padx 10 -pady 10
|
||||
@@ -261,31 +250,57 @@ pack .right -side right
|
||||
set p .drumwindow
|
||||
|
||||
proc myExit {} {
|
||||
global pitch outID
|
||||
puts $outID [format "ExitProgram"]
|
||||
flush $outID
|
||||
close $outID
|
||||
global pitch
|
||||
puts [format "ExitProgram"]
|
||||
flush stdout
|
||||
close stdout
|
||||
exit
|
||||
}
|
||||
|
||||
proc noteOn {pitchVal pressVal} {
|
||||
global outID
|
||||
puts $outID [format "NoteOn 0.0 1 %3.2f %3.2f" $pitchVal $pressVal]
|
||||
flush $outID
|
||||
puts [format "NoteOn 0.0 1 %3.2f %3.2f" $pitchVal $pressVal]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
proc noteOff {pitchVal pressVal} {
|
||||
global outID
|
||||
puts $outID [format "NoteOff 0.0 1 %3.2f %3.2f" $pitchVal $pressVal]
|
||||
flush $outID
|
||||
puts [format "NoteOff 0.0 1 %3.2f %3.2f" $pitchVal $pressVal]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
# Set bindings
|
||||
bind . <KeyPress> { noteOn $pitch $press }
|
||||
bind . <Destroy> +myExit
|
||||
|
||||
proc playDrum {value} {
|
||||
global velocity
|
||||
puts [format "NoteOn 0.0 1 %3i %3.2f" $value $velocity]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
proc printWhatz {tag value1 value2 } {
|
||||
puts [format "%s %2i %3.2f" $tag $value1 $value2]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
proc changePress {value} {
|
||||
global patchnum
|
||||
if { $patchnum<700 || ($patchnum>900 && $patchnum<2500) || $patchnum>=2600 } {
|
||||
puts [format "AfterTouch 0.0 1 %3.2f" $value]
|
||||
flush stdout
|
||||
}
|
||||
}
|
||||
|
||||
proc changePitch {value} {
|
||||
puts [format "PitchChange 0.0 1 %3.2f" $value]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
proc patchChange {value} {
|
||||
global outID bitmappath cont1 cont2 cont4 cont11 oldpatch press pitch temp
|
||||
global bitmappath cont1 cont2 cont4 cont11 oldpatch press pitch temp
|
||||
if {$value!=$oldpatch} {
|
||||
set program [expr $value / 100]
|
||||
puts $outID [format "ProgramChange 0.0 1 %2i" $program]
|
||||
flush $outID
|
||||
puts [format "ProgramChange 0.0 1 %2i" $program]
|
||||
flush stdout
|
||||
|
||||
# This stuff below sets up the correct bitmaps, slider labels, and control
|
||||
# parameters.
|
||||
@@ -374,7 +389,7 @@ proc patchChange {value} {
|
||||
printWhatz "ControlChange 0.0 1 " 2 $cont2
|
||||
printWhatz "ControlChange 0.0 1 " 4 $cont4
|
||||
printWhatz "ControlChange 0.0 1 " 11 $cont11
|
||||
puts $outID [format "NoteOn 0.0 1 %3.2f %3.2f" $pitch $press]
|
||||
puts [format "NoteOn 0.0 1 %3.2f %3.2f" $pitch $press]
|
||||
}
|
||||
if {$program==5} { # Bottle
|
||||
.pretty config -bitmap @$bitmappath/prcFunny.xbm
|
||||
@@ -595,12 +610,12 @@ proc patchChange {value} {
|
||||
set cont2 0.0
|
||||
set cont4 0.0
|
||||
set cont11 0.0
|
||||
puts $outID [format "ControlChange 0.0 1 16 %3.2f" $preset]
|
||||
puts $outID [format "NoteOn 0.0 1 %3.2f %3.2f" $pitch $press]
|
||||
puts [format "ControlChange 0.0 1 16 %3.2f" $preset]
|
||||
puts [format "NoteOn 0.0 1 %3.2f %3.2f" $pitch $press]
|
||||
printWhatz "ControlChange 0.0 1 " 1 $cont1
|
||||
printWhatz "ControlChange 0.0 1 " 2 $cont2
|
||||
printWhatz "ControlChange 0.0 1 " 11 $cont11
|
||||
flush $outID
|
||||
flush stdout
|
||||
}
|
||||
if {$program==23} { # Shakers
|
||||
.pretty config -bitmap @$bitmappath/phism.xbm
|
||||
@@ -619,23 +634,23 @@ proc patchChange {value} {
|
||||
.pretty config -bitmap @$bitmappath/cabasa.xbm
|
||||
}
|
||||
3 {
|
||||
.pretty config -bitmap @$bitmappath/guiro.xbm
|
||||
.pretty config -bitmap @$bitmappath/tambourine.xbm
|
||||
}
|
||||
4 {
|
||||
.pretty config -bitmap @$bitmappath/sleighbell.xbm
|
||||
}
|
||||
5 {
|
||||
.pretty config -bitmap @$bitmappath/bamboo.xbm
|
||||
}
|
||||
6 {
|
||||
.pretty config -bitmap @$bitmappath/tambourine.xbm
|
||||
}
|
||||
7 {
|
||||
.pretty config -bitmap @$bitmappath/sleighbell.xbm
|
||||
}
|
||||
10 {
|
||||
.pretty config -bitmap @$bitmappath/rachet.xbm
|
||||
}
|
||||
12 {
|
||||
.pretty config -bitmap @$bitmappath/cokecan.xbm
|
||||
}
|
||||
19 {
|
||||
.pretty config -bitmap @$bitmappath/guiro.xbm
|
||||
}
|
||||
20 {
|
||||
.pretty config -bitmap @$bitmappath/rachet.xbm
|
||||
}
|
||||
22 {
|
||||
.pretty config -bitmap @$bitmappath/bamboo.xbm
|
||||
}
|
||||
@@ -644,12 +659,12 @@ proc patchChange {value} {
|
||||
set cont2 64.0
|
||||
set cont4 64.0
|
||||
set cont11 64.0
|
||||
puts $outID [format "NoteOn 0.0 1 %3.2f %3.2f" $pitch $press]
|
||||
puts [format "NoteOn 0.0 1 %3.2f %3.2f" $pitch $press]
|
||||
printWhatz "ControlChange 0.0 1 " 1 $cont1
|
||||
printWhatz "ControlChange 0.0 1 " 2 $cont2
|
||||
printWhatz "ControlChange 0.0 1 " 4 $cont4
|
||||
printWhatz "ControlChange 0.0 1 " 11 $cont11
|
||||
flush $outID
|
||||
flush stdout
|
||||
}
|
||||
if {$program==24} { # Modal Instruments
|
||||
.pretty config -bitmap @$bitmappath/KModal.xbm
|
||||
@@ -673,7 +688,7 @@ proc patchChange {value} {
|
||||
printWhatz "ControlChange 0.0 1 " 2 $cont2
|
||||
printWhatz "ControlChange 0.0 1 " 4 $cont4
|
||||
printWhatz "ControlChange 0.0 1 " 11 $cont11
|
||||
flush $outID
|
||||
flush stdout
|
||||
}
|
||||
if { $program==25 } { # Mesh2D
|
||||
.pretty config -bitmap @$bitmappath/prcFunny.xbm
|
||||
@@ -691,7 +706,7 @@ proc patchChange {value} {
|
||||
printWhatz "ControlChange 0.0 1 " 2 $cont2
|
||||
printWhatz "ControlChange 0.0 1 " 4 $cont4
|
||||
printWhatz "ControlChange 0.0 1 " 11 $cont11
|
||||
flush $outID
|
||||
flush stdout
|
||||
}
|
||||
if { $program==26 } { # Resonate
|
||||
.pretty config -bitmap @$bitmappath/prcFunny.xbm
|
||||
@@ -709,7 +724,7 @@ proc patchChange {value} {
|
||||
printWhatz "ControlChange 0.0 1 " 11 $cont11
|
||||
printWhatz "ControlChange 0.0 1 " 1 $cont1
|
||||
printWhatz "ControlChange 0.0 1 " 2 $cont2
|
||||
flush $outID
|
||||
flush stdout
|
||||
}
|
||||
if { $program==27 } { # Whistle
|
||||
.pretty config -bitmap @$bitmappath/prcFunny.xbm
|
||||
@@ -727,105 +742,38 @@ proc patchChange {value} {
|
||||
printWhatz "ControlChange 0.0 1 " 11 $cont11
|
||||
printWhatz "ControlChange 0.0 1 " 1 $cont1
|
||||
printWhatz "ControlChange 0.0 1 " 2 $cont2
|
||||
flush $outID
|
||||
flush stdout
|
||||
}
|
||||
set oldpatch $value
|
||||
}
|
||||
}
|
||||
|
||||
#bind all <KeyPress> {
|
||||
bind . <KeyPress> {
|
||||
noteOn $pitch $press
|
||||
}
|
||||
bind . <Configure> {+ center_the_toplevel %W }
|
||||
proc center_the_toplevel { w } {
|
||||
|
||||
# Bind an X windows "close" event with the Exit routine
|
||||
bind . <Destroy> +myExit
|
||||
# Callback on the <Configure> event for a toplevel
|
||||
# that should be centered on the screen
|
||||
|
||||
proc playDrum {value} {
|
||||
global velocity outID
|
||||
puts $outID [format "NoteOn 0.0 1 %3i %3.2f" $value $velocity]
|
||||
flush $outID
|
||||
}
|
||||
# Make sure that we aren't configuring a child window
|
||||
if { [string equal $w [winfo toplevel $w]] } {
|
||||
|
||||
proc printWhatz {tag value1 value2 } {
|
||||
global outID
|
||||
puts $outID [format "%s %2i %3.2f" $tag $value1 $value2]
|
||||
flush $outID
|
||||
}
|
||||
# Calculate the desired geometry
|
||||
set width [winfo reqwidth $w]
|
||||
set height [winfo reqheight $w]
|
||||
set x [expr { ( [winfo vrootwidth $w] - $width ) / 2 }]
|
||||
set y [expr { ( [winfo vrootheight $w] - $height ) / 2 }]
|
||||
#set y 0
|
||||
|
||||
proc changePress {value} {
|
||||
global outID patchnum
|
||||
if { $patchnum<700 || ($patchnum>900 && $patchnum<2500) || $patchnum>=2600 } {
|
||||
puts $outID [format "AfterTouch 0.0 1 %3.2f" $value]
|
||||
flush $outID
|
||||
# Hand the geometry off to the window manager
|
||||
wm geometry $w ${width}x${height}+${x}+${y}
|
||||
|
||||
# Unbind <Configure> so that this procedure is
|
||||
# not called again when the window manager finishes
|
||||
# centering the window. Also, revert geometry management
|
||||
# to internal default for subsequent size changes.
|
||||
bind $w <Configure> {}
|
||||
wm geometry $w ""
|
||||
}
|
||||
}
|
||||
|
||||
proc changePitch {value} {
|
||||
global outID
|
||||
puts $outID [format "PitchChange 0.0 1 %3.2f" $value]
|
||||
flush $outID
|
||||
}
|
||||
|
||||
# Socket connection procedure
|
||||
set d .socketdialog
|
||||
|
||||
proc setComm {} {
|
||||
global outID commtype d
|
||||
if {$commtype == "stdout"} {
|
||||
if { [string compare "stdout" $outID] } {
|
||||
set i [tk_dialog .dialog "Break Socket Connection?" {You are about to break an existing socket connection ... is this what you want to do?} "" 0 Cancel OK]
|
||||
switch $i {
|
||||
0 {set commtype "socket"}
|
||||
1 {close $outID
|
||||
set outID "stdout"}
|
||||
}
|
||||
}
|
||||
} elseif { ![string compare "stdout" $outID] } {
|
||||
set sockport 2001
|
||||
set sockhost localhost
|
||||
toplevel $d
|
||||
wm title $d "STK Client Socket Connection"
|
||||
wm resizable $d 0 0
|
||||
grab $d
|
||||
label $d.message -text "Specify a socket host and port number below (if different than the STK defaults shown) and then click the \"Connect\" button to invoke a socket-client connection attempt to the STK socket server." \
|
||||
-background white -font {Helvetica 10 bold} \
|
||||
-wraplength 3i -justify left
|
||||
frame $d.sockhost
|
||||
entry $d.sockhost.entry -width 15
|
||||
label $d.sockhost.text -text "Socket Host:" \
|
||||
-font {Helvetica 10 bold}
|
||||
frame $d.sockport
|
||||
entry $d.sockport.entry -width 15
|
||||
label $d.sockport.text -text "Socket Port:" \
|
||||
-font {Helvetica 10 bold}
|
||||
pack $d.message -side top -padx 5 -pady 10
|
||||
pack $d.sockhost.text -side left -padx 1 -pady 2
|
||||
pack $d.sockhost.entry -side right -padx 5 -pady 2
|
||||
pack $d.sockhost -side top -padx 5 -pady 2
|
||||
pack $d.sockport.text -side left -padx 1 -pady 2
|
||||
pack $d.sockport.entry -side right -padx 5 -pady 2
|
||||
pack $d.sockport -side top -padx 5 -pady 2
|
||||
$d.sockhost.entry insert 0 $sockhost
|
||||
$d.sockport.entry insert 0 $sockport
|
||||
frame $d.buttons
|
||||
button $d.buttons.cancel -text "Cancel" -bg grey66 \
|
||||
-command { set commtype "stdout"
|
||||
set outID "stdout"
|
||||
destroy $d }
|
||||
button $d.buttons.connect -text "Connect" -bg grey66 \
|
||||
-command {
|
||||
set sockhost [$d.sockhost.entry get]
|
||||
set sockport [$d.sockport.entry get]
|
||||
set err [catch {socket $sockhost $sockport} outID]
|
||||
|
||||
if {$err == 0} {
|
||||
destroy $d
|
||||
} else {
|
||||
tk_dialog $d.error "Socket Error" {Error: Unable to make socket connection. Make sure the STK socket server is first running and that the port number is correct.} "" 0 OK
|
||||
} }
|
||||
pack $d.buttons.cancel -side left -padx 5 -pady 10
|
||||
pack $d.buttons.connect -side right -padx 5 -pady 10
|
||||
pack $d.buttons -side bottom -padx 5 -pady 10
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -2,28 +2,15 @@
|
||||
|
||||
# Set initial control values
|
||||
set press 127
|
||||
set outID "stdout"
|
||||
set commtype "stdout"
|
||||
|
||||
# Turn down the reverb
|
||||
puts $outID "ControlChange 0.0 1 44.0 0.0"
|
||||
puts "ControlChange 0.0 1 44.0 0.0"
|
||||
|
||||
# Configure main window
|
||||
wm title . "STK Drum Controller"
|
||||
wm iconname . "drum"
|
||||
. config -bg black
|
||||
|
||||
# Configure "communications" menu
|
||||
menu .menu -tearoff 0
|
||||
menu .menu.communication -tearoff 0
|
||||
.menu add cascade -label "Communication" -menu .menu.communication \
|
||||
-underline 0
|
||||
.menu.communication add radio -label "Console" -variable commtype \
|
||||
-value "stdout" -command { setComm }
|
||||
.menu.communication add radio -label "Socket" -variable commtype \
|
||||
-value "socket" -command { setComm }
|
||||
. configure -menu .menu
|
||||
|
||||
# Configure slider
|
||||
scale .bPressure -from 0 -to 128 -length 100 \
|
||||
-command {changePress } -variable press\
|
||||
@@ -87,18 +74,16 @@ pack .exit -side bottom -pady 20
|
||||
bind . <Destroy> +myExit
|
||||
|
||||
proc myExit {} {
|
||||
global outID
|
||||
puts $outID [format "ExitProgram"]
|
||||
flush $outID
|
||||
close $outID
|
||||
puts [format "ExitProgram"]
|
||||
flush stdout
|
||||
close stdout
|
||||
exit
|
||||
}
|
||||
|
||||
proc playDrum {value} {
|
||||
global press
|
||||
global outID
|
||||
puts $outID [format "NoteOn 0.0 1 %i %f" $value $press]
|
||||
flush $outID
|
||||
puts [format "NoteOn 0.0 1 %i %f" $value $press]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
proc changePress {value} {
|
||||
@@ -106,67 +91,32 @@ proc changePress {value} {
|
||||
set press $value
|
||||
}
|
||||
|
||||
# Socket connection procedure
|
||||
set d .socketdialog
|
||||
bind . <Configure> { center_the_toplevel %W }
|
||||
proc center_the_toplevel { w } {
|
||||
|
||||
proc setComm {} {
|
||||
global outID
|
||||
global commtype
|
||||
global d
|
||||
if {$commtype == "stdout"} {
|
||||
if { [string compare "stdout" $outID] } {
|
||||
set i [tk_dialog .dialog "Break Socket Connection?" {You are about to break an existing socket connection ... is this what you want to do?} "" 0 Cancel OK]
|
||||
switch $i {
|
||||
0 {set commtype "socket"}
|
||||
1 {close $outID
|
||||
set outID "stdout"}
|
||||
}
|
||||
}
|
||||
} elseif { ![string compare "stdout" $outID] } {
|
||||
set sockport 2001
|
||||
set sockhost localhost
|
||||
toplevel $d
|
||||
wm title $d "STK Client Socket Connection"
|
||||
wm resizable $d 0 0
|
||||
grab $d
|
||||
label $d.message -text "Specify a socket host and port number below (if different than the STK defaults shown) and then click the \"Connect\" button to invoke a socket-client connection attempt to the STK socket server." \
|
||||
-background white -font {Helvetica 10 bold} \
|
||||
-wraplength 3i -justify left
|
||||
frame $d.sockhost
|
||||
entry $d.sockhost.entry -width 15
|
||||
label $d.sockhost.text -text "Socket Host:" \
|
||||
-font {Helvetica 10 bold}
|
||||
frame $d.sockport
|
||||
entry $d.sockport.entry -width 15
|
||||
label $d.sockport.text -text "Socket Port:" \
|
||||
-font {Helvetica 10 bold}
|
||||
pack $d.message -side top -padx 5 -pady 10
|
||||
pack $d.sockhost.text -side left -padx 1 -pady 2
|
||||
pack $d.sockhost.entry -side right -padx 5 -pady 2
|
||||
pack $d.sockhost -side top -padx 5 -pady 2
|
||||
pack $d.sockport.text -side left -padx 1 -pady 2
|
||||
pack $d.sockport.entry -side right -padx 5 -pady 2
|
||||
pack $d.sockport -side top -padx 5 -pady 2
|
||||
$d.sockhost.entry insert 0 $sockhost
|
||||
$d.sockport.entry insert 0 $sockport
|
||||
frame $d.buttons
|
||||
button $d.buttons.cancel -text "Cancel" -bg grey66 \
|
||||
-command { set commtype "stdout"
|
||||
set outID "stdout"
|
||||
destroy $d }
|
||||
button $d.buttons.connect -text "Connect" -bg grey66 \
|
||||
-command {
|
||||
set sockhost [$d.sockhost.entry get]
|
||||
set sockport [$d.sockport.entry get]
|
||||
set err [catch {socket $sockhost $sockport} outID]
|
||||
# Callback on the <Configure> event for a toplevel
|
||||
# that should be centered on the screen
|
||||
|
||||
if {$err == 0} {
|
||||
destroy $d
|
||||
} else {
|
||||
tk_dialog $d.error "Socket Error" {Error: Unable to make socket connection. Make sure the STK socket server is first running and that the port number is correct.} "" 0 OK
|
||||
} }
|
||||
pack $d.buttons.cancel -side left -padx 5 -pady 10
|
||||
pack $d.buttons.connect -side right -padx 5 -pady 10
|
||||
pack $d.buttons -side bottom -padx 5 -pady 10
|
||||
}
|
||||
}
|
||||
# Make sure that we aren't configuring a child window
|
||||
if { [string equal $w [winfo toplevel $w]] } {
|
||||
|
||||
# Calculate the desired geometry
|
||||
set width [winfo reqwidth $w]
|
||||
set height [winfo reqheight $w]
|
||||
set x [expr { ( [winfo vrootwidth $w] - $width ) / 2 }]
|
||||
set y [expr { ( [winfo vrootheight $w] - $height ) / 2 }]
|
||||
#set y 0
|
||||
|
||||
# Hand the geometry off to the window manager
|
||||
wm geometry $w ${width}x${height}+${x}+${y}
|
||||
|
||||
# Unbind <Configure> so that this procedure is
|
||||
# not called again when the window manager finishes
|
||||
# centering the window. Also, revert geometry management
|
||||
# to internal default for subsequent size changes.
|
||||
bind $w <Configure> {}
|
||||
wm geometry $w ""
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
@@ -6,8 +6,6 @@ set cont4 64.0
|
||||
set cont7 128.0
|
||||
set cont11 64.0
|
||||
set cont44 24.0
|
||||
set outID "stdout"
|
||||
set commtype "stdout"
|
||||
set preset 0
|
||||
|
||||
# Configure main window
|
||||
@@ -15,16 +13,6 @@ wm title . "STK Modal Bar Interface"
|
||||
wm iconname . "modal"
|
||||
. config -bg black
|
||||
|
||||
# Configure "communications" menu
|
||||
menu .menu -tearoff 0
|
||||
menu .menu.communication -tearoff 0
|
||||
.menu add cascade -label "Communication" -menu .menu.communication \
|
||||
-underline 0
|
||||
.menu.communication add radio -label "Console" -variable commtype \
|
||||
-value "stdout" -command { setComm }
|
||||
.menu.communication add radio -label "Socket" -variable commtype \
|
||||
-value "socket" -command { setComm }
|
||||
|
||||
# Configure preset radio buttons
|
||||
frame .radio1 -bg black
|
||||
frame .radio2 -bg black
|
||||
@@ -88,50 +76,50 @@ frame .left -bg black
|
||||
frame .right -bg black
|
||||
|
||||
scale .left.volume -from 0 -to 128 -length 200 \
|
||||
-command {printWhatz "ControlChange 0.0 1 " 7} \
|
||||
-orient horizontal -label "Volume" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont7
|
||||
-command {printWhatz "ControlChange 0.0 1 " 7} \
|
||||
-orient horizontal -label "Volume" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont7
|
||||
|
||||
scale .left.bPressure -from 0 -to 128 -length 200 \
|
||||
-command {changePress } -variable press \
|
||||
-orient horizontal -label "Strike Vigor" \
|
||||
-tickinterval 32 -showvalue true -bg grey66
|
||||
-command {changePress } -variable press \
|
||||
-orient horizontal -label "Strike Vigor" \
|
||||
-tickinterval 32 -showvalue true -bg grey66
|
||||
|
||||
scale .left.pitch -from 0 -to 128 -length 200 \
|
||||
-command {changePitch } -variable pitch \
|
||||
-orient horizontal -label "MIDI Note Number" \
|
||||
-tickinterval 32 -showvalue true -bg grey66
|
||||
-command {changePitch } -variable pitch \
|
||||
-orient horizontal -label "MIDI Note Number" \
|
||||
-tickinterval 32 -showvalue true -bg grey66
|
||||
|
||||
scale .left.cont2 -from 0 -to 128 -length 200 \
|
||||
-command {printWhatz "ControlChange 0.0 1 " 2} \
|
||||
-orient horizontal -label "Stick Hardness" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont2
|
||||
-command {printWhatz "ControlChange 0.0 1 " 2} \
|
||||
-orient horizontal -label "Stick Hardness" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont2
|
||||
|
||||
scale .right.reverb -from 0 -to 128 -length 200 \
|
||||
-command {printWhatz "ControlChange 0.0 1 " 44} \
|
||||
-orient horizontal -label "Reverb Mix" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont44
|
||||
-command {printWhatz "ControlChange 0.0 1 " 44} \
|
||||
-orient horizontal -label "Reverb Mix" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont44
|
||||
|
||||
scale .right.cont4 -from 0 -to 128 -length 200 \
|
||||
-command {printWhatz "ControlChange 0.0 1 " 4} \
|
||||
-orient horizontal -label "Stick Position" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont4
|
||||
-command {printWhatz "ControlChange 0.0 1 " 4} \
|
||||
-orient horizontal -label "Stick Position" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont4
|
||||
|
||||
scale .right.cont11 -from 0 -to 128 -length 200 \
|
||||
-command {printWhatz "ControlChange 0.0 1 " 11} \
|
||||
-orient horizontal -label "Disabled" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont11 -state disabled
|
||||
-command {printWhatz "ControlChange 0.0 1 " 11} \
|
||||
-orient horizontal -label "Disabled" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont11 -state disabled
|
||||
|
||||
scale .right.cont1 -from 0 -to 128 -length 200 \
|
||||
-command {printWhatz "ControlChange 0.0 1 " 1} \
|
||||
-orient horizontal -label "Direct Stick Mix" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont1
|
||||
-command {printWhatz "ControlChange 0.0 1 " 1} \
|
||||
-orient horizontal -label "Direct Stick Mix" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont1
|
||||
|
||||
pack .left.volume -padx 10 -pady 10
|
||||
pack .left.bPressure -padx 10 -pady 10
|
||||
@@ -146,35 +134,31 @@ pack .left -side left
|
||||
pack .right -side right
|
||||
|
||||
#bind all <KeyPress> {
|
||||
bind . <KeyPress> {
|
||||
noteOn $pitch $press
|
||||
}
|
||||
bind . <KeyPress> { noteOn $pitch $press }
|
||||
|
||||
# Bind an X windows "close" event with the Exit routine
|
||||
bind . <Destroy> +myExit
|
||||
|
||||
proc myExit {} {
|
||||
global pitch outID
|
||||
puts $outID [format "ExitProgram"]
|
||||
flush $outID
|
||||
close $outID
|
||||
global pitch
|
||||
puts [format "ExitProgram"]
|
||||
flush stdout
|
||||
close stdout
|
||||
exit
|
||||
}
|
||||
|
||||
proc noteOn {pitchVal pressVal} {
|
||||
global outID
|
||||
puts $outID [format "NoteOn 0.0 1 %3.2f %3.2f" $pitchVal $pressVal]
|
||||
flush $outID
|
||||
puts [format "NoteOn 0.0 1 %3.2f %3.2f" $pitchVal $pressVal]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
proc noteOff {pitchVal pressVal} {
|
||||
global outID
|
||||
puts $outID [format "NoteOff 0.0 1 %3.2f %3.2f" $pitchVal $pressVal]
|
||||
flush $outID
|
||||
puts [format "NoteOff 0.0 1 %3.2f %3.2f" $pitchVal $pressVal]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
proc patchChange {value} {
|
||||
global outID preset
|
||||
global preset
|
||||
if {$preset == 1} {
|
||||
.right.cont11 config -state normal -label "Vibrato Rate"
|
||||
} else {
|
||||
@@ -184,84 +168,48 @@ proc patchChange {value} {
|
||||
}
|
||||
|
||||
proc printWhatz {tag value1 value2 } {
|
||||
global outID
|
||||
puts $outID [format "%s %2i %3.2f" $tag $value1 $value2]
|
||||
flush $outID
|
||||
puts [format "%s %2i %3.2f" $tag $value1 $value2]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
proc changePress {value} {
|
||||
global outID
|
||||
puts $outID [format "AfterTouch 0.0 1 %3.2f" $value]
|
||||
flush $outID
|
||||
puts [format "AfterTouch 0.0 1 %3.2f" $value]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
proc changePitch {value} {
|
||||
global outID
|
||||
puts $outID [format "PitchChange 0.0 1 %3.2f" $value]
|
||||
flush $outID
|
||||
puts [format "PitchChange 0.0 1 %3.2f" $value]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
# Socket connection procedure
|
||||
set d .socketdialog
|
||||
bind . <Configure> { center_the_toplevel %W }
|
||||
proc center_the_toplevel { w } {
|
||||
|
||||
proc setComm {} {
|
||||
global outID commtype d
|
||||
if {$commtype == "stdout"} {
|
||||
if { [string compare "stdout" $outID] } {
|
||||
set i [tk_dialog .dialog "Break Socket Connection?" {You are about to break an existing socket connection ... is this what you want to do?} "" 0 Cancel OK]
|
||||
switch $i {
|
||||
0 {set commtype "socket"}
|
||||
1 {close $outID
|
||||
set outID "stdout"}
|
||||
}
|
||||
}
|
||||
} elseif { ![string compare "stdout" $outID] } {
|
||||
set sockport 2001
|
||||
set sockhost localhost
|
||||
toplevel $d
|
||||
wm title $d "STK Client Socket Connection"
|
||||
wm resizable $d 0 0
|
||||
grab $d
|
||||
label $d.message -text "Specify a socket host and port number below (if different than the STK defaults shown) and then click the \"Connect\" button to invoke a socket-client connection attempt to the STK socket server." \
|
||||
-background white -font {Helvetica 10 bold} \
|
||||
-wraplength 3i -justify left
|
||||
frame $d.sockhost
|
||||
entry $d.sockhost.entry -width 15
|
||||
label $d.sockhost.text -text "Socket Host:" \
|
||||
-font {Helvetica 10 bold}
|
||||
frame $d.sockport
|
||||
entry $d.sockport.entry -width 15
|
||||
label $d.sockport.text -text "Socket Port:" \
|
||||
-font {Helvetica 10 bold}
|
||||
pack $d.message -side top -padx 5 -pady 10
|
||||
pack $d.sockhost.text -side left -padx 1 -pady 2
|
||||
pack $d.sockhost.entry -side right -padx 5 -pady 2
|
||||
pack $d.sockhost -side top -padx 5 -pady 2
|
||||
pack $d.sockport.text -side left -padx 1 -pady 2
|
||||
pack $d.sockport.entry -side right -padx 5 -pady 2
|
||||
pack $d.sockport -side top -padx 5 -pady 2
|
||||
$d.sockhost.entry insert 0 $sockhost
|
||||
$d.sockport.entry insert 0 $sockport
|
||||
frame $d.buttons
|
||||
button $d.buttons.cancel -text "Cancel" -bg grey66 \
|
||||
-command { set commtype "stdout"
|
||||
set outID "stdout"
|
||||
destroy $d }
|
||||
button $d.buttons.connect -text "Connect" -bg grey66 \
|
||||
-command {
|
||||
set sockhost [$d.sockhost.entry get]
|
||||
set sockport [$d.sockport.entry get]
|
||||
set err [catch {socket $sockhost $sockport} outID]
|
||||
# Callback on the <Configure> event for a toplevel
|
||||
# that should be centered on the screen
|
||||
|
||||
if {$err == 0} {
|
||||
destroy $d
|
||||
} else {
|
||||
tk_dialog $d.error "Socket Error" {Error: Unable to make socket connection. Make sure the STK socket server is first running and that the port number is correct.} "" 0 OK
|
||||
} }
|
||||
pack $d.buttons.cancel -side left -padx 5 -pady 10
|
||||
pack $d.buttons.connect -side right -padx 5 -pady 10
|
||||
pack $d.buttons -side bottom -padx 5 -pady 10
|
||||
}
|
||||
# Make sure that we aren't configuring a child window
|
||||
if { [string equal $w [winfo toplevel $w]] } {
|
||||
|
||||
# Calculate the desired geometry
|
||||
set width [winfo reqwidth $w]
|
||||
set height [winfo reqheight $w]
|
||||
set x [expr { ( [winfo vrootwidth $w] - $width ) / 2 }]
|
||||
set y [expr { ( [winfo vrootheight $w] - $height ) / 2 }]
|
||||
#set y 0
|
||||
|
||||
# Hand the geometry off to the window manager
|
||||
wm geometry $w ${width}x${height}+${x}+${y}
|
||||
|
||||
# Unbind <Configure> so that this procedure is
|
||||
# not called again when the window manager finishes
|
||||
# centering the window. Also, revert geometry management
|
||||
# to internal default for subsequent size changes.
|
||||
bind $w <Configure> {}
|
||||
wm geometry $w ""
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,8 +9,6 @@ set cont4 64.0
|
||||
set cont7 128.0
|
||||
set cont11 64.0
|
||||
set cont44 24.0
|
||||
set outID "stdout"
|
||||
set commtype "stdout"
|
||||
set oldpatch 0
|
||||
set patchnum 0
|
||||
|
||||
@@ -19,17 +17,6 @@ wm title . "STK Physical Model Controller"
|
||||
wm iconname . "physical"
|
||||
. config -bg black
|
||||
|
||||
# Configure "communications" menu
|
||||
menu .menu -tearoff 0
|
||||
menu .menu.communication -tearoff 0
|
||||
.menu add cascade -label "Communication" -menu .menu.communication \
|
||||
-underline 0
|
||||
.menu.communication add radio -label "Console" -variable commtype \
|
||||
-value "stdout" -command { setComm }
|
||||
.menu.communication add radio -label "Socket" -variable commtype \
|
||||
-value "socket" -command { setComm }
|
||||
. configure -menu .menu
|
||||
|
||||
# Configure patch change buttons
|
||||
frame .radios1 -bg black
|
||||
frame .radios2 -bg black
|
||||
@@ -68,7 +55,6 @@ pack .radios2.pluk -side left -padx 5 -pady 10
|
||||
pack .radios2.karp -side left -padx 5 -pady 10
|
||||
pack .radios2.sitr -side left -padx 5 -pady 10
|
||||
pack .radios2.mand -side left -padx 5 -pady 10
|
||||
pack .radios2.blot -side left -padx 5 -pady 10
|
||||
|
||||
pack .radios1
|
||||
pack .radios2
|
||||
@@ -100,50 +86,50 @@ frame .left -bg black
|
||||
frame .right -bg black
|
||||
|
||||
scale .left.volume -from 0 -to 128 -length 200 \
|
||||
-command {printWhatz "ControlChange 0.0 1 " 7} \
|
||||
-orient horizontal -label "Volume" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont7
|
||||
-command {printWhatz "ControlChange 0.0 1 " 7} \
|
||||
-orient horizontal -label "Volume" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont7
|
||||
|
||||
scale .left.bPressure -from 0 -to 128 -length 200 \
|
||||
-command {changePress } -variable press \
|
||||
-orient horizontal -label "Breath Pressure" \
|
||||
-tickinterval 32 -showvalue true -bg grey66
|
||||
-command {changePress } -variable press \
|
||||
-orient horizontal -label "Breath Pressure" \
|
||||
-tickinterval 32 -showvalue true -bg grey66
|
||||
|
||||
scale .left.pitch -from 0 -to 128 -length 200 \
|
||||
-command {changePitch } -variable pitch \
|
||||
-orient horizontal -label "MIDI Note Number" \
|
||||
-tickinterval 32 -showvalue true -bg grey66
|
||||
-command {changePitch } -variable pitch \
|
||||
-orient horizontal -label "MIDI Note Number" \
|
||||
-tickinterval 32 -showvalue true -bg grey66
|
||||
|
||||
scale .left.cont2 -from 0 -to 128 -length 200 \
|
||||
-command {printWhatz "ControlChange 0.0 1 " 2} \
|
||||
-orient horizontal -label "Reed Stiffness" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont2
|
||||
-command {printWhatz "ControlChange 0.0 1 " 2} \
|
||||
-orient horizontal -label "Reed Stiffness" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont2
|
||||
|
||||
scale .right.reverb -from 0 -to 128 -length 200 \
|
||||
-command {printWhatz "ControlChange 0.0 1 " 44} \
|
||||
-orient horizontal -label "Reverb Mix" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont44
|
||||
-command {printWhatz "ControlChange 0.0 1 " 44} \
|
||||
-orient horizontal -label "Reverb Mix" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont44
|
||||
|
||||
scale .right.cont4 -from 0 -to 128 -length 200 \
|
||||
-command {printWhatz "ControlChange 0.0 1 " 4} \
|
||||
-orient horizontal -label "Breath Noise" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont4
|
||||
-command {printWhatz "ControlChange 0.0 1 " 4} \
|
||||
-orient horizontal -label "Breath Noise" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont4
|
||||
|
||||
scale .right.cont11 -from 0 -to 128 -length 200 \
|
||||
-command {printWhatz "ControlChange 0.0 1 " 11} \
|
||||
-orient horizontal -label "Vibrato Rate" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont11
|
||||
-command {printWhatz "ControlChange 0.0 1 " 11} \
|
||||
-orient horizontal -label "Vibrato Rate" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont11
|
||||
|
||||
scale .right.cont1 -from 0 -to 128 -length 200 \
|
||||
-command {printWhatz "ControlChange 0.0 1 " 1} \
|
||||
-orient horizontal -label "Vibrato Amount" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont1
|
||||
-command {printWhatz "ControlChange 0.0 1 " 1} \
|
||||
-orient horizontal -label "Vibrato Amount" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont1
|
||||
|
||||
pack .left.volume -padx 10 -pady 10
|
||||
pack .left.bPressure -padx 10 -pady 10
|
||||
@@ -157,37 +143,32 @@ pack .right.cont1 -padx 10 -pady 10
|
||||
pack .left -side left
|
||||
pack .right -side right
|
||||
|
||||
#bind all <KeyPress> {
|
||||
bind . <KeyPress> {
|
||||
noteOn $pitch $press
|
||||
}
|
||||
bind . <KeyPress> { noteOn $pitch $press }
|
||||
|
||||
# Bind an X windows "close" event with the Exit routine
|
||||
bind . <Destroy> +myExit
|
||||
|
||||
proc myExit {} {
|
||||
global pitch outID
|
||||
puts $outID [format "ExitProgram"]
|
||||
flush $outID
|
||||
close $outID
|
||||
global pitch
|
||||
puts [format "ExitProgram"]
|
||||
flush stdout
|
||||
close stdout
|
||||
exit
|
||||
}
|
||||
|
||||
proc noteOn {pitchVal pressVal} {
|
||||
global outID
|
||||
puts $outID [format "NoteOn 0.0 1 %f %f" $pitchVal $pressVal]
|
||||
flush $outID
|
||||
puts [format "NoteOn 0.0 1 %f %f" $pitchVal $pressVal]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
proc noteOff {pitchVal pressVal} {
|
||||
global outID
|
||||
puts $outID [format "NoteOff 0.0 1 %f %f" $pitchVal $pressVal]
|
||||
flush $outID
|
||||
puts [format "NoteOff 0.0 1 %f %f" $pitchVal $pressVal]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
proc patchChange {value} {
|
||||
global outID bitmappath cont1 cont2 cont4 cont11 pitch oldpatch
|
||||
puts $outID [format "ProgramChange 0.0 1 %i" $value]
|
||||
global bitmappath cont1 cont2 cont4 cont11 pitch oldpatch
|
||||
puts [format "ProgramChange 0.0 1 %i" $value]
|
||||
if {$value==0} { # Clarinet
|
||||
.pretty config -bitmap @$bitmappath/Klar.xbm
|
||||
.left.bPressure config -state normal -label "Breath Pressure"
|
||||
@@ -273,7 +254,7 @@ proc patchChange {value} {
|
||||
printWhatz "ControlChange 0.0 1 " 2 $cont2
|
||||
printWhatz "ControlChange 0.0 1 " 4 $cont4
|
||||
printWhatz "ControlChange 0.0 1 " 11 $cont11
|
||||
puts $outID [format "NoteOn 0.0 1 %3.2f %3.2f" $pitch $press]
|
||||
puts [format "NoteOn 0.0 1 %3.2f %3.2f" $pitch $press]
|
||||
}
|
||||
if {$value==5} { # Bottle
|
||||
.pretty config -bitmap @$bitmappath/prcFunny.xbm
|
||||
@@ -363,87 +344,49 @@ proc patchChange {value} {
|
||||
}
|
||||
|
||||
proc printWhatz {tag value1 value2 } {
|
||||
global outID
|
||||
puts $outID [format "%s %i %f" $tag $value1 $value2]
|
||||
flush $outID
|
||||
puts [format "%s %i %f" $tag $value1 $value2]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
proc changePress {value} {
|
||||
global outID patchnum
|
||||
global patchnum
|
||||
if { $patchnum<7 || $patchnum>9 } {
|
||||
puts $outID [format "AfterTouch 0.0 1 %f" $value]
|
||||
flush $outID
|
||||
puts [format "AfterTouch 0.0 1 %f" $value]
|
||||
flush stdout
|
||||
}
|
||||
}
|
||||
|
||||
proc changePitch {value} {
|
||||
global outID
|
||||
puts $outID [format "PitchChange 0.0 1 %.3f" $value]
|
||||
flush $outID
|
||||
puts [format "PitchChange 0.0 1 %.3f" $value]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
# Socket connection procedure
|
||||
set d .socketdialog
|
||||
bind . <Configure> { center_the_toplevel %W }
|
||||
proc center_the_toplevel { w } {
|
||||
|
||||
proc setComm {} {
|
||||
global outID
|
||||
global commtype
|
||||
global d
|
||||
if {$commtype == "stdout"} {
|
||||
if { [string compare "stdout" $outID] } {
|
||||
set i [tk_dialog .dialog "Break Socket Connection?" {You are about to break an existing socket connection ... is this what you want to do?} "" 0 Cancel OK]
|
||||
switch $i {
|
||||
0 {set commtype "socket"}
|
||||
1 {close $outID
|
||||
set outID "stdout"}
|
||||
}
|
||||
}
|
||||
} elseif { ![string compare "stdout" $outID] } {
|
||||
set sockport 2001
|
||||
set sockhost localhost
|
||||
toplevel $d
|
||||
wm title $d "STK Client Socket Connection"
|
||||
wm resizable $d 0 0
|
||||
grab $d
|
||||
label $d.message -text "Specify a socket host and port number below (if different than the STK defaults shown) and then click the \"Connect\" button to invoke a socket-client connection attempt to the STK socket server." \
|
||||
-background white -font {Helvetica 10 bold} \
|
||||
-wraplength 3i -justify left
|
||||
frame $d.sockhost
|
||||
entry $d.sockhost.entry -width 15
|
||||
label $d.sockhost.text -text "Socket Host:" \
|
||||
-font {Helvetica 10 bold}
|
||||
frame $d.sockport
|
||||
entry $d.sockport.entry -width 15
|
||||
label $d.sockport.text -text "Socket Port:" \
|
||||
-font {Helvetica 10 bold}
|
||||
pack $d.message -side top -padx 5 -pady 10
|
||||
pack $d.sockhost.text -side left -padx 1 -pady 2
|
||||
pack $d.sockhost.entry -side right -padx 5 -pady 2
|
||||
pack $d.sockhost -side top -padx 5 -pady 2
|
||||
pack $d.sockport.text -side left -padx 1 -pady 2
|
||||
pack $d.sockport.entry -side right -padx 5 -pady 2
|
||||
pack $d.sockport -side top -padx 5 -pady 2
|
||||
$d.sockhost.entry insert 0 $sockhost
|
||||
$d.sockport.entry insert 0 $sockport
|
||||
frame $d.buttons
|
||||
button $d.buttons.cancel -text "Cancel" -bg grey66 \
|
||||
-command { set commtype "stdout"
|
||||
set outID "stdout"
|
||||
destroy $d }
|
||||
button $d.buttons.connect -text "Connect" -bg grey66 \
|
||||
-command {
|
||||
set sockhost [$d.sockhost.entry get]
|
||||
set sockport [$d.sockport.entry get]
|
||||
set err [catch {socket $sockhost $sockport} outID]
|
||||
# Callback on the <Configure> event for a toplevel
|
||||
# that should be centered on the screen
|
||||
|
||||
if {$err == 0} {
|
||||
destroy $d
|
||||
} else {
|
||||
tk_dialog $d.error "Socket Error" {Error: Unable to make socket connection. Make sure the STK socket server is first running and that the port number is correct.} "" 0 OK
|
||||
} }
|
||||
pack $d.buttons.cancel -side left -padx 5 -pady 10
|
||||
pack $d.buttons.connect -side right -padx 5 -pady 10
|
||||
pack $d.buttons -side bottom -padx 5 -pady 10
|
||||
}
|
||||
}
|
||||
# Make sure that we aren't configuring a child window
|
||||
if { [string equal $w [winfo toplevel $w]] } {
|
||||
|
||||
# Calculate the desired geometry
|
||||
set width [winfo reqwidth $w]
|
||||
set height [winfo reqheight $w]
|
||||
set x [expr { ( [winfo vrootwidth $w] - $width ) / 2 }]
|
||||
set y [expr { ( [winfo vrootheight $w] - $height ) / 2 }]
|
||||
#set y 0
|
||||
|
||||
# Hand the geometry off to the window manager
|
||||
wm geometry $w ${width}x${height}+${x}+${y}
|
||||
|
||||
# Unbind <Configure> so that this procedure is
|
||||
# not called again when the window manager finishes
|
||||
# centering the window. Also, revert geometry management
|
||||
# to internal default for subsequent size changes.
|
||||
bind $w <Configure> {}
|
||||
wm geometry $w ""
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
@@ -6,8 +6,6 @@ set cont1 64.0
|
||||
set cont4 64.0
|
||||
set cont11 64.0
|
||||
set cont99 24.0
|
||||
set outID "stdout"
|
||||
set commtype "stdout"
|
||||
set patchnum 0
|
||||
|
||||
# Configure main window
|
||||
@@ -15,48 +13,37 @@ wm title . "STK Shakers Controller"
|
||||
wm iconname . "shakers"
|
||||
. config -bg black
|
||||
|
||||
# Configure "communications" menu
|
||||
menu .menu -tearoff 0
|
||||
menu .menu.communication -tearoff 0
|
||||
.menu add cascade -label "Communication" -menu .menu.communication \
|
||||
-underline 0
|
||||
.menu.communication add radio -label "Console" -variable commtype \
|
||||
-value "stdout" -command { setComm }
|
||||
.menu.communication add radio -label "Socket" -variable commtype \
|
||||
-value "socket" -command { setComm }
|
||||
. configure -menu .menu
|
||||
|
||||
# Configure sliders
|
||||
frame .right -bg black
|
||||
|
||||
scale .right.bPressure -from 0 -to 128 -length 300 \
|
||||
-command {changePress } -variable press\
|
||||
-orient horizontal -label "Shake Energy" \
|
||||
-tickinterval 32 -showvalue true -bg grey66
|
||||
-command {changePress } -variable press\
|
||||
-orient horizontal -label "Shake Energy" \
|
||||
-tickinterval 32 -showvalue true -bg grey66
|
||||
|
||||
scale .right.cont2 -from 0 -to 128 -length 300 \
|
||||
-command {printWhatz "ControlChange -1.0 1 " 11} \
|
||||
-orient horizontal -label "(<--High) System Damping (Low-->)" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont4
|
||||
-command {printWhatz "ControlChange -1.0 1 " 11} \
|
||||
-orient horizontal -label "(<--High) System Damping (Low-->)" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont4
|
||||
|
||||
scale .right.cont3 -from 0 -to 128 -length 300 \
|
||||
-command {printWhatz "ControlChange -1.0 1 " 4} \
|
||||
-orient horizontal -label "Number of Objects" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont11
|
||||
-command {printWhatz "ControlChange -1.0 1 " 4} \
|
||||
-orient horizontal -label "Number of Objects" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont11
|
||||
|
||||
scale .right.vibrato -from 0 -to 128 -length 300 \
|
||||
-command {printWhatz "ControlChange -1.0 1 " 1} \
|
||||
-orient horizontal -label "Resonance Center Freq." \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont1
|
||||
-command {printWhatz "ControlChange -1.0 1 " 1} \
|
||||
-orient horizontal -label "Resonance Center Freq." \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont1
|
||||
|
||||
scale .right.reverb -from 0 -to 128 -length 300 \
|
||||
-command {printWhatz "ControlChange -1.0 1 " 44} \
|
||||
-orient horizontal -label "Reverb Mix" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont99
|
||||
-command {printWhatz "ControlChange -1.0 1 " 44} \
|
||||
-orient horizontal -label "Reverb Mix" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont99
|
||||
|
||||
pack .right.bPressure -padx 10 -pady 10
|
||||
pack .right.vibrato -padx 10 -pady 10
|
||||
@@ -73,89 +60,88 @@ frame .buttons.columns.left1 -bg black
|
||||
frame .buttons.columns.left2 -bg black
|
||||
|
||||
radiobutton .buttons.columns.left1.maraca -text Maraca -bg grey66 \
|
||||
-command { patchChange 0 } -variable patchnum -width 12 \
|
||||
-command { patchChange 0 } -variable patchnum -width 15 \
|
||||
-justify left -value 0
|
||||
radiobutton .buttons.columns.left1.sekere -text Sekere -bg grey66 \
|
||||
-command { patchChange 2 } -variable patchnum -width 12 \
|
||||
-justify left -value 2
|
||||
radiobutton .buttons.columns.left1.cabasa -text Cabasa -bg grey66 \
|
||||
-command { patchChange 1 } -variable patchnum -width 12 \
|
||||
-command { patchChange 1 } -variable patchnum -width 15 \
|
||||
-justify left -value 1
|
||||
radiobutton .buttons.columns.left1.bamboo -text Bamboo -bg grey66 \
|
||||
-command { patchChange 5 } -variable patchnum -width 12 \
|
||||
-justify left -value 5
|
||||
radiobutton .buttons.columns.left1.waterdrp -text "Water Drops" -bg grey66 \
|
||||
-command { patchChange 4 } -variable patchnum -width 12 \
|
||||
-justify left -value 4
|
||||
radiobutton .buttons.columns.left1.sekere -text Sekere -bg grey66 \
|
||||
-command { patchChange 2 } -variable patchnum -width 15 \
|
||||
-justify left -value 2
|
||||
radiobutton .buttons.columns.left1.tambourn -text Tambourine -bg grey66 \
|
||||
-command { patchChange 6 } -variable patchnum -width 12 \
|
||||
-justify left -value 6
|
||||
radiobutton .buttons.columns.left1.sleighbl -text "Sleigh Bells" -bg grey66 \
|
||||
-command { patchChange 7 } -variable patchnum -width 12 \
|
||||
-justify left -value 7
|
||||
radiobutton .buttons.columns.left1.guiro -text Guiro -bg grey66 \
|
||||
-command { patchChange 3 } -variable patchnum -width 12 \
|
||||
-command { patchChange 3 } -variable patchnum -width 15 \
|
||||
-justify left -value 3
|
||||
radiobutton .buttons.columns.left1.sleighbl -text "Sleigh Bells" -bg grey66 \
|
||||
-command { patchChange 4 } -variable patchnum -width 15 \
|
||||
-justify left -value 4
|
||||
radiobutton .buttons.columns.left1.bamboo -text Bamboo -bg grey66 \
|
||||
-command { patchChange 5 } -variable patchnum -width 15 \
|
||||
-justify left -value 5
|
||||
radiobutton .buttons.columns.left1.sandpapr -text "Sand Paper" -bg grey66 \
|
||||
-command { patchChange 6 } -variable patchnum -width 15 \
|
||||
-justify left -value 6
|
||||
radiobutton .buttons.columns.left1.cokecan -text "Coke Can" -bg grey66 \
|
||||
-command { patchChange 7 } -variable patchnum -width 15 \
|
||||
-justify left -value 7
|
||||
radiobutton .buttons.columns.left1.stix1 -text Sticks -bg grey66 \
|
||||
-command { patchChange 8 } -variable patchnum -width 12 \
|
||||
-command { patchChange 8 } -variable patchnum -width 15 \
|
||||
-justify left -value 8
|
||||
radiobutton .buttons.columns.left1.crunch1 -text Crunch -bg grey66 \
|
||||
-command { patchChange 9 } -variable patchnum -width 12 \
|
||||
-command { patchChange 9 } -variable patchnum -width 15 \
|
||||
-justify left -value 9
|
||||
radiobutton .buttons.columns.left1.wrench -text Wrench -bg grey66 \
|
||||
-command { patchChange 10 } -variable patchnum -width 12 \
|
||||
radiobutton .buttons.columns.left1.bigrocks -text "Big Rocks" -bg grey66 \
|
||||
-command { patchChange 10 } -variable patchnum -width 15 \
|
||||
-justify left -value 10
|
||||
radiobutton .buttons.columns.left2.sandpapr -text "Sand Paper" -bg grey66 \
|
||||
-command { patchChange 11 } -variable patchnum -width 12 \
|
||||
radiobutton .buttons.columns.left1.littlerocks -text "Little Rocks" -bg grey66 \
|
||||
-command { patchChange 11 } -variable patchnum -width 15 \
|
||||
-justify left -value 11
|
||||
radiobutton .buttons.columns.left2.cokecan -text "Coke Can" -bg grey66 \
|
||||
-command { patchChange 12 } -variable patchnum -width 12 \
|
||||
-justify left -value 12
|
||||
radiobutton .buttons.columns.left2.nextmug -text "NeXT Mug" -bg grey66 \
|
||||
-command { patchChange 13 } -variable patchnum -width 12 \
|
||||
-justify left -value 13
|
||||
-command { patchChange 12 } -variable patchnum -width 15 \
|
||||
-justify left -value 12
|
||||
radiobutton .buttons.columns.left2.pennymug -text "Mug & Penny" -bg grey66 \
|
||||
-command { patchChange 14 } -variable patchnum -width 12 \
|
||||
-justify left -value 14
|
||||
-command { patchChange 13 } -variable patchnum -width 15 \
|
||||
-justify left -value 13
|
||||
radiobutton .buttons.columns.left2.nicklemug -text "Mug & Nickle" -bg grey66 \
|
||||
-command { patchChange 15 } -variable patchnum -width 12 \
|
||||
-justify left -value 15
|
||||
-command { patchChange 14 } -variable patchnum -width 15 \
|
||||
-justify left -value 14
|
||||
radiobutton .buttons.columns.left2.dimemug -text "Mug & Dime" -bg grey66 \
|
||||
-command { patchChange 16 } -variable patchnum -width 12 \
|
||||
-justify left -value 16
|
||||
-command { patchChange 15 } -variable patchnum -width 15 \
|
||||
-justify left -value 15
|
||||
radiobutton .buttons.columns.left2.quartermug -text "Mug & Quarter" -bg grey66 \
|
||||
-command { patchChange 17 } -variable patchnum -width 12 \
|
||||
-justify left -value 17
|
||||
-command { patchChange 16 } -variable patchnum -width 15 \
|
||||
-justify left -value 16
|
||||
radiobutton .buttons.columns.left2.francmug -text "Mug & Franc" -bg grey66 \
|
||||
-command { patchChange 18 } -variable patchnum -width 12 \
|
||||
-justify left -value 18
|
||||
-command { patchChange 17 } -variable patchnum -width 15 \
|
||||
-justify left -value 17
|
||||
radiobutton .buttons.columns.left2.pesomug -text "Mug & Peso" -bg grey66 \
|
||||
-command { patchChange 19 } -variable patchnum -width 12 \
|
||||
-command { patchChange 18 } -variable patchnum -width 15 \
|
||||
-justify left -value 18
|
||||
radiobutton .buttons.columns.left2.guiro -text Guiro -bg grey66 \
|
||||
-command { patchChange 19 } -variable patchnum -width 15 \
|
||||
-justify left -value 19
|
||||
radiobutton .buttons.columns.left2.bigrocks -text "Big Rocks" -bg grey66 \
|
||||
-command { patchChange 20 } -variable patchnum -width 12 \
|
||||
radiobutton .buttons.columns.left2.wrench -text Wrench -bg grey66 \
|
||||
-command { patchChange 20 } -variable patchnum -width 15 \
|
||||
-justify left -value 20
|
||||
radiobutton .buttons.columns.left2.littlerocks -text "Little Rocks" -bg grey66 \
|
||||
-command { patchChange 21 } -variable patchnum -width 12 \
|
||||
radiobutton .buttons.columns.left2.waterdrp -text "Water Drops" -bg grey66 \
|
||||
-command { patchChange 21 } -variable patchnum -width 15 \
|
||||
-justify left -value 21
|
||||
radiobutton .buttons.columns.left1.tunedbamboo -text "Tuned Bamboo" -bg grey66 \
|
||||
-command { patchChange 22 } -variable patchnum -width 12 \
|
||||
radiobutton .buttons.columns.left2.tunedbamboo -text "Tuned Bamboo" -bg grey66 \
|
||||
-command { patchChange 22 } -variable patchnum -width 15 \
|
||||
-justify left -value 22
|
||||
|
||||
pack .buttons.columns.left1.maraca -pady 5
|
||||
pack .buttons.columns.left1.sekere -pady 5
|
||||
pack .buttons.columns.left1.cabasa -pady 5
|
||||
pack .buttons.columns.left1.bamboo -pady 5
|
||||
pack .buttons.columns.left1.tunedbamboo -pady 5
|
||||
pack .buttons.columns.left1.waterdrp -pady 5
|
||||
pack .buttons.columns.left1.sekere -pady 5
|
||||
pack .buttons.columns.left1.tambourn -pady 5
|
||||
pack .buttons.columns.left1.sleighbl -pady 5
|
||||
pack .buttons.columns.left1.guiro -pady 5
|
||||
pack .buttons.columns.left1.bamboo -pady 5
|
||||
pack .buttons.columns.left1.sandpapr -pady 5
|
||||
pack .buttons.columns.left1.cokecan -pady 5
|
||||
pack .buttons.columns.left1.stix1 -pady 5
|
||||
pack .buttons.columns.left1.crunch1 -pady 5
|
||||
pack .buttons.columns.left1.wrench -pady 5
|
||||
pack .buttons.columns.left2.sandpapr -pady 5
|
||||
pack .buttons.columns.left2.cokecan -pady 5
|
||||
pack .buttons.columns.left1.bigrocks -pady 5
|
||||
pack .buttons.columns.left1.littlerocks -pady 5
|
||||
|
||||
pack .buttons.columns.left2.nextmug -pady 5
|
||||
pack .buttons.columns.left2.pennymug -pady 5
|
||||
pack .buttons.columns.left2.nicklemug -pady 5
|
||||
@@ -163,8 +149,10 @@ pack .buttons.columns.left2.dimemug -pady 5
|
||||
pack .buttons.columns.left2.quartermug -pady 5
|
||||
pack .buttons.columns.left2.francmug -pady 5
|
||||
pack .buttons.columns.left2.pesomug -pady 5
|
||||
pack .buttons.columns.left2.bigrocks -pady 5
|
||||
pack .buttons.columns.left2.littlerocks -pady 5
|
||||
pack .buttons.columns.left2.guiro -pady 5
|
||||
pack .buttons.columns.left2.wrench -pady 5
|
||||
pack .buttons.columns.left2.waterdrp -pady 5
|
||||
pack .buttons.columns.left2.tunedbamboo -pady 5
|
||||
|
||||
pack .buttons.columns.left1 -side left -padx 10
|
||||
pack .buttons.columns.left2 -side left -padx 10
|
||||
@@ -184,94 +172,56 @@ bind . <KeyPress> {
|
||||
bind . <Destroy> +myExit
|
||||
|
||||
proc myExit {} {
|
||||
global outID
|
||||
puts $outID [format "ExitProgram"]
|
||||
flush $outID
|
||||
close $outID
|
||||
puts [format "ExitProgram"]
|
||||
flush stdout
|
||||
close stdout
|
||||
exit
|
||||
}
|
||||
|
||||
proc patchChange {value} {
|
||||
global outID press
|
||||
puts $outID [format "NoteOn -1.0 1 %i $press" $value]
|
||||
flush $outID
|
||||
global press
|
||||
puts [format "NoteOn -1.0 1 %i $press" $value]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
proc printWhatz {tag value1 value2 } {
|
||||
global outID
|
||||
puts $outID [format "%s %i %f" $tag $value1 $value2]
|
||||
flush $outID
|
||||
puts [format "%s %i %f" $tag $value1 $value2]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
proc changePress {value} {
|
||||
global outID
|
||||
puts $outID [format "AfterTouch -1.0 1 %f" $value]
|
||||
flush $outID
|
||||
puts [format "AfterTouch -1.0 1 %f" $value]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
eval patchChange $patchnum
|
||||
|
||||
# Socket connection procedure
|
||||
set d .socketdialog
|
||||
bind . <Configure> { center_the_toplevel %W }
|
||||
proc center_the_toplevel { w } {
|
||||
|
||||
proc setComm {} {
|
||||
global outID
|
||||
global commtype
|
||||
global d
|
||||
if {$commtype == "stdout"} {
|
||||
if { [string compare "stdout" $outID] } {
|
||||
set i [tk_dialog .dialog "Break Socket Connection?" {You are about to break an existing socket connection ... is this what you want to do?} "" 0 Cancel OK]
|
||||
switch $i {
|
||||
0 {set commtype "socket"}
|
||||
1 {close $outID
|
||||
set outID "stdout"}
|
||||
}
|
||||
}
|
||||
} elseif { ![string compare "stdout" $outID] } {
|
||||
set sockport 2001
|
||||
set sockhost localhost
|
||||
toplevel $d
|
||||
wm title $d "STK Client Socket Connection"
|
||||
wm resizable $d 0 0
|
||||
grab $d
|
||||
label $d.message -text "Specify a socket host and port number below (if different than the STK defaults shown) and then click the \"Connect\" button to invoke a socket-client connection attempt to the STK socket server." \
|
||||
-background white -font {Helvetica 10 bold} \
|
||||
-wraplength 3i -justify left
|
||||
frame $d.sockhost
|
||||
entry $d.sockhost.entry -width 15
|
||||
label $d.sockhost.text -text "Socket Host:" \
|
||||
-font {Helvetica 10 bold}
|
||||
frame $d.sockport
|
||||
entry $d.sockport.entry -width 15
|
||||
label $d.sockport.text -text "Socket Port:" \
|
||||
-font {Helvetica 10 bold}
|
||||
pack $d.message -side top -padx 5 -pady 10
|
||||
pack $d.sockhost.text -side left -padx 1 -pady 2
|
||||
pack $d.sockhost.entry -side right -padx 5 -pady 2
|
||||
pack $d.sockhost -side top -padx 5 -pady 2
|
||||
pack $d.sockport.text -side left -padx 1 -pady 2
|
||||
pack $d.sockport.entry -side right -padx 5 -pady 2
|
||||
pack $d.sockport -side top -padx 5 -pady 2
|
||||
$d.sockhost.entry insert 0 $sockhost
|
||||
$d.sockport.entry insert 0 $sockport
|
||||
frame $d.buttons
|
||||
button $d.buttons.cancel -text "Cancel" -bg grey66 \
|
||||
-command { set commtype "stdout"
|
||||
set outID "stdout"
|
||||
destroy $d }
|
||||
button $d.buttons.connect -text "Connect" -bg grey66 \
|
||||
-command {
|
||||
set sockhost [$d.sockhost.entry get]
|
||||
set sockport [$d.sockport.entry get]
|
||||
set err [catch {socket $sockhost $sockport} outID]
|
||||
# Callback on the <Configure> event for a toplevel
|
||||
# that should be centered on the screen
|
||||
|
||||
if {$err == 0} {
|
||||
destroy $d
|
||||
} else {
|
||||
tk_dialog $d.error "Socket Error" {Error: Unable to make socket connection. Make sure the STK socket server is first running and that the port number is correct.} "" 0 OK
|
||||
} }
|
||||
pack $d.buttons.cancel -side left -padx 5 -pady 10
|
||||
pack $d.buttons.connect -side right -padx 5 -pady 10
|
||||
pack $d.buttons -side bottom -padx 5 -pady 10
|
||||
}
|
||||
# Make sure that we aren't configuring a child window
|
||||
if { [string equal $w [winfo toplevel $w]] } {
|
||||
|
||||
# Calculate the desired geometry
|
||||
set width [winfo reqwidth $w]
|
||||
set height [winfo reqheight $w]
|
||||
set x [expr { ( [winfo vrootwidth $w] - $width ) / 2 }]
|
||||
set y [expr { ( [winfo vrootheight $w] - $height ) / 2 }]
|
||||
#set y 0
|
||||
|
||||
# Hand the geometry off to the window manager
|
||||
wm geometry $w ${width}x${height}+${x}+${y}
|
||||
|
||||
# Unbind <Configure> so that this procedure is
|
||||
# not called again when the window manager finishes
|
||||
# centering the window. Also, revert geometry management
|
||||
# to internal default for subsequent size changes.
|
||||
bind $w <Configure> {}
|
||||
wm geometry $w ""
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ set cont1 20.0
|
||||
set cont2 64.0
|
||||
set cont4 64.0
|
||||
set cont11 64.0
|
||||
set outID "stdout"
|
||||
set commtype "stdout"
|
||||
set patchnum 17
|
||||
|
||||
# Configure main window
|
||||
@@ -16,17 +14,6 @@ wm title . "STK Voice Model Controller"
|
||||
wm iconname . "voice"
|
||||
. config -bg black
|
||||
|
||||
# Configure "communications" menu
|
||||
menu .menu -tearoff 0
|
||||
menu .menu.communication -tearoff 0
|
||||
.menu add cascade -label "Communication" -menu .menu.communication \
|
||||
-underline 0
|
||||
.menu.communication add radio -label "Console" -variable commtype \
|
||||
-value "stdout" -command { setComm }
|
||||
.menu.communication add radio -label "Socket" -variable commtype \
|
||||
-value "socket" -command { setComm }
|
||||
. configure -menu .menu
|
||||
|
||||
# Configure patch change buttons
|
||||
frame .instChoice -bg black
|
||||
|
||||
@@ -67,38 +54,38 @@ frame .left -bg black
|
||||
frame .right -bg black
|
||||
|
||||
scale .left.bPressure -from 0 -to 128 -length 200 \
|
||||
-command {changePress } -variable press \
|
||||
-orient horizontal -label "Loudness (Spectral Tilt)" \
|
||||
-tickinterval 32 -showvalue true -bg grey66
|
||||
-command {changePress } -variable press \
|
||||
-orient horizontal -label "Loudness (Spectral Tilt)" \
|
||||
-tickinterval 32 -showvalue true -bg grey66
|
||||
|
||||
scale .left.pitch -from 0 -to 128 -length 200 \
|
||||
-command {changePitch } -variable pitch \
|
||||
-orient horizontal -label "MIDI Note Number" \
|
||||
-tickinterval 32 -showvalue true -bg grey66
|
||||
-command {changePitch } -variable pitch \
|
||||
-orient horizontal -label "MIDI Note Number" \
|
||||
-tickinterval 32 -showvalue true -bg grey66
|
||||
|
||||
scale .left.cont1 -from 0 -to 128 -length 200 \
|
||||
-command {printWhatz "ControlChange -1.0 1 " 2} \
|
||||
-orient horizontal -label "Formant Q / Voiced/Un." \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont2
|
||||
-command {printWhatz "ControlChange -1.0 1 " 2} \
|
||||
-orient horizontal -label "Formant Q / Voiced/Un." \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont2
|
||||
|
||||
scale .right.cont2 -from 0 -to 128 -length 200 \
|
||||
-command {printWhatz "ControlChange -1.0 1 " 4} \
|
||||
-orient horizontal -label "Vowel (Bass, Tenor, Alto, Sop.)" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont4
|
||||
-command {printWhatz "ControlChange -1.0 1 " 4} \
|
||||
-orient horizontal -label "Vowel (Bass, Tenor, Alto, Sop.)" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont4
|
||||
|
||||
scale .right.cont3 -from 0 -to 128 -length 200 \
|
||||
-command {printWhatz "ControlChange -1.0 1 " 11} \
|
||||
-orient horizontal -label "Vibrato Rate" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont11
|
||||
-command {printWhatz "ControlChange -1.0 1 " 11} \
|
||||
-orient horizontal -label "Vibrato Rate" \
|
||||
-tickinterval 32 -showvalue true -bg grey66 \
|
||||
-variable cont11
|
||||
|
||||
scale .right.vibrato -from 0 -to 128 -length 200 \
|
||||
-command {printWhatz "ControlChange -1.0 1 " 1} \
|
||||
-orient horizontal -label "Vibrato Amount" \
|
||||
-tickinterval 32 -showvalue true -bg grey66\
|
||||
-variable cont1
|
||||
-command {printWhatz "ControlChange -1.0 1 " 1} \
|
||||
-orient horizontal -label "Vibrato Amount" \
|
||||
-tickinterval 32 -showvalue true -bg grey66\
|
||||
-variable cont1
|
||||
|
||||
pack .left.bPressure -padx 10 -pady 10
|
||||
pack .left.pitch -padx 10 -pady 10
|
||||
@@ -114,35 +101,33 @@ pack .right -side right
|
||||
bind . <Destroy> +myExit
|
||||
|
||||
proc myExit {} {
|
||||
global pitch outID
|
||||
puts $outID [format "ExitProgram"]
|
||||
flush $outID
|
||||
close $outID
|
||||
global pitch
|
||||
puts [format "ExitProgram"]
|
||||
flush stdout
|
||||
close stdout
|
||||
exit
|
||||
}
|
||||
|
||||
proc noteOn {pitchVal pressVal} {
|
||||
global outID
|
||||
puts $outID [format "NoteOn 0.0 1 %f %f" $pitchVal $pressVal]
|
||||
flush $outID
|
||||
puts [format "NoteOn 0.0 1 %f %f" $pitchVal $pressVal]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
proc noteOff {pitchVal pressVal} {
|
||||
global outID
|
||||
puts $outID [format "NoteOff 0.0 1 %f %f" $pitchVal $pressVal]
|
||||
flush $outID
|
||||
puts [format "NoteOff 0.0 1 %f %f" $pitchVal $pressVal]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
proc patchChange {value} {
|
||||
global outID bitmappath cont1 cont2 cont4 cont11
|
||||
puts $outID [format "ProgramChange 0.0 1 %i" $value]
|
||||
global bitmappath cont1 cont2 cont4 cont11
|
||||
puts [format "ProgramChange 0.0 1 %i" $value]
|
||||
if {$value==16} {
|
||||
.pretty config -bitmap @$bitmappath/KVoiceFM.xbm
|
||||
}
|
||||
if {$value==17} {
|
||||
.pretty config -bitmap @$bitmappath/KVoicForm.xbm
|
||||
}
|
||||
flush $outID
|
||||
flush stdout
|
||||
set cont1 0.0
|
||||
set cont2 20.0
|
||||
set cont4 64.0
|
||||
@@ -150,84 +135,46 @@ proc patchChange {value} {
|
||||
}
|
||||
|
||||
proc printWhatz {tag value1 value2 } {
|
||||
global outID
|
||||
puts $outID [format "%s %i %f" $tag $value1 $value2]
|
||||
flush $outID
|
||||
puts [format "%s %i %f" $tag $value1 $value2]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
proc changePress {value} {
|
||||
global outID
|
||||
puts $outID [format "AfterTouch 0.0 1 %f" $value]
|
||||
flush $outID
|
||||
puts [format "AfterTouch 0.0 1 %f" $value]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
proc changePitch {value} {
|
||||
global outID
|
||||
puts $outID [format "PitchChange 0.0 1 %.3f" $value]
|
||||
flush $outID
|
||||
puts [format "PitchChange 0.0 1 %.3f" $value]
|
||||
flush stdout
|
||||
}
|
||||
|
||||
# Socket connection procedure
|
||||
set d .socketdialog
|
||||
bind . <Configure> { center_the_toplevel %W }
|
||||
proc center_the_toplevel { w } {
|
||||
|
||||
proc setComm {} {
|
||||
global outID
|
||||
global commtype
|
||||
global d
|
||||
if {$commtype == "stdout"} {
|
||||
if { [string compare "stdout" $outID] } {
|
||||
set i [tk_dialog .dialog "Break Socket Connection?" {You are about to break an existing socket connection ... is this what you want to do?} "" 0 Cancel OK]
|
||||
switch $i {
|
||||
0 {set commtype "socket"}
|
||||
1 {close $outID
|
||||
set outID "stdout"}
|
||||
}
|
||||
}
|
||||
} elseif { ![string compare "stdout" $outID] } {
|
||||
set sockport 2001
|
||||
set sockhost localhost
|
||||
toplevel $d
|
||||
wm title $d "STK Client Socket Connection"
|
||||
wm resizable $d 0 0
|
||||
grab $d
|
||||
label $d.message -text "Specify a socket host and port number below (if different than the STK defaults shown) and then click the \"Connect\" button to invoke a socket-client connection attempt to the STK socket server." \
|
||||
-background white -font {Helvetica 10 bold} \
|
||||
-wraplength 3i -justify left
|
||||
frame $d.sockhost
|
||||
entry $d.sockhost.entry -width 15
|
||||
label $d.sockhost.text -text "Socket Host:" \
|
||||
-font {Helvetica 10 bold}
|
||||
frame $d.sockport
|
||||
entry $d.sockport.entry -width 15
|
||||
label $d.sockport.text -text "Socket Port:" \
|
||||
-font {Helvetica 10 bold}
|
||||
pack $d.message -side top -padx 5 -pady 10
|
||||
pack $d.sockhost.text -side left -padx 1 -pady 2
|
||||
pack $d.sockhost.entry -side right -padx 5 -pady 2
|
||||
pack $d.sockhost -side top -padx 5 -pady 2
|
||||
pack $d.sockport.text -side left -padx 1 -pady 2
|
||||
pack $d.sockport.entry -side right -padx 5 -pady 2
|
||||
pack $d.sockport -side top -padx 5 -pady 2
|
||||
$d.sockhost.entry insert 0 $sockhost
|
||||
$d.sockport.entry insert 0 $sockport
|
||||
frame $d.buttons
|
||||
button $d.buttons.cancel -text "Cancel" -bg grey66 \
|
||||
-command { set commtype "stdout"
|
||||
set outID "stdout"
|
||||
destroy $d }
|
||||
button $d.buttons.connect -text "Connect" -bg grey66 \
|
||||
-command {
|
||||
set sockhost [$d.sockhost.entry get]
|
||||
set sockport [$d.sockport.entry get]
|
||||
set err [catch {socket $sockhost $sockport} outID]
|
||||
# Callback on the <Configure> event for a toplevel
|
||||
# that should be centered on the screen
|
||||
|
||||
if {$err == 0} {
|
||||
destroy $d
|
||||
} else {
|
||||
tk_dialog $d.error "Socket Error" {Error: Unable to make socket connection. Make sure the STK socket server is first running and that the port number is correct.} "" 0 OK
|
||||
} }
|
||||
pack $d.buttons.cancel -side left -padx 5 -pady 10
|
||||
pack $d.buttons.connect -side right -padx 5 -pady 10
|
||||
pack $d.buttons -side bottom -padx 5 -pady 10
|
||||
}
|
||||
}
|
||||
# Make sure that we aren't configuring a child window
|
||||
if { [string equal $w [winfo toplevel $w]] } {
|
||||
|
||||
# Calculate the desired geometry
|
||||
set width [winfo reqwidth $w]
|
||||
set height [winfo reqheight $w]
|
||||
set x [expr { ( [winfo vrootwidth $w] - $width ) / 2 }]
|
||||
set y [expr { ( [winfo vrootheight $w] - $height ) / 2 }]
|
||||
#set y 0
|
||||
|
||||
# Hand the geometry off to the window manager
|
||||
wm geometry $w ${width}x${height}+${x}+${y}
|
||||
|
||||
# Unbind <Configure> so that this procedure is
|
||||
# not called again when the window manager finishes
|
||||
# centering the window. Also, revert geometry management
|
||||
# to internal default for subsequent size changes.
|
||||
bind $w <Configure> {}
|
||||
wm geometry $w ""
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user