updates audiometer example for recent Stream changes

This commit is contained in:
Spencer Russell 2016-03-23 23:41:26 -04:00
parent db2f697d6c
commit 6970d2b81e

View file

@ -3,12 +3,12 @@ using PortAudio
"""Continuously read from the default audio input and plot an """Continuously read from the default audio input and plot an
ASCII level/peak meter""" ASCII level/peak meter"""
function micmeter(metersize) function micmeter(metersize)
mic = PortAudioSource() mic = PortAudioStream(1, 0; bufsize=512)
signalmax = zero(eltype(mic)) signalmax = zero(eltype(mic))
println("Press Ctrl-C to quit") println("Press Ctrl-C to quit")
while true while true
block = read(mic, 4096) block = read(mic, 512)
blockmax = maximum(abs(block)) # find the maximum value in the block blockmax = maximum(abs(block)) # find the maximum value in the block
signalmax = max(signalmax, blockmax) # keep the maximum value ever signalmax = max(signalmax, blockmax) # keep the maximum value ever
print("\r") # reset the cursor to the beginning of the line print("\r") # reset the cursor to the beginning of the line
@ -45,3 +45,5 @@ function barcolor(metersize, position)
:yellow :yellow
end end
end end
micmeter(80)