--- gforth/fft.fs 2005/09/27 13:50:43 1.1 +++ gforth/fft.fs 2007/10/17 15:50:01 1.4 @@ -1,3 +1,23 @@ +\ fast fourier transform + +\ Copyright (C) 2005 Free Software Foundation, Inc. + +\ This file is part of Gforth. + +\ Gforth is free software; you can redistribute it and/or +\ modify it under the terms of the GNU General Public License +\ as published by the Free Software Foundation; either version 2 +\ of the License, or (at your option) any later version. + +\ This program is distributed in the hope that it will be useful, +\ but WITHOUT ANY WARRANTY; without even the implied warranty of +\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +\ GNU General Public License for more details. + +\ You should have received a copy of the GNU General Public License +\ along with this program; if not, write to the Free Software +\ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + \ *** Fast Fourier Transformation *** 15may93py require complex.fs @@ -50,9 +70,13 @@ Carray expix BEGIN 2dup > WHILE dup 2* swap fft-step REPEAT 2drop drop ; -: normalize ( -- ) #points dup s>f 1/f - 0 DO I values dup z@ 2 fpick zscale z! LOOP fdrop ; +: fftscale ( r -- ) + #points 0 DO I values dup z@ 2 fpick zscale z! LOOP fdrop ; +: normalize ( -- ) #points s>f 1/f fftscale ; : fft ( -- ) #points true (fft ; : rfft ( -- ) #points false (fft ; +: hamming ( -- ) #points 0 DO + I values dup z@ pi I #points fm*/ fsin f**2 f2* zscale z! + LOOP ; \ No newline at end of file