pya icon indicating copy to clipboard operation
pya copied to clipboard

Handling Stream-based and event-based audio in Aserver / Arecorder

Open thomas-hermann opened this issue 4 years ago • 0 comments

Aserver currently starts a stream at boot() and stops it at quit(). Asig.play(onset=...,...) simply dispatches an audio object for output at given onset time. However, there are occasions where a more 'sound object'-oriented output would be wished atone.play(server=f) using a FilewriterBackend to create a file of given format atone.play(server=j) using a JupyterBackend to create an interactive widget that allows to play and replay and navigate within this asig-sound object etc. Even for PyaudioBackend, object based output could be helpful, as it avoids any problems with a chopping stream, which still could happen using the stream-based output.

Proposition to solve this issue:

  1. create a method Asig.playobj(), which plays the object using the specified backend outside the stream-based callback logic (alternative names play1(), or play_event(). This method would not have an onset, and implementation would basically create&start a stream on each invocation, close it right after and delete it.

  2. create a new class altogether, e.g. AEventPlayer(), which would not have a boot and quit method, but always frame play() invocations as outlined above by stream management ops.

I tend to favor 1., but wonder whether there is a third hidden better solution for this problem. I can start to implement it once we are on the same page it it...

thomas-hermann avatar Oct 10 '19 12:10 thomas-hermann