# What would it take to replace pyo?

**URL:** <https://discourse.psychopy.org/t/what-would-it-take-to-replace-pyo/1318>\
**Category:** Development\
**Tags:** sound\
**Created:** [October 20, 2016, 3:45pm UTC](https://discourse.psychopy.org/t/what-would-it-take-to-replace-pyo/1318 "2016-10-20T15:45:49Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![matthias.geier](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/matthias.geier/32/216_2.png) [@matthias.geier](https://discourse.psychopy.org/u/matthias.geier)\
**Post date:** [March 9, 2017, 5:02pm UTC](https://discourse.psychopy.org/t/what-would-it-take-to-replace-pyo/1318/12 "2017-03-09T17:02:09Z")

</div>

> [@glupyan](#):
>
> Is the only way to have recordings start and stop on command using an inputStream with a callback? Os is there another way to terminate the recording before the time is up?

Well, generally there is the option of using a so-called “blocking” stream (by not providing a callback method), but I don’t think this has any advantages over using a callback function. One of the disadvantages is that it is not available for all host API (which IMHO is already a deal-breaker).

When using a callback function, there are still two ways to stop some sound from being played:

1. set some state in the callback so that it (the callback) knows it should stop playing
2. stop the whole stream

I think the first option (as @jon has implemented it) makes more sense.

I would use a single stream for everything, both playing and recording, and keep that same stream active all the time.

BTW, I mentioned in [Low sound latency with sounddevice module & wdm-ks driver - #7 by matthias.geier](https://discourse.psychopy.org/t/low-sound-latency-with-sounddevice-module-wdm-ks-driver/912/7) that it would be interesting to try to implement the audio callback in C for more stable, predictable and responsive performance.  
In the meantime, I’ve started to do exactly that: [GitHub - mgeier/python-rtmixer: 🎤 Reliable low-latency audio playback and recording with Python 🐍](https://github.com/mgeier/python-rtmixer/). This is still very much work in progress, but it should already support most of the use cases needed for PsychoPy. I would love to hear what you think about it!

---

_[View the full topic](https://discourse.psychopy.org/t/what-would-it-take-to-replace-pyo/1318)._
