home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 May / PCWorld_2002-05_cd.bin / Software / TemaCD / activetcltk / ActiveTcl8.3.4.1-8.win32-ix86.exe / ActiveTcl8.3.4.1-win32-ix86 / demos / Snack / fourChan.tcl < prev    next >
Encoding:
Text File  |  2001-10-22  |  2.3 KB  |  57 lines

  1. #!/bin/sh
  2. # the next line restarts using wish \
  3. exec wish8.3 "$0" "$@"
  4.  
  5. package require -exact snack 2.1
  6.  
  7. # Create a four channel sound with some computed waveform data
  8.  
  9. sound s -channels 4 -rate 8000
  10. s length 16000
  11. set p 16
  12. set n 0
  13. for {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.  
  34. set f1 [snack::filter map 1 0 0 0 1 0 0 0]
  35. set f2 [snack::filter map 0 1 0 0 0 1 0 0]
  36. set f3 [snack::filter map 0 0 1 0 0 0 1 0]
  37. set f4 [snack::filter map 0 0 0 1 0 0 0 1]
  38. set f5 [snack::filter map 0 0 1 0 0 1 0 0]
  39. set f6 [snack::filter map 0 1 0 0 0 0 1 0]
  40.  
  41. pack [frame .a] -side left
  42. pack [label .a.l -text "Sound channels 1-4"]
  43. pack [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
  48. pack [frame .f] -side left
  49. pack [label .f.l -text "Play channels:"]
  50. pack [button .f.a1 -text "Default 1,2"  -wi 12 -command "s play"]
  51. pack [button .f.a2 -text "Channel 1"    -wi 12 -command "s play -filter $f1"]
  52. pack [button .f.a3 -text "Channel 2"    -wi 12 -command "s play -filter $f2"]
  53. pack [button .f.a4 -text "Channel 3"    -wi 12 -command "s play -filter $f3"]
  54. pack [button .f.a5 -text "Channel 4"    -wi 12 -command "s play -filter $f4"]
  55. pack [button .f.a6 -text "Channels 3,2" -wi 12 -command "s play -filter $f5"]
  56. pack [button .f.a7 -text "Channels 2,3" -wi 12 -command "s play -filter $f6"]
  57.