File: dbpower.test

package info (click to toggle)
snack 2.2.9.dfsg-1.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,060 kB
  • ctags: 3,536
  • sloc: ansic: 35,290; sh: 8,950; tcl: 1,037; python: 701; makefile: 467
file content (107 lines) | stat: -rw-r--r-- 3,650 bytes parent folder | download | duplicates (11)
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
# Commands covered: sound dBPowerSpectrum
#

package require -exact snack 2.2

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest
    namespace import ::tcltest::*
}

test dbpower-1.1 {dBPowerSpectrum command} {
  set s [snack::sound snd -load ex1.wav]
  set tcl_precision 5
  set res [$s dBPowerSpectrum -start 0 -fftlength 32 -windowlength 32 \
	-channel 0 -preemphasisfactor 0.97]
  $s destroy
  set res
} {-76.131 -82.843 -107.69 -102.82 -101.37 -102.09 -95.375 -95.568 -95.339 -98.854 -101.56 -98.987 -126.39 -106.92 -107.49 -105.77}

test dbpower-1.2 {dBPowerSpectrum command, -end option} {
  set s [snack::sound snd -load ex1.wav]
  set tcl_precision 5
  set res [$s dBPowerSpectrum -start 1000 -end 2000 -fftlength 32 \
	-windowlength 32]
  $s destroy
  set res
} {-44.938 -51.981 -83.818 -91.582 -95.218 -97.588 -97.686 -99.849 -99.143 -100.16 -102.67 -102.81 -102.91 -104.24 -104.26 -107.86}

test dbpower-1.3 {dBPowerSpectrum command, -end and -skip options} {
  set s [snack::sound snd -load ex1.wav]
  set tcl_precision 5
  set res [$s dBPowerSpectrum -start 1000 -end 2000 -skip 10 -fftlength 32 \
	-windowlength 32]
  $s destroy
  set res
} {-44.939 -51.993 -84.497 -91.109 -94.957 -97.564 -98.45 -99.985 -99.593 -99.321 -102.01 -103.28 -104.12 -105.15 -104.44 -106.91}

test dbpower-1.4 {dBPowerSpectrum command, -channel -1} {
  set s [snack::sound snd -load ex1.wav]
  set tcl_precision 5
  set res [$s dBPowerSpectrum -start 0 -end 1 -fftlength 32 -windowlength 32 \
	 -channel -1]
  $s destroy
  set res
} {-46.206 -53.295 -86.135 -95.745 -95.521 -98.841 -98.824 -96.341 -98.931 -102.45 -104.78 -104.59 -116.6 -110.38 -115.77 -109.94}

test dbpower-2.1 {dBPowerSpectrum command, bad -fftlength option} {
  set s [snack::sound snd -load ex1.wav]
  catch {$s dBPowerSpectrum -fftlength 33} msg
  $s destroy
  set msg
} {-fftlength must be one of { 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 }}

test dbpower-2.2 {dBPowerSpectrum command, bad -windowlength option} {
  set s [snack::sound snd -load ex1.wav]
  catch {$s dBPowerSpectrum -windowlength 0} msg
  $s destroy
  set msg
} {-winlength must be > 0}

test dbpower-2.3 {dBPowerSpectrum command, bad -start option} {
  set s [snack::sound snd -load ex1.wav]
  catch {$s dBPowerSpectrum -start -1} msg
  $s destroy
  set msg
} {FFT window out of bounds}

test dbpower-2.4 {dBPowerSpectrum command, bad -start option} {
  set s [snack::sound snd -load ex1.wav]
  catch {$s dBPowerSpectrum -start 100000} msg
  $s destroy
  set msg
} {FFT window out of bounds}

test dbpower-2.5 {dBPowerSpectrum command, bad -end option} {
  set s [snack::sound snd -load ex1.wav]
  catch {$s dBPowerSpectrum -end 100000} msg
  $s destroy
  set msg
} {FFT window out of bounds}

test dbpower-3.1 {dBPowerSpectrum command, -windowtype option} {
  set s [snack::sound snd -load ex1.wav]
  set tcl_precision 5
  set res [$s dBPowerSpectrum -start 1000 -end 2000 -skip 10 -fftlength 32 \
	-windowlength 32 -windowtype hanning]
  $s destroy
  set res
} {-45.649 -51.27 -83.822 -90.784 -94.893 -97.554 -98.568 -100.2 -99.748 -99.653 -102.17 -103.53 -104.44 -105.31 -104.91 -107.19}

test dbpower-4.1 {dBPowerSpectrum command, bad -end option} {
  set s [snack::sound snd -load ex1.wav]
  catch {$s dBPowerSpectrum -end 100000} msg
  $s destroy
  set msg
} {FFT window out of bounds}

test dbpower-5.1 {dBPowerSpectrum command, with missing value for -start option} {
  set s [snack::sound snd -load ex1.wav]
  catch {$s dBPowerSpectrum -start} msg
  $s destroy
  set msg
} {No argument given for -start option}

# cleanup
::tcltest::cleanupTests
return