Home » Recent acquisitions » Acorn ADFS disks » adfs_ArchimedesWorld_199201.adf » January92 » !AWJan92/Goodies/ProgTheARM/FFT1

!AWJan92/Goodies/ProgTheARM/FFT1

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Recent acquisitions » Acorn ADFS disks » adfs_ArchimedesWorld_199201.adf » January92
Filename: !AWJan92/Goodies/ProgTheARM/FFT1
Read OK:
File size: 0779 bytes
Load address: 0000
Exec address: 0000
File contents
   10REM > FFT1
   20
   30MODE 12
   40
   50N%=64
   60
   70n2%=2*N%
   80
   90DIM data(n2%)
  100
  110REPEAT
  120
  121K=RND(20)
  130
  150CLS
  160PRINT"Frequency:"K
  170
  180GCOL7
  190
  200FOR I%=0TO N%-1
  210  ii%=2*I%+1
  220  data(ii%)   = SINRAD(I%*K)
  230  data(ii%+1) = 0
  251  RECTANGLE FILL 8*I%,512,7,256*data(ii%)
  260NEXT
  270
  280PROCfour1(N%,1)
  290
  300GCOL1
  310
  320FOR I%=0 TO (N%-1) DIV 2
  330  ii%=2*I%+1
  340  RECTANGLE FILL 16*I%,0,15,8*ABS(data(ii%))
  360NEXT
  370QQ=GET
  380CLS
  390UNTIL.
  400
  410END
  420
  430
  440REM data() accessed by refernece
  450DEFPROCfour1(nn%,isign%)
  460
  470LOCALii%,jj%,n%,mmax%,m%,j%,istep%,i%
  480LOCALwtemp,wr,wpr,wpi,wi,theta
  490LOCALtempr,tempi,wrs,wis
  500
  510LOCALs
  520
  530n%=2*nn%
  540j%=1
  550REM This is the bit-reversal section of the routine
  560FOR ii%=1 TO nn%
  570  i%=2*ii%-1
  580  IF j% > i% THEN
  590    REM Swap the real and imarinary parts of the two
  600    tempr      = data(j%) : tempi      = data(j%+1)
  610    data(j%)   = data(i%) : data(j%+1) = data(i%+1)
  620    data(i%)   = tempr    : data(i%+1) = tempi
  630  ENDIF
  640  m% = n% DIV 2
  650  WHILE (m%>=2) AND (j%>m%)
  660    j% = j% - m%
  670    m% = m% DIV 2
  680  ENDWHILE
  690  j% = j% + m%
  700NEXT
  710
  720mmax% = 2
  730
  740REM Now the Danielson-Lanczos recurrence
  750
  760WHILE n% > mmax%
  770  istep% = 2*mmax%
  780  theta  = 2 * PI / (isign%*mmax%)
  790
  800        s=SIN(0.5*theta)
  810  wpr    = -2.0 * s*s
  820  wpi    = SIN(theta)
  830
  840  wr = 1.0
  850  wi = 0.0
  860  FOR ii% = 1 TO mmax% DIV 2
  870    m% = 2*ii%-1
  880    wrs = wr
  890    wis = wi
  900    FOR jj%=0 TO (n%-m%) DIV istep%
  910      i% = m% + jj%*istep%
  920      j% = i%+mmax%
  930      tempr = wrs*data(j%)   - wis*data(j%+1)
  940      tempi = wrs*data(j%+1) + wis*data(j%)
  950      data(j%)   = data(i%)   - tempr
  960      data(j%+1) = data(i%+1) - tempi
  970      data(i%)   = data(i%)   + tempr
  980      data(i%+1) = data(i%+1) + tempi
  990    NEXT
 1000    wtemp = wr
 1010    wr = wr*wpr -    wi*wpi + wr
 1020    wi = wi*wpr + wtemp*wpi  +wi
 1030  NEXT
 1040  mmax% = istep%
 1050ENDWHILE
 1060ENDPROC
 1070
 1080
 1090
 1100
 1110
 1120
 1130
 1140
 1150
 1160
 1170
 1180
 1190
 1200
 1210
 1220

� > FFT1

� 12
(
2	N%=64
<
Fn2%=2*N%
P
Z� data(n2%)
d
n�
x
yK=�(20)
�
��
��"Frequency:"K
�
��7
�
�� I%=0� N%-1
�  ii%=2*I%+1
�  data(ii%)   = ��(I%*K)
�  data(ii%+1) = 0
�$  ȓ Ȑ 8*I%,512,7,256*data(ii%)
�

�four1(N%,1)
"
,�1
6
@� I%=0 � (N%-1) � 2
J  ii%=2*I%+1
T%  ȓ Ȑ 16*I%,0,15,8*�(data(ii%))
h�
rQQ=�
|�
��.
�
��
�
�
�"� data() accessed by refernece
���four1(nn%,isign%)
�
�%�ii%,jj%,n%,mmax%,m%,j%,istep%,i%
��wtemp,wr,wpr,wpi,wi,theta
��tempr,tempi,wrs,wis
�
��s

n%=2*nn%
j%=1
&5� This is the bit-reversal section of the routine
0� ii%=1 � nn%
:  i%=2*ii%-1
D  � j% > i% �
N6    � Swap the real and imarinary parts of the two
X7    tempr      = data(j%) : tempi      = data(j%+1)
b7    data(j%)   = data(i%) : data(j%+1) = data(i%+1)
l2    data(i%)   = tempr    : data(i%+1) = tempi
v  �
�  m% = n% � 2
�  ȕ (m%>=2) � (j%>m%)
�    j% = j% - m%
�    m% = m% � 2
�  �
�  j% = j% + m%
��
�
�
mmax% = 2
�
�*� Now the Danielson-Lanczos recurrence
�
�ȕ n% > mmax%
  istep% = 2*mmax%
%  theta  = 2 * � / (isign%*mmax%)

         s=�(0.5*theta)
*  wpr    = -2.0 * s*s
4  wpi    = �(theta)
>
H  wr = 1.0
R  wi = 0.0
\  � ii% = 1 � mmax% � 2
f    m% = 2*ii%-1
p    wrs = wr
z    wis = wi
�"    � jj%=0 � (n%-m%) � istep%
�      i% = m% + jj%*istep%
�      j% = i%+mmax%
�1      tempr = wrs*data(j%)   - wis*data(j%+1)
�/      tempi = wrs*data(j%+1) + wis*data(j%)
�)      data(j%)   = data(i%)   - tempr
�)      data(j%+1) = data(i%+1) - tempi
�)      data(i%)   = data(i%)   + tempr
�)      data(i%+1) = data(i%+1) + tempi
�	    �
�    wtemp = wr
�$    wr = wr*wpr -    wi*wpi + wr
�$    wi = wi*wpr + wtemp*wpi  +wi
  �
  mmax% = istep%
�
$�
.
8
B
L
V
`
j
t
~
�
�
�
�
�
�
�
�
00000000  0d 00 0a 0c f4 20 3e 20  46 46 54 31 0d 00 14 04  |..... > FFT1....|
00000010  0d 00 1e 08 eb 20 31 32  0d 00 28 04 0d 00 32 09  |..... 12..(...2.|
00000020  4e 25 3d 36 34 0d 00 3c  04 0d 00 46 0c 6e 32 25  |N%=64..<...F.n2%|
00000030  3d 32 2a 4e 25 0d 00 50  04 0d 00 5a 0f de 20 64  |=2*N%..P...Z.. d|
00000040  61 74 61 28 6e 32 25 29  0d 00 64 04 0d 00 6e 05  |ata(n2%)..d...n.|
00000050  f5 0d 00 78 04 0d 00 79  0b 4b 3d b3 28 32 30 29  |...x...y.K=.(20)|
00000060  0d 00 82 04 0d 00 96 05  db 0d 00 a0 12 f1 22 46  |.............."F|
00000070  72 65 71 75 65 6e 63 79  3a 22 4b 0d 00 aa 04 0d  |requency:"K.....|
00000080  00 b4 06 e6 37 0d 00 be  04 0d 00 c8 10 e3 20 49  |....7......... I|
00000090  25 3d 30 b8 20 4e 25 2d  31 0d 00 d2 10 20 20 69  |%=0. N%-1....  i|
000000a0  69 25 3d 32 2a 49 25 2b  31 0d 00 dc 1c 20 20 64  |i%=2*I%+1....  d|
000000b0  61 74 61 28 69 69 25 29  20 20 20 3d 20 b5 b2 28  |ata(ii%)   = ..(|
000000c0  49 25 2a 4b 29 0d 00 e6  15 20 20 64 61 74 61 28  |I%*K)....  data(|
000000d0  69 69 25 2b 31 29 20 3d  20 30 0d 00 fb 24 20 20  |ii%+1) = 0...$  |
000000e0  c8 93 20 c8 90 20 38 2a  49 25 2c 35 31 32 2c 37  |.. .. 8*I%,512,7|
000000f0  2c 32 35 36 2a 64 61 74  61 28 69 69 25 29 0d 01  |,256*data(ii%)..|
00000100  04 05 ed 0d 01 0e 04 0d  01 18 10 f2 66 6f 75 72  |............four|
00000110  31 28 4e 25 2c 31 29 0d  01 22 04 0d 01 2c 06 e6  |1(N%,1).."...,..|
00000120  31 0d 01 36 04 0d 01 40  17 e3 20 49 25 3d 30 20  |1..6...@.. I%=0 |
00000130  b8 20 28 4e 25 2d 31 29  20 81 20 32 0d 01 4a 10  |. (N%-1) . 2..J.|
00000140  20 20 69 69 25 3d 32 2a  49 25 2b 31 0d 01 54 25  |  ii%=2*I%+1..T%|
00000150  20 20 c8 93 20 c8 90 20  31 36 2a 49 25 2c 30 2c  |  .. .. 16*I%,0,|
00000160  31 35 2c 38 2a 94 28 64  61 74 61 28 69 69 25 29  |15,8*.(data(ii%)|
00000170  29 0d 01 68 05 ed 0d 01  72 08 51 51 3d a5 0d 01  |)..h....r.QQ=...|
00000180  7c 05 db 0d 01 86 06 fd  2e 0d 01 90 04 0d 01 9a  ||...............|
00000190  05 e0 0d 01 a4 04 0d 01  ae 04 0d 01 b8 22 f4 20  |.............". |
000001a0  64 61 74 61 28 29 20 61  63 63 65 73 73 65 64 20  |data() accessed |
000001b0  62 79 20 72 65 66 65 72  6e 65 63 65 0d 01 c2 17  |by refernece....|
000001c0  dd f2 66 6f 75 72 31 28  6e 6e 25 2c 69 73 69 67  |..four1(nn%,isig|
000001d0  6e 25 29 0d 01 cc 04 0d  01 d6 25 ea 69 69 25 2c  |n%).......%.ii%,|
000001e0  6a 6a 25 2c 6e 25 2c 6d  6d 61 78 25 2c 6d 25 2c  |jj%,n%,mmax%,m%,|
000001f0  6a 25 2c 69 73 74 65 70  25 2c 69 25 0d 01 e0 1e  |j%,istep%,i%....|
00000200  ea 77 74 65 6d 70 2c 77  72 2c 77 70 72 2c 77 70  |.wtemp,wr,wpr,wp|
00000210  69 2c 77 69 2c 74 68 65  74 61 0d 01 ea 18 ea 74  |i,wi,theta.....t|
00000220  65 6d 70 72 2c 74 65 6d  70 69 2c 77 72 73 2c 77  |empr,tempi,wrs,w|
00000230  69 73 0d 01 f4 04 0d 01  fe 06 ea 73 0d 02 08 04  |is.........s....|
00000240  0d 02 12 0c 6e 25 3d 32  2a 6e 6e 25 0d 02 1c 08  |....n%=2*nn%....|
00000250  6a 25 3d 31 0d 02 26 35  f4 20 54 68 69 73 20 69  |j%=1..&5. This i|
00000260  73 20 74 68 65 20 62 69  74 2d 72 65 76 65 72 73  |s the bit-revers|
00000270  61 6c 20 73 65 63 74 69  6f 6e 20 6f 66 20 74 68  |al section of th|
00000280  65 20 72 6f 75 74 69 6e  65 0d 02 30 11 e3 20 69  |e routine..0.. i|
00000290  69 25 3d 31 20 b8 20 6e  6e 25 0d 02 3a 10 20 20  |i%=1 . nn%..:.  |
000002a0  69 25 3d 32 2a 69 69 25  2d 31 0d 02 44 11 20 20  |i%=2*ii%-1..D.  |
000002b0  e7 20 6a 25 20 3e 20 69  25 20 8c 0d 02 4e 36 20  |. j% > i% ...N6 |
000002c0  20 20 20 f4 20 53 77 61  70 20 74 68 65 20 72 65  |   . Swap the re|
000002d0  61 6c 20 61 6e 64 20 69  6d 61 72 69 6e 61 72 79  |al and imarinary|
000002e0  20 70 61 72 74 73 20 6f  66 20 74 68 65 20 74 77  | parts of the tw|
000002f0  6f 0d 02 58 37 20 20 20  20 74 65 6d 70 72 20 20  |o..X7    tempr  |
00000300  20 20 20 20 3d 20 64 61  74 61 28 6a 25 29 20 3a  |    = data(j%) :|
00000310  20 74 65 6d 70 69 20 20  20 20 20 20 3d 20 64 61  | tempi      = da|
00000320  74 61 28 6a 25 2b 31 29  0d 02 62 37 20 20 20 20  |ta(j%+1)..b7    |
00000330  64 61 74 61 28 6a 25 29  20 20 20 3d 20 64 61 74  |data(j%)   = dat|
00000340  61 28 69 25 29 20 3a 20  64 61 74 61 28 6a 25 2b  |a(i%) : data(j%+|
00000350  31 29 20 3d 20 64 61 74  61 28 69 25 2b 31 29 0d  |1) = data(i%+1).|
00000360  02 6c 32 20 20 20 20 64  61 74 61 28 69 25 29 20  |.l2    data(i%) |
00000370  20 20 3d 20 74 65 6d 70  72 20 20 20 20 3a 20 64  |  = tempr    : d|
00000380  61 74 61 28 69 25 2b 31  29 20 3d 20 74 65 6d 70  |ata(i%+1) = temp|
00000390  69 0d 02 76 07 20 20 cd  0d 02 80 11 20 20 6d 25  |i..v.  .....  m%|
000003a0  20 3d 20 6e 25 20 81 20  32 0d 02 8a 1a 20 20 c8  | = n% . 2....  .|
000003b0  95 20 28 6d 25 3e 3d 32  29 20 80 20 28 6a 25 3e  |. (m%>=2) . (j%>|
000003c0  6d 25 29 0d 02 94 14 20  20 20 20 6a 25 20 3d 20  |m%)....    j% = |
000003d0  6a 25 20 2d 20 6d 25 0d  02 9e 13 20 20 20 20 6d  |j% - m%....    m|
000003e0  25 20 3d 20 6d 25 20 81  20 32 0d 02 a8 07 20 20  |% = m% . 2....  |
000003f0  ce 0d 02 b2 12 20 20 6a  25 20 3d 20 6a 25 20 2b  |.....  j% = j% +|
00000400  20 6d 25 0d 02 bc 05 ed  0d 02 c6 04 0d 02 d0 0d  | m%.............|
00000410  6d 6d 61 78 25 20 3d 20  32 0d 02 da 04 0d 02 e4  |mmax% = 2.......|
00000420  2a f4 20 4e 6f 77 20 74  68 65 20 44 61 6e 69 65  |*. Now the Danie|
00000430  6c 73 6f 6e 2d 4c 61 6e  63 7a 6f 73 20 72 65 63  |lson-Lanczos rec|
00000440  75 72 72 65 6e 63 65 0d  02 ee 04 0d 02 f8 11 c8  |urrence.........|
00000450  95 20 6e 25 20 3e 20 6d  6d 61 78 25 0d 03 02 16  |. n% > mmax%....|
00000460  20 20 69 73 74 65 70 25  20 3d 20 32 2a 6d 6d 61  |  istep% = 2*mma|
00000470  78 25 0d 03 0c 25 20 20  74 68 65 74 61 20 20 3d  |x%...%  theta  =|
00000480  20 32 20 2a 20 af 20 2f  20 28 69 73 69 67 6e 25  | 2 * . / (isign%|
00000490  2a 6d 6d 61 78 25 29 0d  03 16 04 0d 03 20 1a 20  |*mmax%)...... . |
000004a0  20 20 20 20 20 20 20 73  3d b5 28 30 2e 35 2a 74  |       s=.(0.5*t|
000004b0  68 65 74 61 29 0d 03 2a  19 20 20 77 70 72 20 20  |heta)..*.  wpr  |
000004c0  20 20 3d 20 2d 32 2e 30  20 2a 20 73 2a 73 0d 03  |  = -2.0 * s*s..|
000004d0  34 17 20 20 77 70 69 20  20 20 20 3d 20 b5 28 74  |4.  wpi    = .(t|
000004e0  68 65 74 61 29 0d 03 3e  04 0d 03 48 0e 20 20 77  |heta)..>...H.  w|
000004f0  72 20 3d 20 31 2e 30 0d  03 52 0e 20 20 77 69 20  |r = 1.0..R.  wi |
00000500  3d 20 30 2e 30 0d 03 5c  1b 20 20 e3 20 69 69 25  |= 0.0..\.  . ii%|
00000510  20 3d 20 31 20 b8 20 6d  6d 61 78 25 20 81 20 32  | = 1 . mmax% . 2|
00000520  0d 03 66 14 20 20 20 20  6d 25 20 3d 20 32 2a 69  |..f.    m% = 2*i|
00000530  69 25 2d 31 0d 03 70 10  20 20 20 20 77 72 73 20  |i%-1..p.    wrs |
00000540  3d 20 77 72 0d 03 7a 10  20 20 20 20 77 69 73 20  |= wr..z.    wis |
00000550  3d 20 77 69 0d 03 84 22  20 20 20 20 e3 20 6a 6a  |= wi..."    . jj|
00000560  25 3d 30 20 b8 20 28 6e  25 2d 6d 25 29 20 81 20  |%=0 . (n%-m%) . |
00000570  69 73 74 65 70 25 0d 03  8e 1e 20 20 20 20 20 20  |istep%....      |
00000580  69 25 20 3d 20 6d 25 20  2b 20 6a 6a 25 2a 69 73  |i% = m% + jj%*is|
00000590  74 65 70 25 0d 03 98 17  20 20 20 20 20 20 6a 25  |tep%....      j%|
000005a0  20 3d 20 69 25 2b 6d 6d  61 78 25 0d 03 a2 31 20  | = i%+mmax%...1 |
000005b0  20 20 20 20 20 74 65 6d  70 72 20 3d 20 77 72 73  |     tempr = wrs|
000005c0  2a 64 61 74 61 28 6a 25  29 20 20 20 2d 20 77 69  |*data(j%)   - wi|
000005d0  73 2a 64 61 74 61 28 6a  25 2b 31 29 0d 03 ac 2f  |s*data(j%+1).../|
000005e0  20 20 20 20 20 20 74 65  6d 70 69 20 3d 20 77 72  |      tempi = wr|
000005f0  73 2a 64 61 74 61 28 6a  25 2b 31 29 20 2b 20 77  |s*data(j%+1) + w|
00000600  69 73 2a 64 61 74 61 28  6a 25 29 0d 03 b6 29 20  |is*data(j%)...) |
00000610  20 20 20 20 20 64 61 74  61 28 6a 25 29 20 20 20  |     data(j%)   |
00000620  3d 20 64 61 74 61 28 69  25 29 20 20 20 2d 20 74  |= data(i%)   - t|
00000630  65 6d 70 72 0d 03 c0 29  20 20 20 20 20 20 64 61  |empr...)      da|
00000640  74 61 28 6a 25 2b 31 29  20 3d 20 64 61 74 61 28  |ta(j%+1) = data(|
00000650  69 25 2b 31 29 20 2d 20  74 65 6d 70 69 0d 03 ca  |i%+1) - tempi...|
00000660  29 20 20 20 20 20 20 64  61 74 61 28 69 25 29 20  |)      data(i%) |
00000670  20 20 3d 20 64 61 74 61  28 69 25 29 20 20 20 2b  |  = data(i%)   +|
00000680  20 74 65 6d 70 72 0d 03  d4 29 20 20 20 20 20 20  | tempr...)      |
00000690  64 61 74 61 28 69 25 2b  31 29 20 3d 20 64 61 74  |data(i%+1) = dat|
000006a0  61 28 69 25 2b 31 29 20  2b 20 74 65 6d 70 69 0d  |a(i%+1) + tempi.|
000006b0  03 de 09 20 20 20 20 ed  0d 03 e8 12 20 20 20 20  |...    .....    |
000006c0  77 74 65 6d 70 20 3d 20  77 72 0d 03 f2 24 20 20  |wtemp = wr...$  |
000006d0  20 20 77 72 20 3d 20 77  72 2a 77 70 72 20 2d 20  |  wr = wr*wpr - |
000006e0  20 20 20 77 69 2a 77 70  69 20 2b 20 77 72 0d 03  |   wi*wpi + wr..|
000006f0  fc 24 20 20 20 20 77 69  20 3d 20 77 69 2a 77 70  |.$    wi = wi*wp|
00000700  72 20 2b 20 77 74 65 6d  70 2a 77 70 69 20 20 2b  |r + wtemp*wpi  +|
00000710  77 69 0d 04 06 07 20 20  ed 0d 04 10 14 20 20 6d  |wi....  .....  m|
00000720  6d 61 78 25 20 3d 20 69  73 74 65 70 25 0d 04 1a  |max% = istep%...|
00000730  05 ce 0d 04 24 05 e1 0d  04 2e 04 0d 04 38 04 0d  |....$........8..|
00000740  04 42 04 0d 04 4c 04 0d  04 56 04 0d 04 60 04 0d  |.B...L...V...`..|
00000750  04 6a 04 0d 04 74 04 0d  04 7e 04 0d 04 88 04 0d  |.j...t...~......|
00000760  04 92 04 0d 04 9c 04 0d  04 a6 04 0d 04 b0 04 0d  |................|
00000770  04 ba 04 0d 04 c4 04 0d  ff                       |.........|
00000779