I'm new to MCC hardware and also programming so sorry if this is either a noob question or has already been solved:
I want to read continuosly data from a accelerometer with a MCC172 and output this data simultaneously and as fast as possible via a USB-audio device. I used the "continuous_scan.py" file as a starting point but I'm getting "Buffer overruns" after a short period of time.
My code looks basically something like this:
p = pyaudio.PyAudio()
stream = p.open(format=pyaudio.paFloat32, channels=1, rate=8192, output=True)
while True:
read_result = hat.a_in_scan_read_numpy(read_request_size, timeout)
# Check for an overrun error
if read_result.hardware_overrun:
print('\n\nHardware overrun\n')
break
elif read_result.buffer_overrun:
print('\n\nBuffer overrun\n')
Question
Wolfgang_Raspi
Hi,
I'm new to MCC hardware and also programming so sorry if this is either a noob question or has already been solved:
I want to read continuosly data from a accelerometer with a MCC172 and output this data simultaneously and as fast as possible via a USB-audio device. I used the "continuous_scan.py" file as a starting point but I'm getting "Buffer overruns" after a short period of time.
My code looks basically something like this:
p = pyaudio.PyAudio()
stream = p.open(format=pyaudio.paFloat32, channels=1, rate=8192, output=True)
while True:
read_result = hat.a_in_scan_read_numpy(read_request_size, timeout)
# Check for an overrun error
if read_result.hardware_overrun:
print('\n\nHardware overrun\n')
break
elif read_result.buffer_overrun:
print('\n\nBuffer overrun\n')
stream.stop_stream()
stream.close()
p.terminate()
print('\n\nStopping Audio Output...\n')
break
data=read_result.data
output_bytes = (0.5 * data).tobytes()
stream.write(output_bytes)
I hope someone can help me with this, thanks!
Link to comment
Share on other sites
1 answer to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now