Tone detection with Goertzel (x86 ASM)

Type : Tone detection with Goertzel in x86 assembly
References : Posted by Christian[AT]savioursofsoul[DOT]de
Notes :
This is an "assemblified" version of the Goertzel Tone Detector. It is about 2 times faster than the original code.

The code has been tested and it works fine.

Hope you can use it. I'm gonna try to build a Tuner (as VST-Plugin). I hope, that this will work :-\ If anyone is intrested, please let me know.

Christian
Code :
function Goertzel_x87(Buffer :Psingle; BLength:Integer; frequency: Single; samplerate: Single):Single;
asm
mov ecx,BLength
mov eax,Buffer
fld x2
fldpi
fmulp
fmul frequency
fdiv samplerate
fld st(0)
fcos
fld x2
fmulp
fxch st(1)
fldz
fsub st(0),st(1)
fstp st(1)

fldl2e
fmul
fld st(0)
frndint
fsub st(1),st(0)
fxch st(1)
f2xm1
fld1
fadd
fscale
fstp st(1)

fldz
fldz
fldz
@loopStart:
fxch st(1)
fxch st(2)
fstp st(0)
fld st(3)
fmul st(0),st(1)
fsub st(0),st(2)
fld [eax].Single
faddp
add eax,4
loop @loopStart
@loopEnd:

fxch st(3)
fmulp st(2), st(0)
fsub st(0),st(1)
fstp result
ffree st(2)
ffree st(1)
ffree st(0)
end;

Comments
from : thaddy[AT]thaddy[DOT]com
comment : Here's a variant on the theme that compensates for harmonics: [CODE] Function Goertzel(.Buffer: array of double; frequency, samplerate: double):.double; var Qkn, Qkn1, Qkn2, Wkn, Mk: double; i: integer; begin Qkn:=0; Qkn1:=0; Wkn:=2*.PI*.frequency/samplerate; Mk:=2*.Cos(.Wkn); for i:=0 to High(.Buffer) do begin Qkn2: = Qkn1; Qkn1: = Qkn; Qkn : = Buffer[.i ] + Mk*.Qkn1 - Qkn2; end; Result: = sqrt(.Qkn*.Qkn + Qkn1*.Qkn1 - Mk*.Qkn*.Qkn1); end; [/CODE] Posted on www.delphimaster.ru by Jeer

from : thaddy[AT]thaddy[DOT]com
comment : Here's what I ment ;) <code> function Goertzel(Buffer: array of double; frequency, samplerate: double):double; var Qkn, Qkn1, Qkn2, Wkn, Mk : double; i : integer; begin Qkn:=0; Qkn1:=0; Wkn:=2*PI*frequency/samplerate; Mk:=2*Cos(Wkn); for i:=0 to High(Buffer) do begin Qkn2 := Qkn1; Qkn1 := Qkn; Qkn := Buffer[i] + Mk*Qkn1 - Qkn2; end; Result := sqrt(Qkn*Qkn + Qkn1*Qkn1 - Mk*Qkn*Qkn1); end; </code>

from : jennifermartinez[AT]mail15[DOT]com
comment : Some time ago, I needed to buy a good house for my firm but I did not have enough cash and could not order anything. Thank God my colleague suggested to get the <a href="http://lowest-rate-loans.com/topics/personal-loans">personal loans</a> at trustworthy creditors. Hence, I did so and used to be happy with my sba loan.

from : suppaply[AT]gmail[DOT]com
comment : Yeah. I like very much the articles drafted in view of this. A friend of mine told me about your site, ever since my first visit, I have been attracted. Don't crumble your life in questions and despair, just order students <a href="http://www.bestwritingservice.com">term paper</a>. Keep the articles getting near!

from : pamelagonzales69[AT]googlemail[DOT]com
comment : People believe this resume service cause they are very trustworthy! The corporation makes <a href="http://www.prime-resume.com">resume service</a> to fit the precise field of research you expect.

from : luckyjay79[AT]gmail[DOT]com
comment : If you are willing to improve your knowledge referring to this good topic, search for <a href="http://www.primedissertations.com">thesis writing service</a> or <a href="http://www.primedissertations.com">dissertation service</a> and buy superb legal dissertation there.

from : ladyblacklisa[AT]gmail[DOT]com
comment : All should be in order with your academic career when some people notice the professional essay writing service to purchase <a href="http://www.primewritings.com">custom essays</a> at. Therefore that used to be executable to get <a href="http://www.primewritings.com">term papers</a>.

from : lindahernandez[AT]mail333[DOT]com
comment : I make the most of this site before and was impressed with the affectation and usefulness. I appreciate your house, it is a life saver. You can <a href="http://www.goldessays.com/">custom essay</a> and absolutely dependence on this firm for one hundred percent!