wrek
wrek

Reputation: 1161

What to put for the alsaaudio python card?

I am trying to use alsaaudio in my python code.

inp = alsaaudio.PCM(alsaaudio.PCM_CAPTURE, alsaaudio.PCM_NONBLOCK, card)

For the third parameter card, what should I put?

root@abc:~/Desktop# arecord --list-devices
**** List of CAPTURE Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC269VB Analog [ALC269VB Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 1: H340 [Logitech USB Headset H340], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

I want to input audio from the Logitech USB Headset.
Should it be hw:1,0 ????

Thanks

Upvotes: 1

Views: 733

Answers (1)

CL.
CL.

Reputation: 180020

The documentation says:

class alsaaudio.PCM(type=PCM_PLAYBACK, mode=PCM_NORMAL, device='default', cardindex=-1)

This class is used to represent a PCM device (either for playback and recording). The arguments are:
[…]

  • device - the name of the PCM device that should be used (for example a value from the output of pcms()). The default value is 'default'.

[…]

Changed in 0.8:

  • The card keyword argument is still supported, but deprecated. Please use device instead.
  • The keyword argument cardindex was added.

The card keyword is deprecated because it guesses the real ALSA name of the card. This was always fragile and broke some legitimate usecases.

Upvotes: 2

Related Questions