home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1992 January / 1992-01.d64 / synthesizer (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  7KB  |  244 lines

  1. 0 clr
  2. 5 ifpeek(49152)<>169thenpoke53265,0:load"synth ml",8,1
  3. 10 sys49152:kb$(0)="[208]oly":kb$(1)="[211]olo":kb$(2)="[194]i-voice":kb$(3)="[212]ri-voice"
  4. 13 wv$(1)="[212]ria":wv$(2)="[211]awt":wv$(3)="[212]r[211]a":wv$(4)="[208]uls":wv$(5)="[208]u[212]r"
  5. 14 wv$(6)="[208]u[211]a":wv$(7)="[208]u[212][211]":wv$(8)="[206]oiz":xp=14:yp=7
  6. 15 dimk(76),m(31):fort=1to24:reada,b:k(b)=a:next:poke53248,125:poke53249,90
  7. 20 s=54272:m(5)=15:m(4)=17:m(25)=4:kb=197:m(3)=5:m(24)=31:m(23)=240:m(22)=200
  8. 25 m(28)=25:m(29)=25:m(30)=25:b=24:b$=" =[147][133]":fort=stos+24:poket,0:nextt
  9. 27 fort=0to2:poke49248+t*3,m(28)+t:next
  10. 30 pokes+22,m(22):pokes+24,m(24):poke53264,0:gosub320:poke53265,27
  11. 35 data 8583,62,9094,31,9634,68,10207,32,10814,50,11457,63,12139,34,12860,65
  12. 40 data 13625,35,14435,70,15294,36,16203,66,17167,54,18188,38,19269,60
  13. 45 data 20415,29,21629,61,22915,45,24278,26,25721,23,27251,73,28871,75,30588,0
  14. 50 data 32407,1
  15. 55 rem ** which keyboard mode? **
  16. 60 ifm(31)=1then125
  17. 70 ifm(31)=2then230
  18. 75 ifm(31)=3then175
  19. 80 ifpeek(56320)<>127then430
  20. 85 geta$:ifa$=""then80
  21. 90 ifasc(a$)>95orasc(a$)<19then280
  22. 95 f=k(asc(a$)-19)/m(25+v/7):iff=0then280
  23. 100 h=int(f/256):l=f-(256*h)
  24. 105 pokes+4+v,m(v+4)and254:pokes+v,l:pokes+1+v,h
  25. 110 pokes+4+v,m(v+4)or1:v=v+7:ifv=21thenv=0
  26. 115 goto80
  27. 120 rem ** solo **
  28. 125 geta$:ifpeek(56320)<>127then430
  29. 130 ifa$=""then155
  30. 135 ifasc(a$)>95orasc(a$)<19then280
  31. 140 f=k(asc(a$)-19)/m(25):iff=0then280
  32. 145 h=int(f/256):l=f-(256*h)
  33. 150 pokes,l:pokes+1,h:pokes+4,m(4)
  34. 155 ifpeek(kb)<>64then125
  35. 160 ifpeek(kb)=64thenpokes+4,m(4)and254
  36. 165 goto125
  37. 170 rem ** tri-voice **
  38. 175 geta$:ifpeek(56320)<>127then430
  39. 180 ifa$=""then210
  40. 185 ifasc(a$)>95orasc(a$)<19then280
  41. 190 forv=0to14step7:f=k(asc(a$)-19)/m(25+v/7):iff=0then280
  42. 195 h=int(f/256):l=f-(256*h):ifl-14<0thenl=l+14
  43. 200 pokes+1+v,h:pokes+v,l-v:next:v=0
  44. 205 forv=0to14step7:pokes+4+v,m(v+4)or1:next:v=0
  45. 210 ifpeek(kb)<>64then175
  46. 215 ifpeek(kb)=64thenforv=0to14step7:pokes+4+v,m(v+4)and254:next:v=0
  47. 220 goto175
  48. 225 rem ** bi-voice **
  49. 230 geta$:ifpeek(56320)<>127then430
  50. 235 ifa$=""then260
  51. 240 ifasc(a$)>95orasc(a$)<19then280
  52. 245 forv=0to7step7:f=k(asc(a$)-19)/m(25+v/7):iff=0then280
  53. 250 h=int(f/256):l=f-(256*h):ifl<7thenl=l+7
  54. 255 pokes+v,l-v:pokes+1+v,h:next:v=0:pokes+4,m(4)or1:pokes+11,m(11)or1
  55. 260 ifpeek(kb)<>64thengoto230
  56. 265 ifpeek(kb)=64thenforv=0to14step7:pokes+4+v,m(v+4)and254:next:v=0
  57. 270 goto230
  58. 275 rem ** kb mode, equalize, run **
  59. 280 fort=1to4:ifa$<>mid$(b$,t,1)thennext:goto60
  60. 281 ontgoto295,288,287,282
  61. 282 print""
  62. 283 sys50078,128,m(24),24:m(24)=peek(780)
  63. 284 ifm(24)and128thenprinttab(29)"[154][207]ff":goto60
  64. 285 printtab(29)"   ":goto60
  65. 287 run
  66. 288 gosub320:goto60
  67. 290 rem ** keyboard mode **
  68. 295 forv=0to14step7:pokes+4+v,m(v+4)and254:next:v=0:m(31)=m(31)+1
  69. 300 pokes+14,m(14):pokes+15,m(15):ifm(31)=4thenm(31)=0
  70. 305 print""tab(20)kb$(m(31))"     ":goto60
  71. 315 rem ** equalize voices **
  72. 320 forv=0to14step7:m(v+2)=m(e+2):m(v+3)=m(e+3):m(v+4)=m(e+4):m(v+5)=m(e+5)
  73. 323 m(v+6)=m(e+6):m(25+v/7)=m(25+e/7)
  74. 325 pokes+2+v,m(e+2):pokes+3+v,m(e+3):pokes+5+v,m(e+5):pokes+6+v,m(e+6)
  75. 326 pokes+4+v,m(e+4):next
  76. 327 rem ** print values **
  77. 330 print""tab(20)kb$(m(31))
  78. 335 forv=0to14step7:t=7+v/7*13:print""
  79. 337 printtab(t+1)wv$((m(e+4)and240)/16)
  80. 340 printtab(t)"     [157][157][157][157][157]"m(e+2)+m(e+3)*256"[156]"
  81. 345 if(m(e+4)and4)=0thenprinttab(t)" [207]ff":goto350
  82. 347 printtab(t)" [207]n "
  83. 350 if(m(e+4)and2)=0thenprinttab(t)" [207]ff":goto360
  84. 355 printtab(t)" [207]n "
  85. 360 print"[150]"tab(t)(m(e+5)and240)/16"[157] "
  86. 365 printtab(t)m(e+5)and15"[157] "
  87. 370 printtab(t)(m(e+6)and240)/16"[157] "
  88. 375 printtab(t)m(e+6)and15"[157] "
  89. 380 print""tab(t)6-(log(m(e/7+25))/log(2)):next:v=0
  90. 385 print"[159]"tab(14)m(21)+m(22)*8"[158]"tab(31)m(14)+m(15)*256
  91. 390 ifm(23)and1thenprinttab(15)"[159]1[145]"
  92. 392 ifm(23)and2thenprinttab(17)"[159]2[145]"
  93. 394 ifm(23)and4thenprinttab(19)"[159]3[145]"
  94. 395 print"[158]"tab(31)m(28)
  95. 400 ifm(24)and16thenprinttab(15)"[159][204]p[145]"
  96. 401 ifm(24)and64thenprinttab(18)"[159][200]p[145]"
  97. 402 ifm(24)and32thenprinttab(21)"[159][194]p[145]"
  98. 405 print"[158]"tab(31)m(29)
  99. 410 print"[159]"tab(14)(m(23)and240)/16"[158]"tab(31)m(30)
  100. 415 print"[159]"tab(14)m(24)and15
  101. 420 return
  102. 425 rem ** move, voices 15+15*8 34+7*8
  103. 430 ifyp>16then570
  104. 435 poke53248,13+xp*8:poke53249,34+yp*8
  105. 440 j=peek(56320):ifj=127then60
  106. 443 if(jand16)=0then634
  107. 445 if(jand1)=0andyp<>7thenyp=yp-1
  108. 500 if(jand2)=0thenyp=yp+1:ifyp=16thenyp=19:goto570
  109. 550 if(jand4)=0ande<>0thene=e-7:xp=xp-13
  110. 555 if(jand8)=0ande<>14thene=e+7:xp=xp+13
  111. 560 ifxp<>40andxp<>8thenpoke53264,0:xp=14+e/7*13
  112. 561 ifxp=40thenpoke53264,1:xp=8
  113. 562 goto435
  114. 563 rem ** filter and mod **
  115. 570 ifxp<>8then600
  116. 571 rem ** modulation **
  117. 572 ifyp=23thenyp=22
  118. 573 poke53248,13+xp*8:poke53249,34+yp*8
  119. 574 j=peek(56320):ifj=127then60
  120. 575 if(jand16)=0then634
  121. 576 if(jand1)=0thenyp=yp-1:ifyp=18thenxp=14+e/7*13:yp=15:goto560
  122. 580 if(jand2)=0andyp<>22thenyp=yp+1
  123. 585 if(jand4)=0then600
  124. 595 goto573
  125. 597 rem ** filter **
  126. 600 xp=26:poke53264,0
  127. 605 poke53248,13+xp*8:poke53249,34+yp*8
  128. 607 j=peek(56320):ifj=127then60
  129. 608 if(jand16)=0then634
  130. 610 if(jand1)=0thenyp=yp-1:ifyp=18thenxp=14+13*e/7:yp=15:goto560
  131. 615 if(jand2)=0andyp<>23thenyp=yp+1
  132. 620 if(jand8)=0thenpoke53264,1:xp=8:goto572
  133. 630 goto605
  134. 633 rem ** compute **
  135. 634 poke214,yp-2:ifyp>16then655
  136. 640 rem ** compute, voices **
  137. 645 onyp-6goto685,720,745,747,770,805,773,810,850
  138. 650 rem ** compute, filter or mod **
  139. 655 ifxp=8then675
  140. 660 rem ** compute, filter **
  141. 665 onyp-18goto880,915,960,995,997
  142. 670 rem ** compute, modulation **
  143. 675 onyp-18goto1035,1080,1081,1082
  144. 680 rem ** waveform **
  145. 685 print""
  146. 690 j=peek(56320):if(jand1)=0and(m(e+4)and128)=0thenm(e+4)=m(e+4)+16
  147. 695 if(jand2)=0and(m(e+4)and240)>16thenm(e+4)=m(e+4)-16
  148. 700 printtab(8+13*e/7)wv$(int(m(e+4)/16))"[145]":pokes+e+4,m(e+4)and254
  149. 705 ifj=127then60
  150. 710 goto690
  151. 715 rem ** pulse **
  152. 720 p=m(e+2)+m(e+3)*256:print""
  153. 724 j=peek(56320):if(jand1)=0andp<4076thenp=p+20
  154. 725 if(jand2)=0andp>19thenp=p-20
  155. 727 if(jand8)=0andp<4095thenp=p+1
  156. 730 printtab(7+13*e/7)p"[157] [145]":pokes+e+2,pand255:pokes+e+3,int(p/256)
  157. 735 ifj=127thenm(e+2)=pand255:m(e+3)=int(p/256):goto60
  158. 740 goto724
  159. 743 rem ** ring or sync **
  160. 745 print"[156]":eo=4:goto750
  161. 747 print"[156]":eo=2
  162. 750 sys50078,eo,m(e+4),e+4:m(e+4)=peek(780):pokes+e+4,m(e+4)and254
  163. 755 if(m(e+4)andeo)=0thenprinttab(8+13*e/7)"[207]ff[145]":goto760
  164. 757 printtab(8+13*e/7)"[207]n [145]"
  165. 760 goto60
  166. 765 rem ** a,s **
  167. 770 print"[150]":eo=5:goto774
  168. 773 print"[150]":eo=6
  169. 774 p=(m(e+eo)and240)/16
  170. 775 j=peek(56320):if(jand1)=0andp<>15thenp=p+1
  171. 780 if(jand2)=0andp<>0thenp=p-1
  172. 785 printtab(7+13*e/7)p"[157] [145]":pokes+e+eo,(m(e+eo)and15)+p*16
  173. 790 ifj=127thenm(e+eo)=(m(e+eo)and15)+p*16:goto60
  174. 795 goto775
  175. 800 rem ** d,r **
  176. 805 print"[150]":eo=5:goto815
  177. 810 print"[150]":eo=6
  178. 815 p=m(e+eo)and15
  179. 820 j=peek(56320):if(jand1)=0andp<>15thenp=p+1
  180. 825 if(jand2)=0andp<>0thenp=p-1
  181. 830 printtab(7+13*e/7)p"[157] [145]":pokes+e+eo,(m(e+eo)and240)+p
  182. 835 ifj=127thenm(e+eo)=(m(e+eo)and240)+p:goto60
  183. 840 goto820
  184. 845 rem ** octave **
  185. 850 print"":p=6-(log(m(e/7+25))/log(2))
  186. 855 j=peek(56320):if(jand1)=0andp<>7thenp=p+1
  187. 856 if(jand2)=0andp<>-5thenp=p-1
  188. 860 printtab(7+13*e/7)p"[145]"
  189. 865 ifj=127thenm(e/7+25)=2^(6-p):goto60
  190. 870 goto855
  191. 875 rem ** cutoff freq **
  192. 880 print"[159]":p=m(21)+m(22)*8
  193. 885 j=peek(56320):if(jand1)=0andp<2028thenp=p+20
  194. 890 if(jand2)=0andp>19thenp=p-20
  195. 893 if(jand8)=0andp<2047thenp=p+1
  196. 895 printtab(14)p"[157] [145]"
  197. 897 m(21)=pand7:m(22)=int(p/8):pokes+21,m(21):pokes+22,m(22)
  198. 900 ifj=127then60
  199. 905 goto885
  200. 910 rem ** voices **
  201. 915 printtab(15)"[159]     [145]":p=m(23)and7
  202. 920 p=p+1:pokes+23,(m(23)and248)+p:ifp=8thenp=0
  203. 930 ifpand1thenprinttab(15)"[159]1[145]"
  204. 935 ifpand2thenprinttab(17)"[159]2[145]"
  205. 940 ifpand4thenprinttab(19)"[159]3[145]"
  206. 950 m(23)=(m(23)and248)+p:goto60
  207. 955 rem ** mode **
  208. 960 printtab(15)"[159]        [145]":p=m(24)and112
  209. 965 p=p+16:ifp=128thenp=0
  210. 967 pokes+24,(m(24)and143)+p
  211. 970 ifpand16thenprinttab(15)"[159][204]p[145]"
  212. 975 ifpand32thenprinttab(18)"[159][194]p[145]"
  213. 980 ifpand64thenprinttab(21)"[159][200]p[145]"
  214. 985 m(24)=(m(24)and143)+p:goto60
  215. 990 rem ** resonance, volume **
  216. 995 eo=23:a=15:si=16:p=(m(eo)and240)/16:goto998
  217. 997 eo=24:a=240:s