Git Product home page Git Product logo

Comments (11)

maximillion90 avatar maximillion90 commented on July 28, 2024

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.

mgeier avatar mgeier commented on July 28, 2024

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.

maximillion90 avatar maximillion90 commented on July 28, 2024

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.

mgeier avatar mgeier commented on July 28, 2024

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.

maximillion90 avatar maximillion90 commented on July 28, 2024

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.

mgeier avatar mgeier commented on July 28, 2024

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.

maximillion90 avatar maximillion90 commented on July 28, 2024

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.

mgeier avatar mgeier commented on July 28, 2024

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.

mgeier avatar mgeier commented on July 28, 2024

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.

maximillion90 avatar maximillion90 commented on July 28, 2024

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.

mgeier avatar mgeier commented on July 28, 2024

Thanks for testing this!

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.