1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
# Commands covered: sound convert
#
package require -exact snack 2.2
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
namespace import ::tcltest::*
}
test convert-1.1 {convert command, mono->stereo} {
set s [snack::sound snd -load ex1.wav]
$s convert -channels 2
set res [$s sample 0]
$s destroy
set res
} {1177 1177}
test convert-1.2 {convert command, Lin16->Mulaw} {
set s [snack::sound snd -load ex1.wav]
$s convert -encoding Mulaw
set res [$s sample 0]
$s destroy
set res
} {1180}
test convert-1.3 {convert command, 16kH->32kHz} {
set s [snack::sound snd -load ex1.wav]
$s convert -rate 32000
set res [$s sample 5000]
$s destroy
set res
} {1688}
test convert-2.1 {convert command, missing argument for -rate option} {
set s [snack::sound snd -load ex1.wav]
catch {$s convert -rate} msg
$s destroy
set msg
} {wrong # args: should be "snd convert option value"}
test convert-3.1 {convert command, -progress option} {
set res ""
proc prog {msg frac} {
lappend ::res $frac
}
set s [snack::sound snd]
$s length 100000
$s convert -encoding Mulaw -progress prog
$s destroy
set res
} {0.0 0.99999 1.0}
test convert-4.1 {convert command, testing internal allocation} {
set s1 [snack::sound snd1]
set s2 [snack::sound snd2]
$s1 length 50000
$s2 copy $s1
$s1 convert -rate 8000
$s1 copy $s2
set res [$s2 sample 5000]
$s1 destroy
$s2 destroy
set res
} {0}
test convert-5.1 {convert command, stereo->mono} {
set s [snack::sound snd -channels 2]
$s length 1
$s convert -channels 1
set res [$s sample 0]
$s destroy
set res
} {0}
# cleanup
::tcltest::cleanupTests
return
|