20.02.2022

Music Playing: Local & Remote

#tech #linux

The most basic way to play music is using some website. Most people prefer Spotify, but I never liked it.

For the longest time I've been using Soundcloud, it has most music I like, especially the quirky electronic type. It also allows you to upload songs without any additional setup. But, of course, there are songs that are not on there. The worst part is that some more main-stream artists have their songs region-locked or only available with soundcloud premium.

Local Music Library

A year back I decided to begin storing my music locally. This approach ensures that I have access to all my favorite music, in best quality, offline, forever.

It is honestly really freeing and opened a bunch of possibilities for me.

DeaDBeeF Music Player

I first settled on DeaDBeeF, as it's highly customisable, extensible and actively developed.

Configuring takes some time to get used to. You have to enable 'design mode' in the 'View' submenu to start adding and removing panes. It allows you to use a lot of GTK3 (UI library) widgets to structure your window however you like. You can find my config in the GitHub repo linked below.

I especially like the visualization plugins that I found. On Arch-based systems it is extremely easy to install plugins: yay -S deadbeef-plugin-spectrogram-gtk3-git \
deadbeef-plugin-musical-spectrum-gtk3-git \
deadbeef-plugin-rating \
deadbeef-plugin-waveform-gtk3-git
Some plugins are configured through settings, others through the right-click menu.

There are 2 main problems with DeaDBeeF for me:

Both of these features are in plans so at some point in the future I hope we'll get them.

MPD Music Server

Recently I started using MPD. It's a bit technical.

It might sound scary at first but all you need to do to set it up is create 1 config file and run the server. There are a lot of clients that allow you to connect to an MPD server with relatively conventional interfaces. I am currently using Cantata, as it's the most feature rich one I could find.

The great thing about MPD is that you can connect as many clients as you want and they all will be synchronized with each other. There are clients for scrobbling your music to last.fm (with mpdas), setting your discord 'rich presense' and controlling playback with media keys or a notification (with mpdris2). It's the most modular music playing experience and I love it. My config looks like this: music_directory "~/Music"
db_file "~/.config/mpd/database"
playlist_directory "~/.config/mpd/playlists"
sticker_file "~/.config/mpd/sticker.sql"
log_file "syslog"
auto_update "yes"
restore_paused "yes"

audio_output {
type "pulse"
name "pulse audio"
}

audio_output {
type "fifo"
name "my_fifo"
path "/tmp/mpd.fifo"
format "22050:16:2"
}
'sticker_file' allows for custom music ratings (supported by Cantata), 'fifo' audio output allows for latency-less audio visualization with Glava.

To install everything I mentioned on Arch you would run: yay -S mpd mpd-discord-rpc-git mpdas mpdris2 cantata

Remote Music Library

But what if I want to play my music on a device where I don't have my audio library?

MPD Does it All

You can create an http output by putting the following lines in your config: audio_output {
type "httpd"
name "My HTTP Stream"
encoder "lame"
port "8000"
bitrate "192"
format "44100:16:1"
max_clients "0" # 0=no limit
}
I host an MPD instance on my server and can control playback with any client. On my phone I use MPDroid (which can also stream the aduio). To stream audio on desktop you have to connect to the specified port through a music player that can play http streams, like mpv, or a web browser. MPD clients, such as Cantata, can also play http audio streams. The delay is a little annoying. There is a setup that allows for 0 delay playback ( with local mpd using a remote music library) I saw here: www.joram.io/blog/android-streaming-mpd/

But I want my recommendations!

MPD :)

There is a client that automatically queues new songs based on last.fm recommendations.