Re: Sugestions or Comments about my Sound Tutorial
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:
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
Usage: (returns dB of 8000 Hz in the signal at 44100 samples/s)
Code:
dB = power(Goertzel(sngSignal, UBound(sngSignal) + 1, 8000, 44100))
I also did some testing with DTMF tone detection,
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.
Re: Sugestions or Comments about my Sound Tutorial
Originally Posted by rm_03
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.
Thanks for the link.
I implemented the Cubic and Hermite interpolation from the link you gave me, but I don't see significant diferences between linear and the other 2.
Hermite looks best compared to the original.
I will make another test program that will convert wave files and save them into new ones, so that I can hear the diference.
I attached a test project, please take a look at it, and tell me what you think ?
I did not have time to take a look at the rest of the code you gave me. I'm very busy lately.
Re: Sugestions or Comments about my Sound Tutorial
I have no clue what i'm seeing in that gif...
X is frequency, Y is dB at that freq.
The blue line is perfect interpolation, how it should look like.
The green line is "no interpolation", and turns into a lot of audible distortion.
The pink line is linear interpolation, which already has a better quality.
The black line is cubic interpolation, and has the lowest distortion.
A perfect interpolation would be using sinc functions, I heard.
Re: Sugestions or Comments about my Sound Tutorial
Originally Posted by rm_03
Usage: (returns dB of 8000 Hz in the signal at 44100 samples/s)
Code:
dB = power(Goertzel(sngSignal, UBound(sngSignal) + 1, 8000, 44100))
I also did some testing with DTMF tone detection,
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.
I finally had time to try it.
I'm speechless, very nice !
It's soo precise !
I tried with a dual tone with frequencies (tones from the phone): 770 Hz and 1209 Hz (wich coresponds to #4 on the phone)
I made a short program that tests with all the frequencies from the phone, and I got this:
First number is the frequency and in brackets is the dB
Test1:
350(075.87) 440(060.86) 480(046.48) 620(076.66) 697(077.03) 770(171.13) 852(068.98) 941(042.27) 1209(171.14) 1336(067.06) 1477(062.78)
Test2:
350(075.87) 440(060.86) 480(046.48) 620(076.66) 697(077.03) 771(111.53) 852(068.98) 941(042.27) 1209(171.14) 1336(067.06) 1477(062.78)
If you notice In the first test for the frequency 770 the volume is 171, and for frequency 1209 is the same.
The second test, I changed it to test for 771 Hz instead of 770 Hz, and the result is 111 dB
The diference in frequency is only 1 Hz, but a very big diference in dB (wich is very good)
Pretty fast too...
Though I made the test with digitaly created wave files (wich have perfect quality), not actual tone from the phone. I want to test for that too, but I don't have time right now.