如何使用 python pyaudio 或 sounddevice 访问以上 2 个输入通道?

发布于 2025-01-17 07:04:48 字数 980 浏览 1 评论 0原文

我已经在Python和Pyaudio和Sounddevice上建造了录音机。我可以成功记录音频输入并将其写入.wav文件。

我现在正在尝试在音频接口上访问其他频道。在文档,论坛等中没有任何位置。我可以找到如何录制接口频道3,4,5,6等...,我似乎只能记录频道1。在这里我现有代码,有人可以指出我朝正确的方向?

sounddevice:

录制= sounddevice.rec(int(持续时间*采样),采样=采样,频道= 1,device_info [“ name”]);

sounddevice.wait() /code>

pyaudio:

frame_rate,input = true,frames_per_buffer = frame_per_buffer,input_dep_device_index = input_index = input_index)

stream = audio.open(格式= pyaudio.paint16,channels = 1,rate =

这是

ACTIVE DEVICES:
  0 BlackHole 16ch, Core Audio (16 in, 16 out)
> 1 MacBook Pro Microphone, Core Audio (1 in, 0 out)
< 2 MacBook Pro Speakers, Core Audio (0 in, 2 out)
  3 eqMac, Core Audio (2 in, 2 out)
  4 MicChannel3, Core Audio (3 in, 4 out)

我选择设备1时的音频输入,而输入通道1,我会得到声音!我将4设置为MAC聚合设备,其中输入3 = MacBook Pro麦克风,而前2个输入为空。当我选择设备4,输入通道3时,我的音频文件没有声音。我认为两个库的“频道”参数是单声道与立体声,而不是要记录的通道。

I have built audio recorders in python with both pyaudio and sounddevice. I can successfully record audio input and write it to a .wav file.

I am now trying to access other channels on my audio interface. No where in documentation, forums, etc.. can I find how to record an interfaces channel 3,4,5,6, etc..., I can only seem to record channel 1. Here i my existing code, can someone point me in the right direction?

Sounddevice:

recording = sounddevice.rec(int(duration*samplerate), samplerate=samplerate, channels=1, device=device_info["name"]);

sounddevice.wait();

Pyaudio:

stream = audio.open(format=pyaudio.paInt16, channels=1, rate=frame_rate, input=True, frames_per_buffer=frame_per_buffer, input_device_index=input_index);

Additional Details

Here are my audio inputs

ACTIVE DEVICES:
  0 BlackHole 16ch, Core Audio (16 in, 16 out)
> 1 MacBook Pro Microphone, Core Audio (1 in, 0 out)
< 2 MacBook Pro Speakers, Core Audio (0 in, 2 out)
  3 eqMac, Core Audio (2 in, 2 out)
  4 MicChannel3, Core Audio (3 in, 4 out)

When i select device 1, and input channel 1, i get sound! I set up 4 as a Mac Aggregate Device, where input 3 = Macbook Pro Microphone, and the first 2 inputs are empty. When i select device 4, input channel 3, i get no sound in my audio file. I think the "Channel" parameter for both libraries is mono vs stereo, not which channel to record.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寂寞笑我太脆弱 2025-01-24 07:04:48

看来您当前的活动设备(1 个 MacBook Pro 麦克风、Core Audio(1 输入、0 输出))仅支持一个输入通道。

例如,在我的例子中,如果我从下面的列表中选择( 7 Clarett 2Pre USB: Audio (hw:1,0), ALSA (12 in, 4 out) )作为输入设备,那么我最多可以指定 12 个输入通道。

0 HDA Intel PCH: ALC887-VD Analog (hw:0,0), ALSA (2 in, 2 out)
   1 HDA Intel PCH: ALC887-VD Alt Analog (hw:0,2), ALSA (2 in, 0 out)
   2 HDA Intel PCH: HDMI 0 (hw:0,3), ALSA (0 in, 2 out)
   3 HDA Intel PCH: HDMI 1 (hw:0,7), ALSA (0 in, 8 out)
   4 HDA Intel PCH: HDMI 2 (hw:0,8), ALSA (0 in, 8 out)
   5 HDA Intel PCH: HDMI 3 (hw:0,9), ALSA (0 in, 8 out)
   6 HDA Intel PCH: HDMI 4 (hw:0,10), ALSA (0 in, 8 out)
   7 Clarett 2Pre USB: Audio (hw:1,0), ALSA (12 in, 4 out)

您必须选择其他设备或向计算机添加音频接口。

It seams that your current active device (1 MacBook Pro Microphone, Core Audio (1 in, 0 out) ) supports only one input channel.

For example in my case if I select as input device the ( 7 Clarett 2Pre USB: Audio (hw:1,0), ALSA (12 in, 4 out) ) from the list below, then I can specify at most 12 input channels.

0 HDA Intel PCH: ALC887-VD Analog (hw:0,0), ALSA (2 in, 2 out)
   1 HDA Intel PCH: ALC887-VD Alt Analog (hw:0,2), ALSA (2 in, 0 out)
   2 HDA Intel PCH: HDMI 0 (hw:0,3), ALSA (0 in, 2 out)
   3 HDA Intel PCH: HDMI 1 (hw:0,7), ALSA (0 in, 8 out)
   4 HDA Intel PCH: HDMI 2 (hw:0,8), ALSA (0 in, 8 out)
   5 HDA Intel PCH: HDMI 3 (hw:0,9), ALSA (0 in, 8 out)
   6 HDA Intel PCH: HDMI 4 (hw:0,10), ALSA (0 in, 8 out)
   7 Clarett 2Pre USB: Audio (hw:1,0), ALSA (12 in, 4 out)

You have to select another device or add an audio interface to your computer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文