diff options
Diffstat (limited to 'content/blog/2022/music-server.md')
-rw-r--r-- | content/blog/2022/music-server.md | 159 |
1 files changed, 159 insertions, 0 deletions
diff --git a/content/blog/2022/music-server.md b/content/blog/2022/music-server.md new file mode 100644 index 0000000..ce79ebb --- /dev/null +++ b/content/blog/2022/music-server.md @@ -0,0 +1,159 @@ ++++ +title = "Adding simple music server to my network" +author = ["Michał Sapka"] +date = 2022-05-25T22:26:00+02:00 +categories = ["blog"] +draft = false +weight = 3003 +abstract = "As part of my partitioning with streaming services, I have created a small music server on my home network. This article touches on how to get music, how to store and how to actually listen to it." +aliases = ["/articles/music-server", "/2022/music-server"] ++++ + +_This is an old article, and even though it is still valid, I no longer use Linux_ + +One of my goals for 2022 is to not pay for music subscriptions anymore. +Nowadays, it's really easy and cheap to actually own my music. + + +## Getting music {#getting-music} + +Internet is full of cheap, used CDs and new music is ready for purchase on sites like Bandcamp. +Since I mostly listen to dead people, CDs are my primary source. + +The first problem is having something to put a disc in. +I've gotten myself a cheap USB-CD/DVD drive. +It's very loud, but since I use it only for getting the data to my computer, it's not a problem. + +I rip (a word that I have not seen in a long time) on MacBook using XLD app. +I plan to move this step to Linux soon. + +[XLD homepage](https://tmkk.undo.jp/xld/index_e.html) + +I rip the music to FLAC, which seems to be standard. +It's lossless and most file-based players have no problems with it. +Of course, not everywhere. +iOS is always problematic, but I don't listen to music on the go very often, so it's a problem for future me. + +A single album in FLAC takes about 200-300 MB. +I still remember MP3 days, where it would go down to 60 MB or less, but back then storage and transfer were actually expensive. +I don't hear any noticeable difference between FLAC and good compressed file, but again - storage and transfer is cheap, Furthermore I have a single high-res album where half an hour takes 750 MBMB and there is zero difference. +Well, now I know, and I won't buy-high res ever again :) + + +## Storing and serving music {#storing-and-serving-music} + +The music will be accessed by multiple devices on local network, so putting it on the Home Server makes perfect sense. +I now have a dedicated share "music" which is shared via Samba and NFS. + +Samba seems better than NFS, but then NFS on Linux is simpler to set up. + +For Samba, I need to add read+write access to Music share for each user from Synology web UI. + +NFS on the other hand doesn't support users, but devices instead. +The first step is to set static IP for my devices (which is always a good idea). +How exactly this should be approached depends on the setup, but I use UniFi Dream Machine and forcing IP for a device is very straight forward. +After I have static IPs, I can add read/write access for those addresses, also via Synology web UI. + +Served music is so small, that this does not add any noticeable overhead for the server. + + +## Accessing the music on Linux {#accessing-the-music-on-linux} + +First, I needed to install NFS support. I use Arch, so: + +```shell +pacman -S nfs-utils +``` + +Then I checked if the share actually exists. My server's address is 10.0.1.200. + +```shell +showmount -e 10.0.1.200 +------------------ +Export list for 10.0.1.200: +/volume2/music 10.0.1.10 +``` + +Voilà! Next step: check if it works + +```shell +mkdir /mnt/music +mount 10.0.1.200:/volume2/music /mnt/music/ +cd /mnt/music +ls +``` + +And listing worked. +Noice. +To automate it for future, and to allow non-root users to actually mount the drive I added a new mount to /etc/fstab: + +```shell +10.0.1.200:/volume2/music /mnt/music nfs _netdev,noauto,x-systemd.automount,x-systemd.mount-timeout=10,timeo=14,users,x-systemd.idle-timeout=1min 0 0 +``` + +After the first user accesses /mnt/music, the drive will be mounted. + + +## Playing the music using CMUS {#playing-the-music-using-cmus} + +We have access to the files, let's play it. +Every modern music player for Linux should work with Flac, but I've chosen CMUS. +It's fast, it's terminal based, and it supports VIM keybindings. + +[CMUS on Github](https://cmus.github.io/) + +```shell +pacman -S cmus +``` + +After we open cmus, we need to add music. +It's done similarly to VIM, via an ex command. + +```shell +:add /mnt/music/ +``` + +And a few seconds later, the music is visible in the player. +Using CMUS requires reading the manual + +```shell +man cmus-tutorial +``` + +but the basics I needed to play something from Artist/Album view were: + +| key | descrition | +|-------|---------------------------------------| +| j | go up | +| k | go down | +| tab | change active window (artists/tracks) | +| space | expand artist to album list | +| c | play track / pause track | +| e | add track to queue | +| q | exit | + +Extra bonus: after first configuring system I had some problems with audio not working from time to time. +Moving from Pulse to Pipewire solved them all. + +[Pipewire webpage](https://pipewire.org/) + + +## Listening on Mac via CMUS {#listening-on-mac-via-cmus} + +I have no idea how to auto mount a server on MacOS, so after every reboot or network change, I need access the Samba share via Finder. +After it's mounted, I can access it under /Volumes/music. + +On Mac I also use CMUS, so all of the above apply as well. +One difference is adding the files due to different location + +```shelll +:add /Volumes/music +``` + + +## Next up {#next-up} + +This doesn't solve all my needs. In the future I need to find out how to: + +- Access The Music Outside My Home Network +- how to marry this setup with my multiroom system (Sonos + Homepods) |