Audio equalizer

[ion@office ~]$ garuda-inxi
System:
  Kernel: 6.1.22-1-lts arch: x86_64 bits: 64 compiler: gcc v: 12.2.1
    parameters: BOOT_IMAGE=/@/boot/vmlinuz-linux-lts
    root=UUID=e8123a46-1c1f-4e7c-abc1-0f31b5a592f9 rw rootflags=subvol=@
    rd.udev.log_priority=3 vt.global_cursor_default=0 loglevel=3 ibt=off
  Desktop: Xfce v: 4.18.1 tk: Gtk v: 3.24.36 info: xfce4-panel wm: xfwm
    v: 4.18.0 vt: 7 dm: LightDM v: 1.32.0 Distro: Garuda Linux base: Arch Linux
Machine:
  Type: Desktop Mobo: Gigabyte model: B450M DS3H V2 v: x.x
    serial: <superuser required> BIOS: American Megatrends LLC. v: F62
    date: 01/27/2022
CPU:
  Info: model: AMD Ryzen 3 3200G with Radeon Vega Graphics bits: 64 type: MCP
    arch: Zen/Zen+ note: check gen: 1 level: v3 note: check built: 2019
    process: GF 12nm family: 0x17 (23) model-id: 0x18 (24) stepping: 1
    microcode: 0x8108109
  Topology: cpus: 1x cores: 4 smt: <unsupported> cache: L1: 384 KiB
    desc: d-4x32 KiB; i-4x64 KiB L2: 2 MiB desc: 4x512 KiB L3: 4 MiB
    desc: 1x4 MiB
  Speed (MHz): avg: 1914 high: 3600 min/max: 1400/3600 boost: enabled
    scaling: driver: acpi-cpufreq governor: schedutil cores: 1: 3600 2: 1258
    3: 1400 4: 1400 bogomips: 28759
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm
  Vulnerabilities: <filter>
Graphics:
  Device-1: AMD Picasso/Raven 2 [Radeon Vega Series / Radeon Mobile Series]
    vendor: Gigabyte driver: amdgpu v: kernel arch: GCN-5 code: Vega
    process: GF 14nm built: 2017-20 pcie: gen: 3 speed: 8 GT/s lanes: 16
    ports: active: HDMI-A-1 empty: DVI-D-1 bus-ID: 06:00.0 chip-ID: 1002:15d8
    class-ID: 0300 temp: 31.0 C
  Display: x11 server: X.Org v: 21.1.8 compositor: xfwm v: 4.18.0 driver: X:
    loaded: amdgpu unloaded: modesetting alternate: fbdev,vesa dri: radeonsi
    gpu: amdgpu display-ID: :0.0 screens: 1
  Screen-1: 0 s-res: 1280x1024 s-dpi: 96 s-size: 339x271mm (13.35x10.67")
    s-diag: 434mm (17.09")
  Monitor-1: HDMI-A-1 mapped: HDMI-A-0 model: Acer 0x0019 serial: <filter>
    built: 2009 res: 1280x1024 hz: 75 dpi: 8 gamma: 1.2
    size: 4095x4095mm (161.22x161.22") diag: 434mm (17.1") ratio: 5:4, 4:3
    modes: max: 720x480 min: 720x400
  API: OpenGL Message: Unable to show GL data. Required tool glxinfo
    missing.
Audio:
  Device-1: AMD Raven/Raven2/Fenghuang HDMI/DP Audio driver: snd_hda_intel
    v: kernel pcie: gen: 3 speed: 8 GT/s lanes: 16 bus-ID: 06:00.1
    chip-ID: 1002:15de class-ID: 0403
  Device-2: AMD Family 17h/19h HD Audio vendor: Gigabyte
    driver: snd_hda_intel v: kernel pcie: gen: 3 speed: 8 GT/s lanes: 16
    bus-ID: 06:00.6 chip-ID: 1022:15e3 class-ID: 0403
  API: ALSA v: k6.1.22-1-lts status: kernel-api tools: alsamixer,amixer
  Server-1: PipeWire v: 0.3.67 status: active with: 1: pipewire-pulse
    status: active 2: wireplumber status: active 3: pipewire-alsa type: plugin
    4: pw-jack type: plugin tools: pactl,pw-cat,pw-cli,wpctl
Network:
  Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet
    vendor: Gigabyte driver: r8169 v: kernel pcie: gen: 1 speed: 2.5 GT/s
    lanes: 1 port: f000 bus-ID: 04:00.0 chip-ID: 10ec:8168 class-ID: 0200
  IF: enp4s0 state: up speed: 100 Mbps duplex: full mac: <filter>
Drives:
  Local Storage: total: 931.51 GiB used: 145.34 GiB (15.6%)
  SMART Message: Unable to run smartctl. Root privileges required.
  ID-1: /dev/sda maj-min: 8:0 vendor: Seagate model: ST1000VN002-2EY102
    size: 931.51 GiB block-size: physical: 4096 B logical: 512 B speed: 6.0 Gb/s
    type: HDD rpm: 5900 serial: <filter> rev: SC60 scheme: MBR
Partition:
  ID-1: / raw-size: 40 GiB size: 40 GiB (100.00%) used: 24.15 GiB (60.4%)
    fs: btrfs dev: /dev/sda2 maj-min: 8:2
  ID-2: /home raw-size: 40 GiB size: 40 GiB (100.00%)
    used: 24.15 GiB (60.4%) fs: btrfs dev: /dev/sda2 maj-min: 8:2
  ID-3: /var/log raw-size: 40 GiB size: 40 GiB (100.00%)
    used: 24.15 GiB (60.4%) fs: btrfs dev: /dev/sda2 maj-min: 8:2
  ID-4: /var/tmp raw-size: 40 GiB size: 40 GiB (100.00%)
    used: 24.15 GiB (60.4%) fs: btrfs dev: /dev/sda2 maj-min: 8:2
Swap:
  Kernel: swappiness: 133 (default 60) cache-pressure: 100 (default)
  ID-1: swap-1 type: zram size: 5.71 GiB used: 1024 KiB (0.0%) priority: 100
    dev: /dev/zram0
Sensors:
  System Temperatures: cpu: 31.8 C mobo: N/A gpu: amdgpu temp: 31.0 C
  Fan Speeds (RPM): N/A
Info:
  Processes: 382 Uptime: 9h 53m wakeups: 0 Memory: 5.72 GiB
  used: 2.43 GiB (42.4%) Init: systemd v: 253 default: graphical
  tool: systemctl Compilers: gcc: 12.2.1 Packages: pm: pacman pkgs: 1376
  libs: 377 tools: paru Shell: Bash v: 5.1.16 running-in: xfce4-terminal
  inxi: 3.3.26
Garuda (2.6.16-1):
  System install date:     2023-01-04
  Last full system update: 2023-04-01 ↻
  Is partially upgraded:   No
  Relevant software:       NetworkManager mkinitcpio
  Windows dual boot:       <superuser required>
  Failed units:     

What audio equalizer can I use with mpg123?

It looks like it has a built-in equalizer, or do you mean something different?

mpg123
fish❯ mpg123
You made some mistake in program usage... let me briefly remind you:

High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
	version 1.31.3; written and copyright by Michael Hipp and others
	free software (LGPL) without any warranty but with best wishes

usage: mpg123 [option(s)] [file(s) | URL(s) | -]
supported options [defaults in brackets]:
   -v    increase verbosity level       -q    quiet (don't print title)
   -t    testmode (no output)           -s    write to stdout
   -w f  write output as WAV file
   -k n  skip first n frames [0]        -n n  decode only n frames [all]
   -c    check range violations         -y    DISABLE resync on errors
   -b n  output buffer: n Kbytes [0]    -f n  change scalefactor [32768]
   -r n  set/force samplerate [auto]
   -o m  select output module           -a d  set audio device
   -2    downsample 1:2 (22 kHz)        -4    downsample 1:4 (11 kHz)
   -d n  play every n'th frame only     -h n  play every frame n times
   -0    decode channel 0 (left) only   -1    decode channel 1 (right) only
   -m    mix both channels (mono)       -p p  use HTTP proxy p [$HTTP_PROXY]
   -@ f  read filenames/URLs from f     -T get realtime priority
   -z    shuffle play (with wildcards)  -Z    random play
   -u a  HTTP authentication string     -E f  Equalizer, data from file
   -C    enable control keys            --no-gapless  not skip junk/padding in mp3s
   -?    this help                      --version  print name + version
See the manpage mpg123(1) or call mpg123 with --longhelp for more parameters and information.
man mpg123
       -E file, --equalizer
              Enables  equalization,  taken from file.  The file needs to contain 32 lines of data, additional comment lines may be prefixed with #.  Each data line consists of two float‐
              ing-point entries, separated by whitespace.  They specify the multipliers for left and right channel of a certain frequency band, respectively.  The first  line  corresponds
              to  the  lowest, the 32nd to the highest frequency band.  Note that you can control the equalizer interactively with the generic control interface.  Also note that these are
              the 32 bands of the MPEG codec, not spaced like you would see for a usual graphic equalizer. The upside is that there is zero computational cost in addition to decoding. The
              downside is that you roughly have bass in band 0, (upper) mids in band 1, treble in all others.

It's not something you can tweak in real time, and has limitations as detailed above.

Other than that, you may use any "system level" equalizer, like EasyEffects or JamesDSP.
Mind their "autostart" feature, there has been reports of that causing problems (silent output, videos not starting until muting/unmuting, that sort of things).

There may be other options I'm not aware of.

5 Likes

Thank you for your response. I have tried both EasyEffects and JamesDSP without success. With both mgp123 and my default mp3 player mocp. The problem being that adjustment has to be done in real time. I have never understood the ever-changing and complicated methods of audio reproduction once it left the electronic/physical/analog world. Pipewire, ALSA, JACK, etc. Yes, I can buy a multiband hardware equalizer. Expensive, and one more large box to take up desk space.

Eh I feel you, I was born when analog electronics was a modern thing... my first amplifier was made of glass valves, and believe it or not, was built by my mom in her days. It still works by the way.
And it saturates without clipping, only even harmonics if I crank it up too much.
An analog hardware eq will likely give better sound quality without latency, whether it's worth it depends what you're listening to. In my opinion, it's wasted on the average mp3.
Still I think a software one should do, can you better explain "without success"?
Now that I think of it, perhaps mpg123 and the like use ALSA directly and bypass them.
I'll have a look at that later, now I'm too drunk.


edit:
So, I just tried mpg123 with EasyEffects and it does work, but gives me crackling sound while adjusting it (may be my laptop is just too slow). If I recall correctly, I also had to install a bunch of optional dependencies for EasyEffects (it was some time ago).


alsaequal (or rather, alsamixer) is giving me headache to set up, I'll get back.
(it doesn't find caps.so but it's there) <-- solved with export LADSPA_PATH=/usr/lib/ladspa
Now if I can get the .asoundrc right...


edit: @ionmich
Apparently the problem was not with the .asoundrc (the advised one works).
I was using mpg123 -a equal FILE.mp3, thinking it would either work or complain, but the equalizer was not affecting it. Looks like it falls back when it's not valid: -a null indeed does what expected, but -a crap plays audio to the sound card.
When I tried explicitly requesting ALSA output with mpg123 -o alsa -a equal FILE.mp3 I got this:

High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
	version 1.31.3; written and copyright by Michael Hipp and others
	free software (LGPL) without any warranty but with best wishes
ALSA lib dlmisc.c:337:(snd_dlobj_cache_get0) Cannot open shared library libasound_module_pcm_equal.so (/usr/lib/alsa-lib/libasound_module_pcm_equal.so: undefined symbol: snd_config_iterator_next)
[src/libout123/modules/alsa.c:open_alsa():181] error: cannot open device equal
[src/libout123/libout123.c:check_output_module():947] error: Module 'alsa' device open failed.
[src/libout123/libout123.c:out123_open():439] error: Found no driver out of [alsa] working with device equal.
main: [src/mpg123.c:check_fatal_output():334] error: out123 error 3: failure loading driver module

Lame work-around: mpg123 --au - FILE.mp3 |aplay -Dequal.
Also, in case of more than one output device (in my case, HDMI output counts as a separate one), the default slave.pcm "plughw:0,0" can be changed to slave.pcm "default" so that audio goes to whatever the default currently is instead of the first device (internal laptop speakers in my case).


As for EasyEffects, looks like it requires this for the equalizer:

Optional Deps:  lsp-plugins-lv2: equalizer, compressor, delay, loudness

and then has to be added to the pipeline, under "𝅳𝅗𝅥𝅗𝅥𝅴Effects", "Add Effect".

1 Like

I get the best audio effects results with Pipewire, Wireplumber, and JamesDSP, however JamesDSP does distort if run minimized to the tray.

3 Likes

Thanks for all your efforts to solve my problem. Here is the crux of the matter. I have software (mocp) that does exactly what I want. It plays all my stored music very simply. Yes I use mpg123, an excellent application for online streaming, where I have no control over content. But mocp is ancient software and does not come with a realtime equalizer. I used a variety of simple equalizers (not 30+ bands, more like 8) . Many years ago they worked. Since recent enhancements I have not had any success. They are now much more complicated with all sorts of "effects". Just fine for a recording studio. Everything I have tried needed installing more software, that failed, and more new software that also failed. I have made a decision. I will buy a simple, physical, automotive equalizer and end months of frustration.

Thanks again.

1 Like