simplifies GR example

This commit is contained in:
Spencer Russell 2016-03-28 12:20:47 -04:00
parent 2366f76a06
commit 547cce821a

View file

@ -6,25 +6,15 @@ module SpectrumExample
using GR, PortAudio, SampleTypes using GR, PortAudio, SampleTypes
const N = 1024 const N = 1024
const stream = PortAudioStream(1, 1, bufsize=N) const stream = PortAudioStream(1, 0, bufsize=N)
const buf = read(stream, N) const buf = read(stream, N)
const fmin = 0Hz const fmin = 0Hz
const fmax = 10000Hz const fmax = 10000Hz
const fs = Float32[float(f) for f in domain(fft(buf)[fmin..fmax])] const fs = Float32[float(f) for f in domain(fft(buf)[fmin..fmax])]
setwindow(fs[1], fs[end], 0, 100)
setviewport(0.05, 0.95, 0.05, 0.95)
setlinecolorind(218)
setfillintstyle(1)
setfillcolorind(208)
setscale(GR.OPTION_X_LOG)
while true while true
read!(stream, buf) read!(stream, buf)
clearws() plot(fs, abs(fft(buf)[fmin..fmax]), xlim=(fs[1],fs[end]), ylim=(0,100))
fillrect(fs[1], fs[end], 0, 100)
polyline(fs, abs(fft(buf)[fmin..fmax]))
updatews()
end end
end end