diff options
author | carmen rocco <ix9@users.sourceforge.net> | 2005-05-17 17:53:41 +0000 |
---|---|---|
committer | carmen rocco <ix9@users.sourceforge.net> | 2005-05-17 17:53:41 +0000 |
commit | 99748c970453721baa62a895c22f0b8d3b4796b7 (patch) | |
tree | 7072b903bafa0c29c8fb206848e524b61fc44683 /extensions | |
parent | 03e76d3e5c6b8dce7f8047251704f3a6be18af9e (diff) |
k2
svn path=/trunk/; revision=3004
Diffstat (limited to 'extensions')
-rwxr-xr-x | extensions/gui/ix/kbd-demo.pd | 63 | ||||
-rwxr-xr-x | extensions/gui/ix/kbd2.wid | 36 |
2 files changed, 60 insertions, 39 deletions
diff --git a/extensions/gui/ix/kbd-demo.pd b/extensions/gui/ix/kbd-demo.pd index 205ca782..896c3aa5 100755 --- a/extensions/gui/ix/kbd-demo.pd +++ b/extensions/gui/ix/kbd-demo.pd @@ -1,9 +1,6 @@ #N canvas 360 12 554 299 12; -#X obj 56 57 widget kbd k1 #octaves 7 -width 472.441 -height 67.4916 +#X obj 56 57 widget kbd k1 #octaves 7 -width 444.094 -height 63.4421 ; -#X obj 343 246 tow . kbd k1; -#X msg 302 223 -width \$1; -#X msg 365 223 -height \$1; #X obj 56 134 unpack; #X floatatom 56 155 5 0 0 0 - - -; #X floatatom 90 155 5 0 0 0 - - -; @@ -21,42 +18,30 @@ #X obj 81 242 *~; #X obj 92 173 * 0.4; #X floatatom 115 14 5 0 1 0 - - -; -#X obj 305 172 hsl 128 15 0 600 0 0 empty empty empty -2 -6 0 8 -262144 --1 -1 10000 1; -#X floatatom 335 187 5 0 0 0 - - -; #X floatatom 149 21 5 0 12 0 - - -; #X msg 148 38 #octaves \$1; -#X obj 56 174 + 24; -#X obj 367 202 / 7; -#X floatatom 441 180 5 5 9 0 - - -; -#X obj 397 195 t b f; +#X obj 165 140 widget kbd2 k2 #octaves 3 #bg purple #fg pink -height +32; +#X obj 56 174 + 36; +#X connect 0 0 1 0; #X connect 0 0 4 0; -#X connect 0 0 7 0; -#X connect 2 0 1 0; -#X connect 3 0 1 0; -#X connect 4 0 5 0; -#X connect 4 1 6 0; -#X connect 5 0 24 0; -#X connect 6 0 18 0; +#X connect 1 0 2 0; +#X connect 1 1 3 0; +#X connect 2 0 20 0; +#X connect 3 0 15 0; +#X connect 5 0 0 0; +#X connect 6 0 5 0; +#X connect 7 0 5 1; #X connect 8 0 0 0; -#X connect 9 0 8 0; -#X connect 10 0 8 1; -#X connect 11 0 0 0; -#X connect 12 0 17 0; -#X connect 13 0 12 0; -#X connect 14 0 17 1; -#X connect 15 0 14 0; -#X connect 17 0 16 0; -#X connect 17 0 16 1; -#X connect 18 0 15 0; -#X connect 19 0 8 1; -#X connect 20 0 21 0; -#X connect 21 0 2 0; -#X connect 21 0 25 0; -#X connect 22 0 23 0; -#X connect 23 0 0 0; -#X connect 24 0 13 0; -#X connect 25 0 3 0; -#X connect 26 0 27 0; -#X connect 27 0 21 0; -#X connect 27 1 25 1; +#X connect 9 0 14 0; +#X connect 10 0 9 0; +#X connect 11 0 14 1; +#X connect 12 0 11 0; +#X connect 14 0 13 0; +#X connect 14 0 13 1; +#X connect 15 0 12 0; +#X connect 16 0 5 1; +#X connect 17 0 18 0; +#X connect 18 0 0 0; +#X connect 19 0 1 0; +#X connect 20 0 10 0; diff --git a/extensions/gui/ix/kbd2.wid b/extensions/gui/ix/kbd2.wid new file mode 100755 index 00000000..59d22ec8 --- /dev/null +++ b/extensions/gui/ix/kbd2.wid @@ -0,0 +1,36 @@ +namespace eval ::ix {
+ proc kbd2_play {b x y} {
+ array set rs {0 sunken 1 raised} ; array set sr {0 $rs(1) 1 $rs(0)}
+ array set v {0 0 1 {($y - [winfo rooty $w]) / ([winfo height $w] + 0.0)}}
+ set w [winfo containing $x $y]
+ if {[$w cget -relief] eq $rs($b)} {
+ eval $w config -relief $sr($b)
+ pd "[winfo name [winfo parent [winfo parent $w]]].rp _cb [winfo name $w] [eval expr $v($b)] \;"}}
+
+ proc kbd2 {path target octaves b f} {
+ if {![winfo exists $path.f0]} {
+ $path config -width [expr $octaves * 66]
+ set bw {0 1 0 1 0 0 1 0 1 0 1 0} ; set npl {0 1 1 2 2 3 4 4 5 5 6 6}
+ array set bg "0 $b 1 $f"
+ array set fg {1 $bg(0) 0 $bg(1)}
+ array set rw {0 {[expr 1 / 7.]} 1 {[expr 1 / 10.]}}
+ array set rh {0 {[expr 1.]} 1 {[expr 6 / 10.]}}
+ array set an {0 ";lower $wk" 1 "-anchor n"}
+ for {set o 0} {$o < $octaves} {incr o} {
+ set w $path.f$o
+ frame $w -bd 0 -height 66 -width 66
+ for {set on 0} {$on < 12} {incr on} {
+ set wk $w.[expr $o * 12 + $on]
+ set n [lindex $bw $on]
+ eval label $wk -bg $bg($n) -fg $fg($n) -bd 1 -relief raised
+ eval place $wk -relx [expr [lindex $npl $on] / 7.] -y 0 -relwidth $rw($n) -relheight $rh($n) $an($n)
+ bind $wk <1> {::ix::kbd2_play 1 %X %Y}; bind $wk <B1-Motion> [bind $wk <1>]
+ bind $wk <ButtonRelease-1> {::ix::kbd2_play 0 %X %Y}; bind $wk <Leave> [bind $wk <ButtonRelease-1>]}
+ place $w -y 0 -relheight 1.0 -relx [expr $o / $octaves.0] -relwidth [expr 1 / $octaves.0]}}}}
+
+#> kbd2 frame
+#. -height 100 -width 60
+#. #octaves 6 #bg black #fg white
+
+#@ new
+::ix::kbd2 .- .| .#octaves .#bg .#fg
|