Comments (5)
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.
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.
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.
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.
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)
- Cannot get aggregate device to work with sounddevice/rtmixer signal processing.py example HOT 1
- Enhancement Request: Integrate Playback Status Check into Simple `play`/`stop` API in `sounddevice` HOT 4
- Feature request for loopback of output device. HOT 3
- 设备解码错误?utf-8' codec can't decode byte 0xc2 in position 6: invalid continuation byte HOT 4
- Sounddevice + big dict + OOP = Segfault / Bus Error HOT 11
- Update device list by reloading portaudio dll HOT 1
- Won't be able to import sounddevice due to unknown issue with `libportaudio64bit.dll` HOT 5
- Error opening OutputStream: Unanticipated host error', -9999, (2, 0, 'Failed to load ASIO driver
- Use sounddevice with virtual audio device and minimize latency HOT 1
- Achieving stable latency between calls of "playrec" HOT 8
- sounddevice not recognize all devices?
- Issues with playing concurrently with Youtube HOT 1
- Latency 30mSec HOT 9
- Advice on asynchronous playback HOT 7
- docker node minimal image
- Can I continue recording until the volume drops below a threshold? HOT 4
- Simultaneous audio playback datatype issue HOT 2
- Does sd.wait() block all other threads? HOT 1
- OSERROR portaudio library not found
- Advice on detecting when Sounddevice has stopped playing audio (and using multiple OutputStreams)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-sounddevice.