Comments (11)
Little bit more information on this, tried this on my Ubuntu machine as well and rather than only getting the issue when sending just to channel 1 as described above. The last channel always appears to cover two channels example:
sd.play(impulse, samplerate=48000, mapping=[1,3,5], device = 5)
and I will get audio on 1 3 5 and 6
from python-sounddevice.
I think I have an explanation for what you described first (about duplicating the first channel).
This is actually a feature of PortAudio, but it is not available on all host APIs. Probably it's also just a feature of the underlying audio backend(s). AFAIK, this will happen e.g. on ALSA, but not on JACK.
When you use mapping=[1]
(and mono audio data), this will lead to channels=1
internally. Now on some (most?) host APIs (ALSA among others), PortAudio will duplicate this one channel to both output channels. This is actually quite useful for many simple cases, but obviously not at all helpful for your use case.
I don't really know if there is anything I can do to change this behavior.
I can try to force channels=2
instead of channels=1
, but I think this might cause problems in other use cases.
But now to your other comment: I have no idea why the last channel should be duplicated. This doesn't happen with JACK, but I couldn't yet test this with ALSA on a multi-channel soundcard.
from python-sounddevice.
Ok well thanks for the response. I can force channels to 2 myself and try that save you doing it. As for the Jack comment I might look into moving to jack instead of alsa if this solves my problem but I want to test it before I move. Worst comes to it when I want channel one I will will send channel two and silence it myself. thanks for the pointers and confirming its not my donkey hoofs.
from python-sounddevice.
You can't use channels=2
when using mapping=[1]
because former will be ignored. But it should work if you add a second channel with silence.
However you should not get any audio on channel 6 if you use mapping=[1,3,5]
. Are you still having this problem?
from python-sounddevice.
Yeah I never found a work around in the end I retreated back to my pyaudio code and carried on fighting with that.
from python-sounddevice.
And PyAudio doesn't have the same problem?
It should, because it also just uses PortAudio.
My goal with the sounddevice
module is to be able to do everything that can be done with PyAudio (just with a better API) and more.
It would be very helpful if you could tell me what you are able to do with PyAudio that you are not able to do with sounddevice
.
from python-sounddevice.
Sorry let me clarify my statement. There is nothing I can do with pyaudio that I can't do with sounddevice and the API for sounddevice is definitely better of that there is no doubt.
The reason I went back to pyaudio is that I already had most of the functions I needed coded with that and since I appear to have to silence channels in sounddevice and create the mapping in pyaudio rather than re-writting all the stuff i already had to use sound device I stuck with my already done pyaudio code. Purely that i didn't discover sounddevice first.
from python-sounddevice.
OK, thanks for the clarification.
If you happen to find a way to properly avoid the channel duplication, please tell me!
I'll leave this issue open, probably someone else out there has an idea for a solution?
from python-sounddevice.
OK, I think I found a solution that doesn't have too many bad side effects in other situations: #20.
@maximillion90: Can you please check if this works for you?
from python-sounddevice.
Yeah that appears to work as expected now. It allows you to map single channels with no duplication. If i send it too 1 i get just one if i send it to 1 and 3 i get just 1 and 3. Good Work.
from python-sounddevice.
Thanks for testing this!
from python-sounddevice.
Related Issues (20)
- 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)
- Inconsistent order of channels HOT 2
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.