I was playing around with some code to generate a van de graff like spark maker, and cleaned it up to post here.
Nothing earth-shattering, and I know absolutely nothing about wave forms and such, but here it is.
set display mode 640,480,32
randomize -timer()
` a smaller frequency makes more segments
global nFrequency=20
` a higher amplitude makes higher peaks and lower valleys
global nAmplitude=120
` a lower delay makes quicker flickers
global nDelay=50
` starts with the current timer value
global nWaitTime=timer()
do
cls 0
make_lightning(nFrequency,nAmplitude)
handle_key_input(nDelay)
loop
function make_lightning(nF as integer,nA as integer)
x1=0
y1=240
for x=640/nF to 640 step 640/nF
x2=x
y2=240-(nA/2)+rnd(nA)
if x2+(640/nF)>640
x2=640
y2=240
endif
ink rgb(50,50,100),0
line x1,y1-5,x2,y2-5
line x1,y1-4,x2,y2-4
line x1,y1+4,x2,y2+4
line x1,y1+5,x2,y2+5
ink rgb(100,100,150),0
line x1,y1-3,x2,y2-3
line x1,y1-2,x2,y2-2
line x1,y1+2,x2,y2+2
line x1,y1+3,x2,y2+3
ink rgb(150,150,200),0
line x1,y1-1,x2,y2-1
line x1,y1+1,x2,y2+1
ink rgb(200,200,255),0
line x1,y1,x2,y2
x1=x2
y1=y2
next x
endfunction
function handle_key_input(nD as integer)
if upkey() then inc nFrequency
if downkey() then dec nFrequency
if nFrequency<1 then nFrequency=1
if rightkey() then inc nAmplitude
if leftkey() then dec nAmplitude
if nAmplitude<1 then nAmplitude=1
if scancode()=78 then inc nDelay
if scancode()=74 then dec nDelay
if nDelay<1 then nDelay=1
ink rgb(255,255,255),0
center text 320,440,"Up/Down change Frequency, Left/Right change Amplitude, +/- change Delay"
center text 320,460,"Frequency:"+str$(nFrequency)+" Amplitude:"+str$(nAmplitude)+" Delay:"+str$(nDelay)
while timer()<nWaitTime+nD
endwhile
nWaitTime = timer()
endfunction
