0

我想在树莓派 4B 上运行 USB 声卡

首先我检测到了sonddevice:

import sounddevice

devs = sounddevice.query_devices()
print(devs) # Shows current output and input as well with "<" abd ">" tokens
    
for dev in devs:
    print(dev['name'])


* 0 USB Audio Device: - (hw:2,0), ALSA (1 in, 2 out)
  1 dmix, ALSA (0 in, 2 out)
USB Audio Device: - (hw:2,0)
dmix

设置后,我将设备放入混音器设置中

pygame.mixer.init(44100, -16, 2, 512, "USB Audio Device: - (hw:2,0), ALSA (1 in, 2 out)")
pygame.init()

我有

pygame.error: No such device.

然后我找到了另一种检测设备的方法:

import pygame
import pygame._sdl2 as sdl2

pygame.init()
is_capture = 0  # zero to request playback devices, non-zero to request recording devices
num = sdl2.get_num_audio_devices(is_capture)
names = [str(sdl2.get_audio_device_name(i, is_capture), encoding="utf-8") for i in range(num)]
print("\n".join(names))
pygame.quit()

并得到

Traceback (most recent call last):
  File "/home/pi/Brennofen/soundevice.py", line 8, in <module>
    num = sdl2.get_num_audio_devices(is_capture)
  File "src_c/cython/pygame/_sdl2/audio.pyx", line 56, in pygame._sdl2.audio.get_num_audio_devices
pygame._sdl2.sdl2.error: Audio system not initialised

我在哪里可以开始解决这个问题?

4

0 回答 0