aUCBLogo Demos and Tests / generate_eq_preset2
to generate_eq_preset2
; leftname="D:/temp/chirp.raw
leftname="D:/temp/left.raw
; rightname="D:/temp/chirp.raw
rightname="D:/temp/right.raw
N=1024
; N=2048
; N=4096
; N=8192
Nres=100000
f1=20
f2=20000
f3=22050/N/2
f4=22050
clearScreen
WindowMode
setPenSize 0
comment[
l1=log10 f1
l2=log10 f2
xin=rseqfa 0 Nres Nres
_10_=rseqfa 10 10 Nres
y=_10_^(xin/Nres*(l2-l1)+l1)
setPC "black
setXY xin/Nres*300 y/f2*300
x=rseqfa 0 f2 N
a=1/f2*(f2/f1-1)
i=IntArray ((log10 x*a+1)*f2/(log10 f2/f1))*((Nres-1)/f2)+1
setPC "blue
setPixelXY x/f2*300 y.i/f2*300 "blue
for [j 1 N-1][pr y.i.(j+1)-y.i.j]
stop
]
if not Name? "chirp_re
[ ;this is pretty time consuming, so do it only once
samplerate=44100
openReadBin rightname
size=(FileSize rightname)/8
close rightname
l1=log10 f1
l2=log10 f2
logfrequencyQuantum=(l2-l1)/size
blendedLogFrequency=l1
positionInCycles=0
chirp_re=(FloatArray size 0)
chirp_im=(FloatArray size 0)
for [i 0 size-1]
[ blendedFrequency = 360*10^blendedLogFrequency
chirp_re.i=sin positionInCycles/samplerate
chirp_im.i=cos positionInCycles/samplerate
positionInCycles=positionInCycles+blendedFrequency
blendedLogFrequency=blendedLogFrequency+logfrequencyQuantum
]
]
; x=rseqfa -400 400 size
; y=chirp_im*300
; setPC "black
; setXY x y
;stop
filter1=genfilter leftname
;stop
filter2=genfilter rightname
;stop
out="C:/Programme/Winamp/Plugins/dsp_aq.dat
openWriteBin out
setWriter out
typebin filter1.1
typebin reverse filter1.1
typebin filter1.2
typebin reverse filter1.2
typebin filter2.1
typebin reverse filter2.1
typebin filter2.2
typebin reverse filter2.2
setWriter []
close out
end
to genfilter in
openReadBin in
setReader in
size=(FileSize in)/8
fain=readFloatArrayBin size
setReader []
close in
fre=fain*chirp_re
;fre=resize fre Nres
;fre=lowpassfilter2 fre 100
;fre=fre/(max fre)
;x=rseqfa -400 400 Nres
;setXY x fre*300
;stop
fim=fain*chirp_im
;fim=lowpassfilter2 fim 100
fc=(ComplexArray fre)+(ComplexArray fim)*1i
filterc=compute_filter fc
;throw "toplevel
filter_re=FloatArray real filterc
filter_im=FloatArray imag filterc
; filter_im=FloatArray count filter_re
output list filter_re filter_im
end
to compute_filter fa
fa=lowpassfilter2 fa 10
fa=fa*4+(lowpassfilter2 abs fa 10)*0.5
fa=resize fa Nres
fa=fa/(max abs fa)
x=rseqfa -400 400 Nres
setPC "blue
PenUp setXY x.1 (real fa.1)*300 PenDown
setXY x (FloatArray real fa)*300
setPC "green
PenUp setXY x.1 (imag fa.1)*300 PenDown
setXY x (FloatArray imag fa)*300
fa=saturateBelow 0.00001 fa
fa=fa+0.00001
fa=conjugate fa
fa=(reciprocal fa)/3000
fa=lowpassfilter2 fa 10
; x=rseqfa 1 1000 Nres
; fa=fa*30*reciprocal sqrt x
x=rseqfa 0 20 Nres
x=saturateAbove 1 x
fa=fa*x*x
fa=saturateBelow 0 fa
fa=saturateAbove 1 fa
x=rseqfa -400 400 Nres
setPC "blue
PenUp setXY x.1 (real fa.1)*250-250 PenDown
setXY x (FloatArray real fa)*250-250
setPC "green
PenUp setXY x.1 (imag fa.1)*250-250 PenDown
setXY x (FloatArray imag fa)*250-250
;stop
x=rseqfa 0 f2 N
; a=1/f2*(f2/f1-1)
; i=IntArray ((log10 x*a+1)*f2/(log10 f2/f1))*((Nres-1)/f2)+1
x=(x-f1)*(f4-f3)/(f2-f1)+f3
a=1/f2*(f2/f1-1)
i=((log10 x*a+1)*f2/(log10 f2/f1))*((Nres-1)/f2)+1
i=IntArray saturateBelow 1 saturateAbove Nres i
i.1=1
fa2=fa.i
fa2=lowpassfilter2 fa2 5
fa2=saturateAbove 1 fa2
; for [i 1 N]
; [ fa2.i=saturateabove 1 fa2.i*(1-i/N)
; ]
; setPC "green
; fa2=rseqfa 1 1 N ;for a flat filter
; catch "error
; [ blabla=pi*pi
; ]
comment[
setPC "blue
PenUp
setXY x.1/f4*800-400 (real fa2.1)*290
PenDown
setXY x/f4*800-400 (FloatArray real fa2)*290
setPC "green
PenUp
setXY x.1/f4*800-400 (imag fa2.1)*290
PenDown
setXY x/f4*800-400 (FloatArray imag fa2)*290
]
output fa2
end