Giter VIP home page Giter VIP logo

Comments (4)

bastibe avatar bastibe commented on June 20, 2024

This is a very common issue with laptop sound cards, particularly on OS X. Apparently, OS X shuts down the sound hardware completely if no sound is playing. In this case, it can take some time for the sound card to wake up until it is responsive.

You can actually see this in OS X itself, too. If you haven't played a sound in a while and start playing one from the Finder, the first time will start with a short delay. After that, it will play sounds without delay. Thus, it is probably an issue with OS X or CoreAudio, and out of reach for portaudio or pysoundcard.

I don't know whether similar behavior exists on other OSes or hardware, but I certainly have never seen it anywhere else yet.

from python-soundfile.

jeremygray avatar jeremygray commented on June 20, 2024

Interesting, good to know! That's my situation exactly.

from python-soundfile.

jeremygray avatar jeremygray commented on June 20, 2024

I can confirm that playing a very short, effectively silent sound once every 20 seconds in a loop within a separate python process completely fixes this, while being undetectable by ear.

from python-soundfile.

mgeier avatar mgeier commented on June 20, 2024

That's good to know!

Doesn't it work with an actually silent sound (all zeros) instead of an effectively silent one?

Anyway, If you really care about exact timing, you should use a stream which is always running and find out in the callback function if something has to be played back or not.
To achieve a constant latency (with little jitter), you can use the method Stream.time() to get the time when your actual event occurs and use this time value in the callback to determine the correct time for starting the playback (relative to the current block beginning).
Alternatively, you can also always play immediately at the block beginnings, which reduces latency but increases jitter. If the rhythmic succession of events doesn't matter, the latter should suffice.

from python-soundfile.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.