使用Goertzel算法进行DTMF检测

时间:2014-03-05 05:49:32

标签: c# .net signal-processing dtmf goertzel-algorithm

如果波形格式如下,我该如何使用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

1 个答案:

答案 0 :(得分:0)

Goertzel算法的良好描述(网上有many)应该包括采样率,过滤频率和持续时间的参数化。只需保持滤波器频率和持续时间相同,并更改滤波器的采样率参数。