简体   繁体   中英

Python Install correct pyaudio

Python 3.6.9 (default, May 23 2020, 00:01:58) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyaudio
>>> audio = pyaudio.PyAudio()
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:869:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:869:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:869:(find_matching_chmap) Found no matching channel map
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused

ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused

ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card

I found this .

First i try:

sudo apt remove bluez-alsa

but no package found to remove.

Second i delete lines /usr/share/alsa/alsa.conf according to this but i still have the errors:

ALSA lib pcm_route.c:869:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:869:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:869:(find_matching_chmap) Found no matching channel map
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused

ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused

ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card

How can i solve the problem?

Is there any module that i must install (with pip3)?

Thanks in advance,

Chris Pappas

Edit: Following this instructions i have decrease the errors.

Now the output is:

Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused

ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused

ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card

Edit 2:

root@chris-Inspiron-3847:/home/chris/Documents/Python# lspci -v
00:00.0 Host bridge: Intel Corporation 4th Gen Core Processor DRAM Controller (rev 06)
    Subsystem: Dell 4th Gen Core Processor DRAM Controller
    Flags: bus master, fast devsel, latency 0
    Capabilities: [e0] Vendor Specific Information: Len=0c <?>
    Kernel driver in use: hsw_uncore

00:01.0 PCI bridge: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor PCI Express x16 Controller (rev 06) (prog-if 00 [Normal decode])
    Flags: bus master, fast devsel, latency 0, IRQ 25
    Bus: primary=00, secondary=01, subordinate=01, sec-latency=0
    I/O behind bridge: 0000e000-0000efff [size=4K]
    Memory behind bridge: f6000000-f70fffff [size=17M]
    Prefetchable memory behind bridge: 00000000e8000000-00000000f1ffffff [size=160M]
    Capabilities: [88] Subsystem: Dell Xeon E3-1200 v3/4th Gen Core Processor PCI Express x16 Controller
    Capabilities: [80] Power Management version 3
    Capabilities: [90] MSI: Enable+ Count=1/1 Maskable- 64bit-
    Capabilities: [a0] Express Root Port (Slot+), MSI 00
    Capabilities: [100] Virtual Channel
    Capabilities: [140] Root Complex Link
    Kernel driver in use: pcieport

00:14.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB xHCI (rev 05) (prog-if 30 [XHCI])
    Subsystem: Dell 8 Series/C220 Series Chipset Family USB xHCI
    Flags: bus master, medium devsel, latency 0, IRQ 29
    Memory at f7300000 (64-bit, non-prefetchable) [size=64K]
    Capabilities: [70] Power Management version 2
    Capabilities: [80] MSI: Enable+ Count=1/8 Maskable- 64bit+
    Kernel driver in use: xhci_hcd

00:16.0 Communication controller: Intel Corporation 8 Series/C220 Series Chipset Family MEI Controller #1 (rev 04)
    Subsystem: Dell 8 Series/C220 Series Chipset Family MEI Controller
    Flags: bus master, fast devsel, latency 0, IRQ 32
    Memory at f731a000 (64-bit, non-prefetchable) [size=16]
    Capabilities: [50] Power Management version 3
    Capabilities: [8c] MSI: Enable+ Count=1/1 Maskable- 64bit+
    Kernel driver in use: mei_me
    Kernel modules: mei_me

00:1a.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #2 (rev 05) (prog-if 20 [EHCI])
    Subsystem: Dell 8 Series/C220 Series Chipset Family USB EHCI
    Flags: bus master, medium devsel, latency 0, IRQ 16
    Memory at f7318000 (32-bit, non-prefetchable) [size=1K]
    Capabilities: [50] Power Management version 2
    Capabilities: [58] Debug port: BAR=1 offset=00a0
    Capabilities: [98] PCI Advanced Features
    Kernel driver in use: ehci-pci

00:1b.0 Audio device: Intel Corporation 8 Series/C220 Series Chipset High Definition Audio Controller (rev 05)
    Subsystem: Dell 8 Series/C220 Series Chipset High Definition Audio Controller
    Flags: bus master, fast devsel, latency 0, IRQ 33
    Memory at f7310000 (64-bit, non-prefetchable) [size=16K]
    Capabilities: [50] Power Management version 2
    Capabilities: [60] MSI: Enable+ Count=1/1 Maskable- 64bit+
    Capabilities: [70] Express Root Complex Integrated Endpoint, MSI 00
    Capabilities: [100] Virtual Channel
    Kernel driver in use: snd_hda_intel
    Kernel modules: snd_hda_intel

00:1c.0 PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #1 (rev d5) (prog-if 00 [Normal decode])
    Flags: bus master, fast devsel, latency 0, IRQ 26
    Bus: primary=00, secondary=02, subordinate=02, sec-latency=0
    I/O behind bridge: 00002000-00002fff [size=4K]
    Memory behind bridge: e0000000-e01fffff [size=2M]
    Prefetchable memory behind bridge: 00000000e0200000-00000000e03fffff [size=2M]
    Capabilities: [40] Express Root Port (Slot+), MSI 00
    Capabilities: [80] MSI: Enable+ Count=1/1 Maskable- 64bit-
    Capabilities: [90] Subsystem: Dell 8 Series/C220 Series Chipset Family PCI Express Root Port
    Capabilities: [a0] Power Management version 3
    Kernel driver in use: pcieport

00:1c.3 PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #4 (rev d5) (prog-if 00 [Normal decode])
    Flags: bus master, fast devsel, latency 0, IRQ 27
    Bus: primary=00, secondary=03, subordinate=03, sec-latency=0
    I/O behind bridge: 0000d000-0000dfff [size=4K]
    Memory behind bridge: f7200000-f72fffff [size=1M]
    Prefetchable memory behind bridge: 00000000f2100000-00000000f21fffff [size=1M]
    Capabilities: [40] Express Root Port (Slot+), MSI 00
    Capabilities: [80] MSI: Enable+ Count=1/1 Maskable- 64bit-
    Capabilities: [90] Subsystem: Dell 8 Series/C220 Series Chipset Family PCI Express Root Port
    Capabilities: [a0] Power Management version 3
    Kernel driver in use: pcieport

00:1c.4 PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #5 (rev d5) (prog-if 00 [Normal decode])
    Flags: bus master, fast devsel, latency 0, IRQ 28
    Bus: primary=00, secondary=04, subordinate=04, sec-latency=0
    I/O behind bridge: [disabled]
    Memory behind bridge: f7100000-f71fffff [size=1M]
    Prefetchable memory behind bridge: [disabled]
    Capabilities: [40] Express Root Port (Slot+), MSI 00
    Capabilities: [80] MSI: Enable+ Count=1/1 Maskable- 64bit-
    Capabilities: [90] Subsystem: Dell 8 Series/C220 Series Chipset Family PCI Express Root Port
    Capabilities: [a0] Power Management version 3
    Kernel driver in use: pcieport

00:1d.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #1 (rev 05) (prog-if 20 [EHCI])
    Subsystem: Dell 8 Series/C220 Series Chipset Family USB EHCI
    Flags: bus master, medium devsel, latency 0, IRQ 23
    Memory at f7317000 (32-bit, non-prefetchable) [size=1K]
    Capabilities: [50] Power Management version 2
    Capabilities: [58] Debug port: BAR=1 offset=00a0
    Capabilities: [98] PCI Advanced Features
    Kernel driver in use: ehci-pci

00:1f.0 ISA bridge: Intel Corporation H81 Express LPC Controller (rev 05)
    Subsystem: Dell H81 Express LPC Controller
    Flags: bus master, medium devsel, latency 0
    Capabilities: [e0] Vendor Specific Information: Len=0c <?>
    Kernel driver in use: lpc_ich
    Kernel modules: lpc_ich

00:1f.2 SATA controller: Intel Corporation 8 Series/C220 Series Chipset Family 6-port SATA Controller 1 [AHCI mode] (rev 05) (prog-if 01 [AHCI 1.0])
    Subsystem: Dell 8 Series/C220 Series Chipset Family 6-port SATA Controller 1 [AHCI mode]
    Flags: bus master, 66MHz, medium devsel, latency 0, IRQ 30
    I/O ports at f070 [size=8]
    I/O ports at f060 [size=4]
    I/O ports at f050 [size=8]
    I/O ports at f040 [size=4]
    I/O ports at f020 [size=32]
    Memory at f7316000 (32-bit, non-prefetchable) [size=2K]
    Capabilities: [80] MSI: Enable+ Count=1/1 Maskable- 64bit-
    Capabilities: [70] Power Management version 3
    Capabilities: [a8] SATA HBA v1.0
    Kernel driver in use: ahci
    Kernel modules: ahci

00:1f.3 SMBus: Intel Corporation 8 Series/C220 Series Chipset Family SMBus Controller (rev 05)
    Subsystem: Dell 8 Series/C220 Series Chipset Family SMBus Controller
    Flags: medium devsel, IRQ 18
    Memory at f7315000 (64-bit, non-prefetchable) [size=256]
    I/O ports at f000 [size=32]
    Kernel driver in use: i801_smbus
    Kernel modules: i2c_i801

01:00.0 VGA compatible controller: NVIDIA Corporation GF119 [GeForce GT 705] (rev a1) (prog-if 00 [VGA controller])
    Subsystem: Dell GF119 [GeForce GT 705]
    Flags: bus master, fast devsel, latency 0, IRQ 34
    Memory at f6000000 (32-bit, non-prefetchable) [size=16M]
    Memory at e8000000 (64-bit, prefetchable) [size=128M]
    Memory at f0000000 (64-bit, prefetchable) [size=32M]
    I/O ports at e000 [size=128]
    Expansion ROM at 000c0000 [virtual] [disabled] [size=128K]
    Capabilities: [60] Power Management version 3
    Capabilities: [68] MSI: Enable+ Count=1/1 Maskable- 64bit+
    Capabilities: [78] Express Endpoint, MSI 00
    Capabilities: [b4] Vendor Specific Information: Len=14 <?>
    Capabilities: [100] Virtual Channel
    Capabilities: [128] Power Budgeting <?>
    Capabilities: [600] Vendor Specific Information: ID=0001 Rev=1 Len=024 <?>
    Kernel driver in use: nvidia
    Kernel modules: nvidiafb, nouveau, nvidia_drm, nvidia

01:00.1 Audio device: NVIDIA Corporation GF119 HDMI Audio Controller (rev a1)
    Subsystem: Dell GF119 HDMI Audio Controller
    Flags: bus master, fast devsel, latency 0, IRQ 17
    Memory at f7080000 (32-bit, non-prefetchable) [size=16K]
    Capabilities: [60] Power Management version 3
    Capabilities: [68] MSI: Enable- Count=1/1 Maskable- 64bit+
    Capabilities: [78] Express Endpoint, MSI 00
    Kernel driver in use: snd_hda_intel
    Kernel modules: snd_hda_intel

03:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 0c)
    Subsystem: Dell RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
    Flags: bus master, fast devsel, latency 0, IRQ 19
    I/O ports at d000 [size=256]
    Memory at f7200000 (64-bit, non-prefetchable) [size=4K]
    Memory at f2100000 (64-bit, prefetchable) [size=16K]
    Capabilities: [40] Power Management version 3
    Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit+
    Capabilities: [70] Express Endpoint, MSI 01
    Capabilities: [b0] MSI-X: Enable+ Count=4 Masked-
    Capabilities: [d0] Vital Product Data
    Capabilities: [100] Advanced Error Reporting
    Capabilities: [140] Virtual Channel
    Capabilities: [160] Device Serial Number 01-00-00-00-68-4c-e0-00
    Capabilities: [170] Latency Tolerance Reporting
    Kernel driver in use: r8169
    Kernel modules: r8169

04:00.0 Network controller: Qualcomm Atheros QCA9565 / AR9565 Wireless Network Adapter (rev 01)
    Subsystem: Dell QCA9565 / AR9565 Wireless Network Adapter
    Flags: bus master, fast devsel, latency 0, IRQ 16
    Memory at f7100000 (64-bit, non-prefetchable) [size=512K]
    Expansion ROM at f7180000 [disabled] [size=64K]
    Capabilities: [40] Power Management version 2
    Capabilities: [50] MSI: Enable- Count=1/4 Maskable+ 64bit+
    Capabilities: [70] Express Endpoint, MSI 00
    Capabilities: [100] Advanced Error Reporting
    Capabilities: [140] Virtual Channel
    Capabilities: [160] Device Serial Number 00-00-00-00-00-00-00-00
    Kernel driver in use: ath9k
    Kernel modules: ath9k


root@chris-Inspiron-3847:/home/chris/Documents/Python# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC662 rev3 Analog [ALC662 rev3 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
root@chris-Inspiron-3847:/home/chris/Documents/Python# 

This solution didn't worked for me.

I installed jackd2. Now the errors are:

ALSA lib pcm_dmix.c:1089:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused

ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused

ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib pcm_dmix.c:1089:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm_dmix.c:1089:(snd_pcm_dmix_open) unable to open slave


root@chris-Inspiron-3847:/home/chris/Documents/Python# lspci -knn|grep -iA2 audio
00:1b.0 Audio device [0403]: Intel Corporation 8 Series/C220 Series Chipset High Definition Audio Controller [8086:8c20] (rev 05)
    Subsystem: Dell 8 Series/C220 Series Chipset High Definition Audio Controller [1028:0622]
    Kernel driver in use: snd_hda_intel
    Kernel modules: snd_hda_intel
--
01:00.1 Audio device [0403]: NVIDIA Corporation GF119 HDMI Audio Controller [10de:0e08] (rev a1)
    Subsystem: Dell GF119 HDMI Audio Controller [1028:109b]
    Kernel driver in use: snd_hda_intel
    Kernel modules: snd_hda_intel




root@chris-Inspiron-3847:/home/chris/Documents/Python# speaker-test -c2

speaker-test 1.2.2

Playback device is default
Stream parameters are 48000Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
ALSA lib pcm_dmix.c:1089:(snd_pcm_dmix_open) unable to open slave
Playback open error: -2,No such file or directory

选择音频设备

Edit : From https://people.csail.mit.edu/hubert/pyaudio/

These binaries include PortAudio v19 v190600_20161030, built with MinGW. They support only the Windows MME API and do not include support for DirectX, ASIO, etc. If you require support for APIs not included, you will need to compile PortAudio and PyAudio.

Is there something i must change in configuration file?

https://www.alsa-project.org/wiki/Asoundrc

I tried: jackd -R -d alsa -d hw:0,3 and I have only two warings!!!

ALSA lib pcm_dsnoop.c:641:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1089:(snd_pcm_dmix_open) unable to open slave

Now, using: How to play an audiofile with pyaudio? no sound is hearing.

Note: After rebooting the pc, the error messages displayed again. I have to run jackd -R -d alsa i think to operate it again.

root@chris-Inspiron-3847:/home/chris/Documents/Python# sudo lshw -c multimedia
  *-multimedia              
       description: Audio device
       product: GF119 HDMI Audio Controller
       vendor: NVIDIA Corporation
       physical id: 0.1
       bus info: pci@0000:01:00.1
       version: a1
       width: 32 bits
       clock: 33MHz
       capabilities: pm msi pciexpress bus_master cap_list
       configuration: driver=snd_hda_intel latency=0
       resources: irq:17 memory:f7080000-f7083fff
  *-multimedia
       description: Audio device
       product: 8 Series/C220 Series Chipset High Definition Audio Controller
       vendor: Intel Corporation
       physical id: 1b
       bus info: pci@0000:00:1b.0
       version: 05
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress bus_master cap_list
       configuration: driver=snd_hda_intel latency=0
       resources: irq:33 memory:f7310000-f7313fff

Commented again the three lines (see above) in the configuration file clear's the errors-warnings.

When i use first example from: https://people.csail.mit.edu/hubert/pyaudio/docs/ nothing is hearing.

I made but only one time. I copy one file ( see here ) After reboot no sound in output device.

root@chris-Inspiron-3847:/home/chris# cat /proc/asound/cards
 0 [NVidia         ]: HDA-Intel - HDA NVidia
                      HDA NVidia at 0xf7080000 irq 17
 1 [PCH            ]: HDA-Intel - HDA Intel PCH
                      HDA Intel PCH at 0xf7310000 irq 33

Ok now i can listen sounds from the sound device.

Here i all i have done:

sudo apt-get purge bluez-alsa (not neccessery)

sudo add-apt-repository ppa:ubuntu-audio-dev/alsa-daily

sudo apt-get update

sudo apt-get dist-upgrade

sudo apt-get install --reinstall dkms linux-image-generic linux-headers-generic linux-tools-generic linux-source alsa-firmware-loaders alsa-base alsa-utils alsa-source alsa-tools python-alsaaudio python-pyalsa

sudo apt-get install libasound-dev

chris@chris-Inspiron-3847:~/Documents/Python$ cat /etc/asound.conf
pcm.!default {
    type hw
    card 1
    device 0
    rate 44100
}

ctl.!default {
    type hw           
    card 0
}

sudo alsactl init

cp "/usr/lib/x86_64-linux-gnu/libstdc++.so.6" "/usr/./libstdc++.so.6" (not necessary i think)

root@chris-Inspiron-3847:/home/chris/Documents/Python# cat /usr/share/alsa/alsa.conf
#
#  ALSA library configuration file
#

# pre-load the configuration files

@hooks [
    {
        func load
        files [
            "/etc/alsa/conf.d"
            "/etc/asound.conf"
            "~/.asoundrc"
        ]
        errors false
    }
]

# load card-specific configuration files (on request)

cards.@hooks [
    {
        func load
        files [
            {
                @func concat
                strings [
                    { @func datadir }
                    "/cards/aliases.conf"
                ]
            }
        ]
    }
    {
        func load_for_all_cards
        files [
            {
                @func concat
                strings [
                    { @func datadir }
                    "/cards/"
                    { @func private_string }
                    ".conf"
                ]
            }
        ]
        errors false
    }
]

#
# defaults
#

# show all name hints also for definitions without hint {} section
defaults.namehint.showall on
# show just basic name hints
defaults.namehint.basic on
# show extended name hints
defaults.namehint.extended on
#
#defaults.ctl.card 0
#defaults.pcm.card 0
defaults.pcm.device 0
defaults.pcm.subdevice -1
defaults.pcm.nonblock 1
defaults.pcm.compat 0
defaults.pcm.minperiodtime 5000     # in us
defaults.pcm.ipc_key 5678293
defaults.pcm.ipc_gid audio
defaults.pcm.ipc_perm 0660
defaults.pcm.dmix.max_periods 0
defaults.pcm.dmix.channels 2
defaults.pcm.dmix.rate 48000
defaults.pcm.dmix.format "unchanged"
defaults.pcm.dmix.card defaults.pcm.card
defaults.pcm.dmix.device defaults.pcm.device
defaults.pcm.dsnoop.card defaults.pcm.card
defaults.pcm.dsnoop.device defaults.pcm.device
defaults.pcm.front.card defaults.pcm.card
defaults.pcm.front.device defaults.pcm.device
defaults.pcm.rear.card defaults.pcm.card
defaults.pcm.rear.device defaults.pcm.device
defaults.pcm.center_lfe.card defaults.pcm.card
defaults.pcm.center_lfe.device defaults.pcm.device
defaults.pcm.side.card defaults.pcm.card
defaults.pcm.side.device defaults.pcm.device
defaults.pcm.surround21.card defaults.pcm.card
defaults.pcm.surround21.device defaults.pcm.device
defaults.pcm.surround40.card defaults.pcm.card
defaults.pcm.surround40.device defaults.pcm.device
defaults.pcm.surround41.card defaults.pcm.card
defaults.pcm.surround41.device defaults.pcm.device
defaults.pcm.surround50.card defaults.pcm.card
defaults.pcm.surround50.device defaults.pcm.device
defaults.pcm.surround51.card defaults.pcm.card
defaults.pcm.surround51.device defaults.pcm.device
defaults.pcm.surround71.card defaults.pcm.card
defaults.pcm.surround71.device defaults.pcm.device
defaults.pcm.iec958.card defaults.pcm.card
defaults.pcm.iec958.device defaults.pcm.device
defaults.pcm.modem.card defaults.pcm.card
defaults.pcm.modem.device defaults.pcm.device
# truncate files via file or tee PCM
defaults.pcm.file_format    "raw"
defaults.pcm.file_truncate  true
defaults.rawmidi.card 0
defaults.rawmidi.device 0
defaults.rawmidi.subdevice -1
defaults.hwdep.card 0
defaults.hwdep.device 0
defaults.timer.class 2
defaults.timer.sclass 0
defaults.timer.card 0
defaults.timer.device 0
defaults.timer.subdevice 0

#
#  PCM interface
#

# redirect to load-on-demand extended pcm definitions
pcm.cards cards.pcm

pcm.default cards.pcm.default
pcm.sysdefault cards.pcm.default
pcm.front cards.pcm.front
#pcm.rear cards.pcm.rear
#pcm.center_lfe cards.pcm.center_lfe
#pcm.side cards.pcm.side
pcm.surround21 cards.pcm.surround21
pcm.surround40 cards.pcm.surround40
pcm.surround41 cards.pcm.surround41
pcm.surround50 cards.pcm.surround50
pcm.surround51 cards.pcm.surround51
pcm.surround71 cards.pcm.surround71
pcm.iec958 cards.pcm.iec958
pcm.spdif iec958
pcm.hdmi cards.pcm.hdmi
pcm.dmix cards.pcm.dmix
pcm.dsnoop cards.pcm.dsnoop
pcm.modem cards.pcm.modem
pcm.phoneline cards.pcm.phoneline

pcm.hw {
    @args [ CARD DEV SUBDEV ]
    @args.CARD {
        type string
        default {
            @func getenv
            vars [
                ALSA_PCM_CARD
                ALSA_CARD
            ]
            default {
                @func refer
                name defaults.pcm.card
            }
        }
    }
    @args.DEV {
        type integer
        default {
            @func igetenv
            vars [
                ALSA_PCM_DEVICE
            ]
            default {
                @func refer
                name defaults.pcm.device
            }
        }
    }
    @args.SUBDEV {
        type integer
        default {
            @func refer
            name defaults.pcm.subdevice
        }
    }       
    type hw
    card $CARD
    device $DEV
    subdevice $SUBDEV
    hint {
        show {
            @func refer
            name defaults.namehint.extended
        }
        description "Direct hardware device without any conversions"
    }
}

pcm.plughw {
    @args [ CARD DEV SUBDEV ]
    @args.CARD {
        type string
        default {
            @func getenv
            vars [
                ALSA_PCM_CARD
                ALSA_CARD
            ]
            default {
                @func refer
                name defaults.pcm.card
            }
        }
    }
    @args.DEV {
        type integer
        default {
            @func igetenv
            vars [
                ALSA_PCM_DEVICE
            ]
            default {
                @func refer
                name defaults.pcm.device
            }
        }
    }
    @args.SUBDEV {
        type integer
        default {
            @func refer
            name defaults.pcm.subdevice
        }
    }       
    type plug
    slave.pcm {
        type hw
        card $CARD
        device $DEV
        subdevice $SUBDEV
    }
    hint {
        show {
            @func refer
            name defaults.namehint.extended
        }
        description "Hardware device with all software conversions"
    }
}

pcm.plug {
    @args [ SLAVE ]
    @args.SLAVE {
        type string
    }
    type plug
    slave.pcm $SLAVE
}

pcm.shm {
    @args [ SOCKET PCM ]
    @args.SOCKET {
        type string
    }
    @args.PCM {
        type string
    }
    type shm
    server $SOCKET
    pcm $PCM
}

pcm.tee {
    @args [ SLAVE FILE FORMAT ]
    @args.SLAVE {
        type string
    }
    @args.FILE {
        type string
    }
    @args.FORMAT {
        type string
        default {
            @func refer
            name defaults.pcm.file_format
        }
    }
    type file
    slave.pcm $SLAVE
    file $FILE
    format $FORMAT
    truncate {
        @func refer
        name defaults.pcm.file_truncate
    }
}

pcm.file {
    @args [ FILE FORMAT ]
    @args.FILE {
        type string
    }
    @args.FORMAT {
        type string
        default {
            @func refer
            name defaults.pcm.file_format
        }
    }
    type file
    slave.pcm null
    file $FILE
    format $FORMAT
    truncate {
        @func refer
        name defaults.pcm.file_truncate
    }
}

pcm.null {
    type null
    hint {
        show {
            @func refer
            name defaults.namehint.basic
        }
        description "Discard all samples (playback) or generate zero samples (capture)"
    }
}

#
#  Control interface
#

ctl.sysdefault {
    type hw
    card {
        @func getenv
        vars [
            ALSA_CTL_CARD
            ALSA_CARD
        ]
        default {
            @func refer
            name defaults.ctl.card
        }
    }
    hint.description "Default control device"
}
ctl.default ctl.sysdefault

ctl.hw {
    @args [ CARD ]
    @args.CARD {
        type string
        default {
            @func getenv
            vars [
                ALSA_CTL_CARD
                ALSA_CARD
            ]
            default {
                @func refer
                name defaults.ctl.card
            }
        }
    }
    type hw
    card $CARD
    hint.description "Direct control device"
}

ctl.shm {
    @args [ SOCKET CTL ]
    @args.SOCKET {
        type string
    }
    @args.CTL {
        type string
    }
    type shm
    server $SOCKET
    ctl $CTL
}

#
#  RawMidi interface
#

rawmidi.default {
    type hw
    card {
        @func getenv
        vars [
            ALSA_RAWMIDI_CARD
            ALSA_CARD
        ]
        default {
            @func refer
            name defaults.rawmidi.card
        }
    }
    device {
        @func igetenv
        vars [
            ALSA_RAWMIDI_DEVICE
        ]
        default {
            @func refer
            name defaults.rawmidi.device
        }
    }
    hint.description "Default raw MIDI device"
}

rawmidi.hw {
    @args [ CARD DEV SUBDEV ]
    @args.CARD {
        type string
        default {
            @func getenv
            vars [
                ALSA_RAWMIDI_CARD
                ALSA_CARD
            ]
            default {
                @func refer
                name defaults.rawmidi.card
            }
        }
    }
    @args.DEV {
        type integer
        default {
            @func igetenv
            vars [
                ALSA_RAWMIDI_DEVICE
            ]
            default {
                @func refer
                name defaults.rawmidi.device
            }
        }
    }
    @args.SUBDEV {
        type integer
        default -1
    }
    type hw
    card $CARD
    device $DEV
    subdevice $SUBDEV
    hint {
        description "Direct rawmidi driver device"
        device $DEV
    }
}

rawmidi.virtual {
    @args [ MERGE ]
    @args.MERGE {
        type string
        default 1
    }
    type virtual
    merge $MERGE
}

#
#  Sequencer interface
#

seq.default {
    type hw
    hint.description "Default sequencer device"
}

seq.hw {
    type hw
}

#
#  HwDep interface
#

hwdep.default {
    type hw
    card {
        @func getenv
        vars [
            ALSA_HWDEP_CARD
            ALSA_CARD
        ]
        default {
            @func refer
            name defaults.hwdep.card
        }
    }
    device {
        @func igetenv
        vars [
            ALSA_HWDEP_DEVICE
        ]
        default {
            @func refer
            name defaults.hwdep.device
        }
    }
    hint.description "Default hardware dependent device"
}

hwdep.hw {
    @args [ CARD DEV ]
    @args.CARD {
        type string
        default {
            @func getenv
            vars [
                ALSA_HWDEP_CARD
                ALSA_CARD
            ]
            default {
                @func refer
                name defaults.hwdep.card
            }
        }
    }
    @args.DEV {
        type integer
        default {
            @func igetenv
            vars [
                ALSA_HWDEP_DEVICE
            ]
            default {
                @func refer
                name defaults.hwdep.device
            }
        }
    }
    type hw
    card $CARD
    device $DEV
    hint {
        description "Direct hardware dependent device"
        device $DEV
    }
}

#
#  Timer interface
#

timer_query.default {
    type hw
}

timer_query.hw {
    type hw
}

timer.default {
    type hw
    class {
        @func refer
        name defaults.timer.class
    }
    sclass {
        @func refer
        name defaults.timer.sclass
    }
    card {
        @func refer
        name defaults.timer.card
    }
    device {
        @func refer
        name defaults.timer.device
    }
    subdevice {
        @func refer
        name defaults.timer.subdevice
    }
    hint.description "Default timer device"
}

timer.hw {
    @args [ CLASS SCLASS CARD DEV SUBDEV ]
    @args.CLASS {
        type integer
        default {
            @func refer
            name defaults.timer.class
        }
    }
    @args.SCLASS {
        type integer
        default {
            @func refer
            name defaults.timer.sclass
        }
    }
    @args.CARD {
        type string
        default {
            @func refer
            name defaults.timer.card
        }
    }
    @args.DEV {
        type integer
        default {
            @func refer
            name defaults.timer.device
        }
    }
    @args.SUBDEV {
        type integer
        default {
            @func refer
            name defaults.timer.subdevice
        }
    }
    type hw
    class $CLASS
    sclass $SCLASS
    card $CARD
    device $DEV
    subdevice $SUBDEV
    hint {
        description "Direct timer device"
        device $DEV
    }
}

Two last commands

root@chris-Inspiron-3847:/home/chris/Documents/Python# cat /etc/modprobe.d/default.conf
options snd_hda_intel index=1

jackd -d alsa -d hw:0,3 -r 44100

And then i restart the computer.

After that when i run the fist example from: https://people.csail.mit.edu/hubert/pyaudio/docs/ the output:

chris@chris-Inspiron-3847:~/Documents/Python$ python3.6 play_sound.py ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.pcm.card' ALSA lib conf.c:4693:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory...(other errors - warnings

but now i can hear sound!

Pff, i can hear sound from microphone (and also sound device).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM