如果波形格式如下,我如何使用 Goertzel 算法: - 2 通道 - 32 位 - 48 kHz
我已经搜索过 Goertzel 算法,但我在互联网上看到的只是检测 DTMF 的波形格式为 2 通道、16 位和 8 kHz。我不知道我应该修改代码的哪一部分以满足我的要求。
Private Function Goertzel(ByVal sample As Byte(), ByVal N As Long, _
ByVal freq As Double, ByVal sampr As Long) As Double
Dim Skn As Double = 0
Dim Skn1 As Double = 0
Dim Skn2 As Double
Dim c As Double
Dim c2 As Double
Dim i As Integer
c = 2 * Math.PI * freq / sampr
c2 = Math.Cos(c)
For i = 0 To (N - 1)
Skn2 = Skn1
Skn1 = Skn
Skn = 2 * c2 * Skn1 - Skn2 + sample(i)
Next
Return Skn - Math.Exp(-c) * Skn1
End Function
Private Function power(ByVal val As Double) As Double
Return 20 * Math.Log(Math.Abs(val)) / Math.Log(10)
End Function