1#!/bin/sh
2# the next line restarts using wish \
3exec wish8.3 "$0" "$@"
4
5package require -exact snack 2.2
6
7snack::sound s
8
9set f0 [snack::filter map 0.5]
10set f1 [snack::filter echo 0.6 0.6 30 0.4]
11set f2 [snack::filter echo 0.6 0.6 50 0.3]
12set f3 [snack::filter compose $f0 $f1 $f2]
13
14pack [frame .f]
15pack [frame .f.f1 -borderwidth 2 -relief raised]
16pack [frame .f.f2 -borderwidth 2 -relief raised]
17pack [frame .f.f3 -borderwidth 2 -relief raised]
18
19set m1 1.0
20pack [label .f.f1.l -text "Map Filter"]
21pack [scale .f.f1.s0 -label Map -from 1.0 -to 0.0 -resolution .01 \
22	-variable m1 -command "$f0 configure"]
23
24set v(inGain1) 0.6
25pack [label .f.f2.l -text "Echo Filter 1"]
26pack [scale .f.f2.s1 -label InGain -from 1.0 -to 0.0 -resolution .01 \
27	-variable v(inGain1) -command Config1] -side left
28
29set v(outGain1) 0.6
30pack [scale .f.f2.s2 -label OutGain -from 1.0 -to 0.0 -resolution .01 \
31	-variable v(outGain1) -command Config1] -side left
32
33set v(delay1) 30.0
34pack [scale .f.f2.s3 -label Delay -from 250.0 -to 10.0 -variable v(delay1) \
35	-command Config1] -side left
36
37set v(decay1) 0.4
38pack [scale .f.f2.s4 -label Decay -from 1.0 -to 0.0 -resolution .01 \
39	-variable v(decay1) -command Config1] -side left
40
41set v(inGain2) 0.7
42pack [label .f.f3.l -text "Echo Filter 2"]
43pack [scale .f.f3.s1 -label InGain -from 1.0 -to 0.0 -resolution .01 \
44	-variable v(inGain2) -command Config2] -side left
45
46set v(outGain2) 0.5
47pack [scale .f.f3.s2 -label OutGain -from 1.0 -to 0.0 -resolution .01 \
48	-variable v(outGain2) -command Config2] -side left
49
50set v(delay2) 50.0
51pack [scale .f.f3.s5 -label Delay -from 250.0 -to 10.0 -variable v(delay2) \
52	-command Config2] -side left
53
54set v(decay2) 0.3
55pack [scale .f.f3.s6 -label Decay -from 1.0 -to 0.0 -resolution .01 \
56	-variable v(decay2) -command Config2] -side left
57
58snack::createIcons
59pack [frame .fb]
60pack [button .fb.a -image snackOpen -command Load] -side left
61pack [button .fb.b -bitmap snackPlay -command Play] -side left
62pack [button .fb.c -bitmap snackStop -command "s stop"] -side left
63
64proc Config1 {args} {
65    global f1 v
66    $f1 configure $v(inGain1) $v(outGain1) $v(delay1) $v(decay1)
67}
68
69proc Config2 {args} {
70    global f2 v
71    $f2 configure $v(inGain2) $v(outGain2) $v(delay2) $v(decay2)
72}
73
74proc Play {} {
75    global f3
76    s play -filter $f3
77}
78
79proc Load {} {
80 set file [snack::getOpenFile -initialdir [file dirname [s cget -file]]]
81 if {$file == ""} return
82 s config -file $file
83}
84