DTMF detection using Goertzel Algorithm

2019-09-07 08:55发布

问题:

How can I use Goertzel Algorithm if the wave format are the following: - 2 Channels - 32 bit - 48 kHz

I already searched about Goertzel algorithm but all I can see all over the internet is detection of DTMF with wave format of 2 Channels, 16 bit, and 8 kHz. I don't know what part of code should I modify to meet my requirements.

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:

A good description of the Goertzel algorithm (there are many on the web) should include parameterization for sample rate, filter frequency, and duration. Just leave the filter frequency and duration the same and change the sample rate parameter of the filter.