Linux Hardware Audio - mastakira/notes GitHub Wiki

TABLE OF CONTENT

  • Audio
    • Alsa
    • Pulseaudio
    • Network
  • Monitor output
  • Mic
    • Recording
  • Monitor input
  • Visualise audio
    • Glava

| = = = = = = = = = = = = = = = = = = = |

A U D I O

You'll need to configure alsa but pulseaudio is the way to go if you want kde to connect, steam link, etc. So after installing both alsa and pulseaudio start configure pulseaudio, assuming the audio in and out works properly.


A L S A

Install

$ sudo pacman -S alsa-utils 

Start, Go to master bring up the sound levels.

$ alsamixer 

Change -c to fit your speaker setup. Use -c 8 for 7.1, for instance:

$ speaker-test -c 2 
Depricated 
---
	$ sudo pacman -S asoundconf -> Utility to read and change the user's ALSA library configuration
	$ asoundconf list -> List devices
	$ asoundconf set-default-card _Parameter_ -> Set the default card 
$ aplay -L | grep :CARD

AUDIO / MIC / AUX IN

TEST

$ arecord -l -> list capture device 
$ arecord --duration=5 --format=dat test-mic.wav
$ aplay test-mic.wav

Listen to device

$ amixer set Master toggle -> Mute Toggle
$ amixer set Master 5%+ -> Increse volume
$ amixer set Master 5%- -> Decrease volume

PROBLEM SOLVING

First, check that all dependencies are installed. There might be a permission problem.

$ sudo chown -R $USER $HOME

BACKUP /etc/pulse/default.pa


P U L S E A U D I O

Will take exclusive control over your sound https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Modules/

Installation

CLI tool

$ pacman -S pamixer 

Mpris media player controller and lib for spotify, vlc, audacious, bmp, xmms2, and others

$ pacman -S playerctl 

GUI tool

$ pacman -S pavucontrol-qt

System-tray and mixer

no $ pacman -S kmix

Audio effects

$ pacman -S pulseeffects

N E T W O R K

Arch Wki / Pulse Audio

$ load-module module-native-protocol-tcp

| = = = = = = = = = = = = = = = = = = = |

M I C R O P H O N E

Recording ro-che / record-audio-linux

Setup The GUI paprefs tried to combine one HDMI with one analog output, instead of both hdmi. So I had to edit the file as described by Léo Léopold Hertz 준영

$ gedit /etc/pulse/default.pa

Then after changes

$ pulseaudio -k

Both these methods work on their own, so pick one (make sure to add to the top of the file, I put it right after .fail ! Otherwise it doesn't work).

Method A)

load-module module-alsa-sink device=hw:1,3 sink_name=hdmi
load-module module-alsa-sink device=hw:1,7 sink_name=hdmi2
load-module module-combine-sink sink_name=combined slaves=hdmi,hdmi2
set-default-sink hdmi-combined

Method B)

load-module module-alsa-sink device=hw:0,0
load-module module-combine-sink sink_name=combined
  Reference Method A
  For reference, the hw:0,0 comes from aplay -l
  ---
  $ aplay -l
  **** List of PLAYBACK Hardware Devices ****
  card 0: PCH [HDA Intel PCH], device 0: ALC892 Analog [ALC892 Analog]
  	Subdevices: 1/1
  	Subdevice #0: subdevice #0
  card 0: PCH [HDA Intel PCH], device 1: ALC892 Digital [ALC892 Digital]
  	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
  card 1: NVidia [HDA NVidia], device 8: HDMI 2 [HDMI 2]
  	Subdevices: 1/1
  	Subdevice #0: subdevice #0
  card 1: NVidia [HDA NVidia], device 9: HDMI 3 [HDMI 3]
  	Subdevices: 1/1
  	Subdevice #0: subdevice #0

Reference Method B

And the 1:3 comes from

$ pacmd list-sinks | grep -e 'name:' -e 'alsa.device ' -e 'alsa.subdevice '
	name: <alsa_output.pci-0000_00_1b.0.iec958-stereo>
			alsa.subdevice = "0"
			alsa.device = "1"
	name: <alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1>
			alsa.subdevice = "0"
			alsa.device = "7"

On the "sound settings" I set the other HDMI as output and then got

$ pacmd list-sinks | grep -e 'name:' -e 'alsa.device ' -e 'alsa.subdevice '
	name: <alsa_output.pci-0000_00_1b.0.iec958-stereo>
			alsa.subdevice = "0"
			alsa.device = "1"
	name: <alsa_output.pci-0000_01_00.1.hdmi-stereo>
			alsa.subdevice = "0"
			alsa.device = "3"

To verify, I ran

$ aplay -D plughw:1,3 /usr/share/sounds/alsa/Front_Right.wav
$ aplay -D plughw:1,7 /usr/share/sounds/alsa/Front_Right.wav

which sounded on their respective monitors.

$ cat /proc/asound/cards

defaults.ctl.card 1
defaults.pcm.card 1
defaults.pcm.device 3

I tried using pacmd, but list-sinks gives me only the device I'm currently using:

pacmd list-sinks | grep name:
name: <alsa_output.pci-0000_00_1b.0.hdmi-stereo>

After a switch from GUI:

pacmd list-sinks | grep name:
name: <alsa_output.pci-0000_00_1b.0.analog-stereo>

And if I try to change it I get:

pacmd set-default-sink alsa_output.pci-0000_00_1b.0.hdmi-stereo
Welcome to PulseAudio! Use "help" for usage information.
Sink alsa_output.pci-0000_00_1b.0.hdmi-stereo does not exist.

In this case the card is always the same. What is changing between a switch and another is the "card-profile". So the solution which actually worked is:

pacmd set-card-profile <cardindex> <profilename>

In my case I found all the card profiles with:

pacmd list-cards

And after I can switch between monitor and laptop speakers with:

pacmd set-card-profile 0 output:hdmi-stereo

And:

pacmd set-card-profile 0 output:analog-stereo+input:analog-stereo

Where 0 is the index of the card:

pacmd list-cards
Welcome to PulseAudio! Use "help" for usage information.
>>> 1 card(s) available.
		index: 0
		name: <alsa_card.pci-0000_00_1b.0>

And finally, in order to make the switch faster, I set up two alias in my .bashrc file:

alias audio-hdmi='pacmd set-card-profile 0 output:hdmi-stereo+input:analog-stereo'
alias audio-laptop='pacmd set-card-profile 0 output:analog-stereo+input:analog-stereo'

This way I can switch between audio from the monitor or from the laptop (headphones) typing in the shell: audio-hdmi or audio-laptop


List of CAPTURE Hardware Devices

$ arecord -l
$pactl load-module module-loopback latency_msec=1 source=0 sink=0 

Restart pulseaudio

$ pulseaudio -k ; pulseaudio -D 

Listen/monitor input

$ pactl load-module module-loopback -> Loops incoming audio back through your output. Run for each input like Aux and Headset: 
$ pactl unload-module module-loopback -> Unload/Stop running: 

Load this module whenever the system starts:

$ sudo sh -c ' echo "load-module module-loopback" >>  /etc/pulse/default.pa '

OR do it on the user in autostart

$ pactl load-module module-loopback latency_msec=1 source=1 sink=0 &

Autostart line in monitoring

$ pactl load-module module-loopback latency_msec=1 source=1 sink=0 &
$ pactl load-module module-loopback latency_msec=1 source=3 sink=0 &

GLAVA

$ glava -> OpenGL audio spectrum visualizer
$ glava --copy-config -> Copy its default configuration files to your home glava

$ glava --desktop -> Embed audio spectrum on desktop background 
$ glava --desktop --entry=mycustomconfig.glsl <- Run specific 

configuration

$ glava --desktop --force-mod=circle <- nstance that uses the circle visualizer 

Autostart

sh -c 'sleep 10 && glava --desktop' & 

Mic monitoring glsl

$ glava --entry=rc_mic.glsl --force-mod=circle 

Setup

$ pacmd list-sources | grep -E 'index|name:' -> find device grep -E '0|0:' 
finn your output-> alsa_input.hw_0_0
AND / OR 
$ arecord -l -> 
card 0: PCH [HDA Intel PCH], device 0: ALC295 Analog [ALC295 Analog]
	Subdevices: 0/1
	Subdevice #0: subdevice #0
Card 0: device 0: -> alsa_input.hw_0_0

Configure

~/.config/glava
---
rc.glsl

Is it possible to use glava with microphones? /* PulseAudio source. Can be a number or a name of an audio sink or device to record from. Set to "auto" to use the default output device. */

#request setsource "auto" <- alsa_input.hw_0_0

Yes, this is possible. The easiest way is to use the device index, as listed by pacmd list-sources | grep -E 'index|name:'. You can also use the device name (eg. alsa_input.hw_microphone_0 on my system, yours will most likely differ). By default GLava uses a monitor of your default output device. This means any sound you hear from your speakers/headphones will be what GLava displays (barring some niche configurations). I will close this since I assume this should answer your question, but if you would like to request a feature (like detecting the default input device with a flag), then please mention so.

OTHER

#request setgeometry #specify the size of the GLava embedded window, as well as its X and Y offset, so you can set it on the monitor you desire
#request setgeometry 0 0 1920 1080
⚠️ **GitHub.com Fallback** ⚠️