-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgoertzel_test.go
53 lines (43 loc) · 1.22 KB
/
goertzel_test.go
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
package goertzel
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestOptimalBlockSize(t *testing.T) {
f := 1400.0
r := RateTelephony
min := (50 * time.Second) / 1000
n := optimalBlockSize(f, r, min)
assert.Equal(t, 400, n, "optimum block size should match reference")
f = 1400.0
r = RateTelephony
min = (50 * time.Second) / 1000
n = optimalBlockSize2(f, r, min)
assert.Equal(t, 160, n, "optimum block size should match reference")
f = 2300.0
r = RateTelephony
min = (50 * time.Second) / 1000
n = optimalBlockSize(f, r, min)
assert.Equal(t, 400, n, "optimum block size should match reference")
}
/*
func TestOptimalBlockSizeMultiFreq(t *testing.T) {
o := &Options{
Rate: RateTelephony,
Frequencies: []float64{1400, 2300},
MinDuration: 50,
}
n := optimalBlockSizeMultiFreq(o)
// 400 is the best N; 320 is next; base common multiple is 80
assert.Equal(t, n, 400, "optimum block size should match reference")
o = &Options{
Rate: RateTelephony,
Frequencies: []float64{697, 770, 852, 941, 1209, 1336, 1477, 1633},
MinDuration: 250,
}
n = optimalBlockSizeMultiFreq(o)
// No common multiple; use maxN
assert.Equal(t, n, 2000, "optimum block size should match reference")
}
*/