aUCBLogo Demos and Tests / palindromic_numbers_graph
be palindromic_numbers_graph
fn="palindroms2.dat
openRead fn
setReader fn
dat=readListFlat
close fn
setReader []
dat=FloatArray dat
imax=count dat
snd=FloatArray dat
setPointSize 2
hideTurtle
WindowMode
setUpdateGraph false
black=RGB 0 0 0
m=50
k=1
while [not key?]
[
; catch "error [
clearScreen
plot0
; plot1
; plot2
; plot3
; plot4
updateGraph
; ]
]
comment[
rate=44100
size=rate
openWriteBin "tmp.wav
setWriter "tmp.wav
type [RIFF]
typebin 4+8+8+16+size*2
type [WAVE]
type [fmt\ ]
typebin 16
typebin int16 1
typebin int16 1
typebin rate
typebin rate*2
typebin int16 2
typebin int16 16
type [data]
typebin size*2
typebin snd
setWriter []
close "tmp.wav
playWave "tmp.wav 2
]
be plot0
PenUp
setXY -400 -300
PenDown
repeat imax-2
[ i=repcount
y=(mod dat.i m)*600/m-300
setPixelXY i/imax*800-400 y black
]
print m
m=m+-0.0001
m=900
m=90
end
be plot1
PenUp
setXY -400 -300
PenDown
repeat imax
[ i=repcount
y=((daty i)-(normi i))*2000
setPixelXY i/imax*800-400 y "black
snd.i=y*1000
]
end
be daty i
output dat.i/dat.imax
end
be normi i
output (i/imax)
end
be datn i
output (daty i)-normi i
end
be ddaty i
output ((datn i+1)-(datn i))
end
be dddaty i
output ((ddaty i+1)-(ddaty i))
end
be plot2
PenUp
setXY -400 -300
PenDown
repeat imax-1
[ i=repcount
y=(ddaty i)*50000
setPixelXY i/imax*800-400 y "red
snd.i=y*1000
]
end
be plot3
PenUp
setXY -400 -300
PenDown
setPC "green
m=0
repeat imax-2
[ i=repcount
y=(dddaty i)*50000
setPixelXY i/imax*800-400 y "green
snd.i=y*1000
]
snd=Int16Array lowPassFilter snd 10
end
be plot4
PenUp
setXY -400 -300
PenDown
m=90
y1=0
repeat imax-2
[ i=repcount
y=(mod dat.i-y1 m)*4-200
setPixelXY i/imax*800-400 y "blue
if (ddaty i) > .001 [y1=i-mod i k]
]
print k
; k=k+0.01
; k=92
end
end