;----------------------------------------------------------------- ; Julia Set Instruments ; Coded by Hans Mikelson June 28, 1999 ;----------------------------------------------------------------- sr=44100 ; Sample rate kr=22050 ; Control rate ksmps=2 ; Samples per control period nchnls=2 ; Number of channels ;----------------------------------------------------------------- ; Julia Set Waveform, Rastor Scan ;----------------------------------------------------------------- instr 10 idur = p3 ; Duration aamp init p4 ; Amplitude ifqc = cpspch(p5) ; Frequency kxtrace init p6 ; X-Scan kytrace init p7 ; Y-Scan kxstep init p8 ; X-Step size kystep init p9*ifqc/55 ; Y-Step size ilpmax init p10 ; Maximum number of inner loops ipanl = sqrt(p11) ; Pan left ipanr = sqrt(1-p11) ; Pan right kcx init p12 ; Real constant kcy init p13 ; Complex constant kclk init 1 ; A square clock going from -1 to 1 aout2 init 0 ; Output 2 kdy init 1 ; Step direction because of the rastor scan aout1 init 0 ; step direction reverses each cycle. kclkold = kclk ; Remember the previous clock value kclk oscil 1, ifqc, 9 ; Obtain the new clock value kdclick linseg 0, .002, 1, idur-.004, 1, .002, 0 ; Declick envelope kfco linseg 500, .1, 2000, .2, 1400, idur-.3, 800 kcount = 0 ; Initialize loop counter kx = kxtrace ; Initialize X coordinate (real) ky = kytrace ; Initialize Y coordinate (complex) julialoop: ; Iteration for calculating the Julia Set. kxx = kx*kx-ky*ky+kcx ; Compute Z^2 + C kyy = 2*kx*ky+kcy ; (x+iy)^2=x^2+ixy-y^2 kx = kxx ky = kyy kcount = kcount + 1 if ((kx*kx+ky*ky<4) && (kcount