Git Product home page Git Product logo

Comments (5)

fakufaku avatar fakufaku commented on July 28, 2024

After some more test, the problem does not occur so fast if I do not specify the devices and the sampling rate, and specify the latency in seconds (e.g. 0.02 s). It still occurs after sometimes.
Also, after the program hangs, then I can see that CPU usage for python goes to 100%.

Also, when setting explicitly the buffer size

sd.default.blocksize = 512

for example, then the audio is very choppy.

from python-sounddevice.

mgeier avatar mgeier commented on July 28, 2024

Hmmm ... I don't really have a clue ...

When you are working close to the limits of the hardware, strange things might happen, in that case you normally just have to choose more conservative settings.
But you're right, hanging with maxed out CPU is a particularly bad behavior, hopefully this can be somewhat improved.

But first we'll have to find where and how this is happening.
You are saying that the Python process is generating 100% load, but since there is no tight loop in my code, I suspect that the callback is just called too often. Or there is some synchronization problem between the callback and the main Python thread?

Can you probably add some debugging to your callback?
I think it could be interesting to show frames, outdata.shape and indata.shape.

Any other ideas?

from python-sounddevice.

mgeier avatar mgeier commented on July 28, 2024

BTW, you don't have to specify the options twice if they are the same. Instead of

sd.default.dtype = 'int16', 'int16'

you can just use

sd.default.dtype = 'int16'

from python-sounddevice.

fakufaku avatar fakufaku commented on July 28, 2024

Hi thanks for the answer.

Actually it seems I can make it work by cranking up the frequency of the CPU to 1GHz and recompiling the latest version of portaudio.

Another quick quick question, is it possible to have different sampling rates for the input and output ?

from python-sounddevice.

mgeier avatar mgeier commented on July 28, 2024

Actually it seems I can make it work by cranking up the frequency of the CPU to 1GHz and recompiling the latest version of portaudio.

It's good to hear that it works.
In general, it would be more revealing if you change only one thing at a time.
Could you try the two things separately?

is it possible to have different sampling rates for the input and output ?

This is a general PortAudio question, nothing specific to the sounddevice module.

Each "stream" can only have one sampling rate.
If you want your application to be portable, you should only use one stream at a time.
If not, you can try to open two streams at the same time, one for input and one for output.
This may or may not work, depending on your system configuration and the used host API.
You may or may not be able to use different sample rates in this case.
If you use two different streams, they will not be synchronized, so you will have to take care of any buffering that will be necessary to send audio from one stream to another. If you don't do that, you'll have drop-outs at some point.

from python-sounddevice.

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.