I really like the resampling function, I tried that before but failed on downsampling, although I havn't tested yours yet.
It looks like you're using linear interpolation, cubic or Hermite interpolation should increase the quality.
(http://astronomy.swin.edu.au/~pbourk...ion/index.html)
I've also heard you should do low pass filtering to remove frequencies above the new Nyquist frequency when downsampling, but never dealed with it.
Anyway, I've just ported a Goertzel algorithm (Fourier transformation, but only for 1 frequency)
for tone detection to VB,
maybe you can use it for your tone detection topic:
Usage: (returns dB of 8000 Hz in the signal at 44100 samples/s)Code:Function Goertzel( _ sngData() As Single, _ ByVal N As Long, _ ByVal freq As Single, _ ByVal sampr As Long _ ) As Single Dim Skn As Single Dim Skn1 As Single Dim Skn2 As Single Dim c As Single Dim c2 As Single Dim i As Long c = 2 * PI * freq / sampr c2 = Cos(c) For i = 0 To N - 1 Skn2 = Skn1 Skn1 = Skn Skn = 2 * c2 * Skn1 - Skn2 + sngData(i) Next Goertzel = Skn - Exp(-c) * Skn1 End Function Function power(ByVal value As Single) As Single power = 20 * Log(Abs(value)) / Log(10) End Function
I also did some testing with DTMF tone detection,Code:dB = power(Goertzel(sngSignal, UBound(sngSignal) + 1, 8000, 44100))
it can detect a generated tone in 0.01 seconds in the IDE
(compiled with optimizations 0.001 s), which is pretty fast on a P3 550 Mhz, I think.




Reply With Quote