Fix overflow bug for Raspberry Pi

As fixed at :  https://github.com/scottlawsonbc/audio-reactive-led-strip/pull/73
This commit is contained in:
kanapoutz78 2017-12-19 16:50:24 +01:00 committed by GitHub
parent 437b07f8a4
commit c61db1b140
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,8 +16,9 @@ def start_stream(callback):
prev_ovf_time = time.time() prev_ovf_time = time.time()
while True: while True:
try: try:
y = np.fromstring(stream.read(frames_per_buffer), dtype=np.int16) y = np.fromstring(stream.read(frames_per_buffer, exception_on_overflow=False), dtype=np.int16)
y = y.astype(np.float32) y = y.astype(np.float32)
stream.read(get_read_available(), exception_on_overflow=False)
callback(y) callback(y)
except IOError: except IOError:
overflows += 1 overflows += 1