# Commands covered: sound sample # package require -exact snack 2.2 if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest namespace import ::tcltest::* } test sample-1.1 {sample command, get} { set s [snack::sound snd] $s length 10 set res [$s sample 0] $s destroy set res } 0 test sample-1.2 {sample command, set/get} { set s [snack::sound snd] $s length 10 $s sample 9 17 set res [$s sample 9] $s destroy set res } 17 test sample-1.3 {sample command, index out of bounds} { set s [snack::sound snd] $s length 10 catch {$s sample 10 17} msg $s destroy set msg } {Index out of bounds} test sample-1.4 {sample command, too many samples given} { set s [snack::sound snd] $s length 10 catch {$s sample 9 17 18} msg $s destroy set msg } {Too many samples given} test sample-2.1 {sample command, stereo get} { set s [snack::sound snd -channels 2] $s length 10 set res [$s sample 9] $s destroy set res } {0 0} test sample-2.2 {sample command, stereo get/set left channel} { set s [snack::sound snd -channels 2] $s length 10 $s sample 9 17 set res [$s sample 9] $s destroy set res } {17 0} test sample-2.3 {sample command, stereo get/set left channel using ?} { set s [snack::sound snd -channels 2] $s length 10 $s sample 9 17 ? set res [$s sample 9] $s destroy set res } {17 0} test sample-2.4 {sample command, stereo get/set right channel} { set s [snack::sound snd -channels 2] $s length 10 $s sample 9 ? 18 set res [$s sample 9] $s destroy set res } {0 18} test sample-2.5 {sample command, stereo get/set both channels} { set s [snack::sound snd -channels 2] $s length 10 $s sample 9 17 18 set res [$s sample 9] $s destroy set res } {17 18} test sample-3.1 {sample command, get from loaded ex1.wav} { set s [snack::sound snd -load ex1.wav] set res [$s sample 0] $s destroy set res } {1177} test sample-3.2 {sample command, get from linked ex1.wav} { set s [snack::sound snd -file ex1.wav] set res [$s sample 0] $s destroy set res } {1177} test sample-4.1 {sample command, wrong # args} { set s [snack::sound snd] catch {$s sample} msg $s destroy set msg } {wrong # args: should be "snd sample index ?val? ..."} test sample-5.1 {sample command, float sample set/get} { set s [snack::sound snd -encoding float] $s length 10 $s sample 9 32767.0 set res [$s sample 9] $s destroy set res } 32767.000000 test sample-5.2 {sample command, float sample set/get} { set s [snack::sound snd -encoding float -precision double] $s length 10 $s sample 9 32767.0 set res [$s sample 9] $s destroy set res } 32767.000000000000 test sample-6.1 {sample command, 3-channel get} { set s [snack::sound snd -channels 3] $s length 10 set res [$s sample 9] $s destroy set res } {0 0 0} test sample-6.2 {sample command, 3-channel get/set channel 0} { set s [snack::sound snd -channels 3] $s length 10 $s sample 9 17 set res [$s sample 9] $s destroy set res } {17 0 0} test sample-6.3 {sample command, 3-channel get/set channel 0 using ?} { set s [snack::sound snd -channels 3] $s length 10 $s sample 9 17 ? ? set res [$s sample 9] $s destroy set res } {17 0 0} test sample-6.4 {sample command, 3-channel get/set channel 1} { set s [snack::sound snd -channels 3] $s length 10 $s sample 9 ? 18 ? set res [$s sample 9] $s destroy set res } {0 18 0} test sample-6.5 {sample command, 3-channel get/set channel 2} { set s [snack::sound snd -channels 3] $s length 10 $s sample 9 ? ? 19 set res [$s sample 9] $s destroy set res } {0 0 19} test sample-6.6 {sample command, 3-channel get/set all channels} { set s [snack::sound snd -channels 3] $s length 10 $s sample 9 17 18 19 set res [$s sample 9] $s destroy set res } {17 18 19} test sample-7.1 {sample command, set/get with configure channels} { set s [snack::sound snd -channels 1] $s length 100 $s sample 15 17 $s sample 16 18 $s sample 17 19 $s configure -channels 3 set res [$s sample 5] $s destroy set res } {17 18 19} test sample-7.2 {sample command, set/get with configure channels} { set s [snack::sound snd -channels 3] $s length 100 $s sample 15 17 18 19 $s configure -channels 5 set res [$s sample 9] $s destroy set res } {17 18 19 0 0} test sample-8.1 {sample command, lin24 sample set/get} { set s [snack::sound snd -encoding lin24] $s length 10 $s sample 9 32768 $s sample 8 -8388608 $s sample 7 8388607 set res [$s sample 9],[$s sample 8],[$s sample 7] $s destroy set res } 32768,-8388608,8388607 # cleanup ::tcltest::cleanupTests return