-
Notifications
You must be signed in to change notification settings - Fork 0
Audio
Test sound: espeak hello
- sound card device drivers API
- Advanced Linux Sound Architecture - ALSA
- Open Sound System - OSS
- sound devices API (sound server), allowing mixing
- Pulse
- JACK: real-time, low-latency connections (you'll neeed a real-tipe kernel)
To listed sound devices, including: - embeded soundcard (here Intel) - USB microphone (here, Yeti) - external soundcard (here, AudioEngine)
sudo lshw -class multimedia
[sudo] password for topi: *-usb:0 description: Audio device product: Yeti Stereo Microphone physical id: 3 *-usb:0 description: Audio device product: Audioengine HD3 physical id: 2 *-multimedia description: Audio device product: Sunrise Point-LP HD Audio physical id: 1f.3
ALSA: Advanced Linux Sound Architecture, API for sound card device drivers The sound servers PulseAudio work on top of ALSA and implements sound card device drivers.
General:
- restart:
sudo alsa force-reload
- play file:
aplay <FILE>
- sound level control:
alsamixer
- get driver
vi /proc/asound/oss/sndstat
General:
- GUI
- control levels: pavucontrol (Playback tab: mute a window, change sink..)
- config file are:
- system-wide:
/etc/pulse/default.pa
- user:
~/.config/pulse/default.pa
- system-wide:
General:
- check if running:
pulseaudio --check
- show logs:
pulseaudio --verbose
(-v) - stop :
pulseaudio --kill
(-k) - restart:
- as service:
systemctl --user restart pulseaudio.service
- as dameon:
pulseaudio --daemon
(-D)
- as service:
- if problem persists, consider ALSA
Glossary:
- input hardware device (eg. microphone) is called a source
- output hardware device (eg. loudspeaker) is called a sink
- actual data exchange between application throught Pulse is called a stream
- sink:
pacmd list-sink-inputs
pactl list short sinks
- sources:
pacmd list-sink-sources
pactl list short sources
- ingoing (sink) streams
-
list-sink-inputs
-
pactl list short sinks
output
1 alsa_output.usb-Audioengine_Audioengine_HD3_B40020170802-00.iec958-stereo module-alsa-card.c s16le 2ch 48000Hz IDLE 2 alsa_output.usb-Blue_Microphones_Yeti_Stereo_Microphone_797_2019_09_27_71466-00.iec958-stereo module-alsa-card.c s16le 2ch 48000Hz IDLE 3 alsa_output.pci-0000_00_1f.3.analog-stereo module-alsa-card.c s16le 2ch 48000Hz IDLE
Sample of pactl list short sources
1 alsa_output.usb-Audioengine_Audioengine_HD3_B40020170802-00.iec958-stereo.monitor module-alsa-card.c s16le 2ch 48000Hz RUNNING 2 alsa_output.usb-Blue_Microphones_Yeti_Stereo_Microphone_797_2019_09_27_71466-00.iec958-stereo.monitor module-alsa-card.c s16le 2ch 48000Hz RUNNING
From here
List:
- get:
pactl list short source
- set default for current session (lost at reboot):
pactl set-default-source'<SOURCE_NAME>'
List:
- set default for current session (lost at reboot):
pactl set-default-sink '<SINK_NUMBER>'
List:
- default sink:
pacmd info | grep 'Default sink'
- default source:
pacmd info | grep 'Default source'
Set default for current session (lost at reboot):
- source:
pactl set-default-source <SOURCE_NUMBER>
- sink:
pactl set-default-sink '<SINK_NUMBER>'
Application "Pulse Audio Volume Control" (pavucontrol
:)
- default: section Output, check "Fallback"
- current application: section "Playback"
Edit system-wide pulse configuration sudo vi /etc/pulse/default.pa
Uncomment the following lines
### Make some devices default #set-default-sink output #set-default-source input
Replace output/input by their values
### Make some devices default set-default-sink 1 set-default-source 2
Delete user pulse config rm -rf ~/.config/pulse
Reboot
General:
- list modules:
pactl list short modules
- load module:
pactl load-module <MODULE_NAME>
- unload module:
pactl unload-module <MODULE_NAME>
- loopback (hear your voice):
pactl load-module module-loopback latency_msec=1
Use aplay --list-devices
(Alsa play)
aplay --list-devices **** List of PLAYBACK Hardware Devices **** card 0: HD3 [Audioengine HD3], device 0: USB Audio [USB Audio] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: Microphone [Yeti Stereo Microphone], device 0: USB Audio [USB Audio] Subdevices: 1/1 Subdevice #0: subdevice #0 card 2: PCH [HDA Intel PCH], device 0: CX8200 Analog [CX8200 Analog]
So we've got:
- an external USB soundcard on card 0, device 0
- a USB microphone on card 1, device 0
- an embedded USB soundcard on card 2, device 0 (you can't guess it from output, but by unplugging everything and running again)
Some soundcard may not work from the start.
Here's an example. For the sake of completeness I include a test.
To play sound file, we'll use ALSA playback tool aplay
We'll tell aplay>
to send the sound to each soundcards trough a <SOUNDCARD>,<DEVICE>
pattern
aplay -Dhw:<SOUNDCARD>,<DEVICE>
, eg aplay -Dhw:0,0
for internal USB
To avoid such hassle, I used environment variable
EXTERNAL_SOUNDCARD=0,0 INTERNAL_SOUNDCARD=2,0
Testing 44Khz standard sample rate
curl https://www.kozco.com/tech/organfinale.wav > organ-13s-44khz.wav aplay -Dhw:$INTERNAL_SOUNDCARD organ-13s-44khz.wav aplay -Dhw:$EXTERNAL_SOUNDCARD organ-13s-44khz.wav
Testing 48kHz sample rate
curl https://www.kozco.com/tech/organfinale.wav > organ-13s-44khz.waw aplay -Dhw:$INTERNAL_SOUNDCARD Piano-7s-48khz.wav aplay -Dhw:$EXTERNAL_SOUNDCARD Piano-7s-48khz.wav
Note: aplay --rate
argument does NOT modify input sample rate. Rather, it overwrite detected sample rate.
From manual
For supported soundfile formats, the sampling rate, bit depth, and so forth can be automatically determined from the soundfile header.
The detected sample is displayed while playing, here 48Khz
Playing WAVE 'Piano-7s-48khz.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
Check with alsa player
aplay organ-13s-44khz.wav
Check with external player
sudo apt install sox play organ-13s-44khz.wav
Check on browser (Firefox / Chrome / Chromium behaviour vary)
- local file https://29a.ch/timestretch/
- remote file https://www.youtube.com/watch?v=0HrHuLa7y1E