1#!/bin/sh 2# the next line restarts using wish \ 3exec wish8.3 "$0" "$@" 4 5package require -exact snack 2.2 6 7# Create a four channel sound with some computed waveform data 8 9sound s -channels 4 -rate 8000 10s length 16000 11set p 16 12set n 0 13for {set i 0} {$i < [expr int([s length] / $p -1)]} {incr i} { 14 s sample [incr n] 0 0 10000 10000 15 s sample [incr n] 3827 7071 10000 -10000 16 s sample [incr n] 7071 10000 10000 10000 17 s sample [incr n] 9239 7071 10000 -10000 18 s sample [incr n] 10000 0 10000 10000 19 s sample [incr n] 9239 -7071 10000 -10000 20 s sample [incr n] 7071 -10000 10000 10000 21 s sample [incr n] 3827 -7071 10000 -10000 22 s sample [incr n] 0 0 -10000 10000 23 s sample [incr n] -3827 7071 -10000 -10000 24 s sample [incr n] -7071 10000 -10000 10000 25 s sample [incr n] -9239 7071 -10000 -10000 26 s sample [incr n] -10000 0 -10000 10000 27 s sample [incr n] -9239 -7071 -10000 -10000 28 s sample [incr n] -7071 -10000 -10000 10000 29 s sample [incr n] -3827 -7071 -10000 -10000 30} 31 32# Filters for channel selection 33 34set f1 [snack::filter map 1 0 0 0 1 0 0 0] 35set f2 [snack::filter map 0 1 0 0 0 1 0 0] 36set f3 [snack::filter map 0 0 1 0 0 0 1 0] 37set f4 [snack::filter map 0 0 0 1 0 0 0 1] 38set f5 [snack::filter map 0 0 1 0 0 1 0 0] 39set f6 [snack::filter map 0 1 0 0 0 0 1 0] 40 41pack [frame .a] -side left 42pack [label .a.l -text "Sound channels 1-4"] 43pack [canvas .a.c -width 256 -height 200] 44.a.c create waveform 0 0 -sound s -channe 0 -end 128 -width 256 -height 50 45.a.c create waveform 0 50 -sound s -channe 1 -end 128 -width 256 -height 50 46.a.c create waveform 0 100 -sound s -channe 2 -end 128 -width 256 -height 50 47.a.c create waveform 0 150 -sound s -channe 3 -end 128 -width 256 -height 50 48pack [frame .f] -side left 49pack [label .f.l -text "Play channels:"] 50pack [button .f.a1 -text "Default 1,2" -wi 12 -command "s play"] 51pack [button .f.a2 -text "Channel 1" -wi 12 -command "s play -filter $f1"] 52pack [button .f.a3 -text "Channel 2" -wi 12 -command "s play -filter $f2"] 53pack [button .f.a4 -text "Channel 3" -wi 12 -command "s play -filter $f3"] 54pack [button .f.a5 -text "Channel 4" -wi 12 -command "s play -filter $f4"] 55pack [button .f.a6 -text "Channels 3,2" -wi 12 -command "s play -filter $f5"] 56pack [button .f.a7 -text "Channels 2,3" -wi 12 -command "s play -filter $f6"] 57