spatialaudio / python-sounddevice

:sound: Play and Record Sound with Python :snake:
https://python-sounddevice.readthedocs.io/
MIT License
1.05k stars 149 forks source link

Cannot get aggregate device to work with sounddevice/rtmixer signal processing.py example #506

Open russellchung opened 11 months ago

russellchung commented 11 months ago

I am new to sound device and rtmixer, I have the following aggregate device (2 USB mic +Apple EarPods built-in mic) in MacOSX:

Available Input Devices: {'name': 'Aggregate Device', 'index': 6, 'hostapi': 0, 'max_input_channels': 4, 'max_output_channels': 0, ....,default_samplerate': 48000.0} Available Output Devices: {'name': 'Built-in Output', 'index': 1, 'hostapi': 0, 'max_input_channels': 0, 'max_output_channels': 2, ..., 'default_samplerate': 48000.0}

I can get the live plot mic.py to work (despite the fact that the built-in microphone really have one channel instead of two) but not the signal processing example to work. My declaration for the class is as follow:

stream = rtmixer.MixerAndRecorder( device=[6,1], channels=[4,2], blocksize=0, latency=latency, samplerate=samplerate)

I am wondering if my mistakes is on the queue or the stream class is not declared properly or the device/channels not declared correctly ? Thank you for any input and help!

mgeier commented 11 months ago

What exactly is going wrong? Are you getting error/warning messages?

I don't have a lot of experience with aggregate devices, so I don't know if that will work, but why don't you add your output to the aggregate device as well?

And if all else fails, you can try to use separate Mixer and Recorder objects. You could then call play_ringbuffer() on one and record_ringbuffer() on the other. I guess the rest of the signal processing example could stay the same.

the built-in microphone really have one channel instead of two

This is interesting, but it is not under my control. Either the aggregate device creates one more channel than necessary or the PortAudio library does that.