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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
|
# 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
|