0

I currently have 2 audio codecs suitable for input and I want to record from them at the same time and not sequentially.

This is how I see my devices:

import sounddevice as sd
sd.querydevices()

output:

< 0 DisplayPort, Core Audio (0 in, 2 out)
  1 USB AUDIO  CODEC, Core Audio (0 in, 2 out)
  2 USB AUDIO  CODEC, Core Audio (2 in, 0 out)
  3 USB AUDIO  CODEC, Core Audio (0 in, 2 out)
> 4 USB AUDIO  CODEC, Core Audio (2 in, 0 out)
  5 USB Advanced Audio Device, Core Audio (0 in, 2 out)
  6 USB Advanced Audio Device, Core Audio (1 in, 0 out)
  7 MacBook Pro Microphone, Core Audio (1 in, 0 out)
  8 MacBook Pro Speakers, Core Audio (0 in, 2 out)

Currently I can only record from one device at a time. The input audio devices above are 2 and 4, with 4 selected as the default and noted by the carat '>'.

Now I know how to record on the default channel for 4 seconds:

recording = sd.rec(int(4 * 44100), samplerate=44100, channels=1)

I also know how to change the default channel, for example setting it to 2:

sd.default.device = [2,0]   

What I would like to do is simultaneously record from channels [4,0] and [2,0] at the same time.

user391339
  • 8,355
  • 13
  • 58
  • 71

1 Answers1

0
sounddevice.rec(frames=None, samplerate=None, channels=None, dtype=None, out=None, mapping=None, blocking=False, **kwargs)
#Record audio data into a NumPy array.

This is a convenience function for interactive use and for small scripts. This function does the following steps internally:

  • Call stop() to terminate any currently running invocation of play(), rec() and playrec().
  • Create an InputStream and a callback function for taking care of the actual recording.
  • Start the stream.
  • If blocking=True was given, wait until recording is done. If not, return immediately.

If you need more control (e.g. block-wise gapless recording, overlapping recordings, …), you should explicitly create an InputStream yourself

So maybe solution is to create another InputSream

xana
  • 499
  • 3
  • 13