1#!/bin/sh
2# the next line restarts using wish \
3exec wish8.4 "$0" "$@"
4
5# A cross-platform mixer application that adapts to the capabilities
6# of Snack on the machine it is run on.
7# Lots of functionality on Linux - play volume only on Windows, currently.
8
9package require -exact snack 2.2
10
11proc Update {} {
12  snack::mixer update
13  if $::doMonitor { after 100 Update }
14}
15bind . <Configure> Update
16wm protocol . WM_DELETE_WINDOW exit
17
18pack [frame .f] -expand yes -fill both
19pack [checkbutton .r -text Monitor -command Update -variable doMonitor]
20
21foreach line [snack::mixer lines] {
22  pack [frame .f.g$line -bd 1 -relief solid] -side left -expand yes -fill both
23  pack [label .f.g$line.l -text $line]
24  if {[snack::mixer channels $line] == "Mono"} {
25    snack::mixer volume $line v(r$line)
26  } else {
27    snack::mixer volume $line v(l$line) v(r$line)
28    pack [scale .f.g$line.e -from 100 -to 0 -show no -var v(l$line)] -side \
29	    left -expand yes -fill both
30  }
31  pack [scale .f.g$line.s -from 100 -to 0 -show no -var v(r$line)] -expand yes\
32	  -fill both
33}
34
35pack [frame .f.f2] -side left
36
37if {[llength [snack::mixer inputs]] > 0} {
38  pack [label .f.f2.li -text "Input jacks:"]
39  foreach jack [snack::mixer inputs] {
40    snack::mixer input $jack v(i$jack)
41    pack [checkbutton .f.f2.b$jack -text $jack -variable v(i$jack)] -anc w
42  }
43}
44if {[llength [snack::mixer outputs]] > 0} {
45  pack [label .f.f2.lo -text "Output jacks:"]
46  foreach jack [snack::mixer outputs] {
47    snack::mixer output $jack v(o$jack)
48    pack [checkbutton .f.f2.b$jack -text $jack -variable v(o$jack)] -anc w
49  }
50}
51