Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unanticipated Host Error #242

Open
chigkim opened this issue Aug 2, 2022 · 1 comment
Open

Unanticipated Host Error #242

chigkim opened this issue Aug 2, 2022 · 1 comment

Comments

@chigkim
Copy link

chigkim commented Aug 2, 2022

If I run the following code, I get this error after playing for a few seconds and stuttering.
Portaudio error in Pa_AbortStream (pa_stop): Unanticipated host error
Portaudio error in Pa_CloseStream (pa_deinit): PortAudio not initialized
Portaudio error in Pa_Terminate (pa_deinit): PortAudio not initialized
Pyo error: Error closing audio backend.

import numpy as np
n = 20
# I get data from files, but I use random for this demo.
data = np.random.random((n, n))
panData = np.random.random(n)
speed = 0.5
from pyo import *
import time
s = Server()
s.boot()
s.start()
pink = PinkNoise()
split = BandSplit(pink, num=n, q=500)
panTableReader = TableRead(DataTable(n, init=panData.tolist()), freq=speed, loop=1, interp=1)
dataTableReader = [TableRead(DataTable(n, init=data[i].tolist()), freq=speed, loop=1, interp=1) for i in range(n)]
pans = []
for i in range(n):
	pans.append(SPan(split[i], pan=panTableReader.play(), mul=dataTableReader[i].play()).out())
time.sleep(3)
exit()
@belangeo
Copy link
Owner

belangeo commented Nov 4, 2022

You should exit your program more gracefully than simply exit() after a given time. A good habit is to stop the audio server before leaving the program.

Instead of:

time.sleep(3)
exit()

You can try something like:

time.sleep(3)
s.stop()
time.sleep(.2)
exit()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants