如何使用 python pyaudio 或 sounddevice 访问以上 2 个输入通道?
我已经在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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来您当前的活动设备(1 个 MacBook Pro 麦克风、Core Audio(1 输入、0 输出))仅支持一个输入通道。
例如,在我的例子中,如果我从下面的列表中选择( 7 Clarett 2Pre USB: Audio (hw:1,0), ALSA (12 in, 4 out) )作为输入设备,那么我最多可以指定 12 个输入通道。
您必须选择其他设备或向计算机添加音频接口。
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.
You have to select another device or add an audio interface to your computer.