+ Reply to Thread
Results 1 to 5 of 5

Thread: Spotify on a Pi and other adventures

  1. #1
    Join Date: Sep 2012

    Location: East Anglia UK

    Posts: 1,219
    I'm Marc.

    Default Spotify on a Pi and other adventures

    If you don't like tinkering with your Pi this post isn't for you, there will be references to editing system files and other such scary and mystical practices. Also, much of what I've ended up with is probably possible with one of the 'vanilla' audio distros such as Moode or Volumio, but my preference is for the road less travelled in these matters, this is DIY digital audio.

    What I've ended up with a Pi that not only runs my much loved Subsonic media server platform (allowing me native playing of my FLAC files on my home system and streaming of those files at rates up to 320kBs across the internet using either a phone app or simply in a web browser) but also Spotify (albeit with a premium account) with a nice interface on my local machine (next step is to work out a streaming option for this)

    I've shown snaps of Subsonic before but for reference this is what Spotify looks like in a web browser served by the Pi



    This is the 'spotmop' interface, you can also browse and play your local files with it too



    This aspect of my recent developments is not of itself all that clever, I simple followed the instructions on the mopidy website: https://www.mopidy.com/ added the Mopidy Repository to my DietPi install and installed Mopidy (and the Spotify and SQLite plugins) I also installed python-pip so I could install the Spotmop interface.

    Edit /etc/mopidy/mopidy.conf to taste and I'm up and running with Mopidy and Spotify.

    However, there's a couple of problems. Namely that my Sabre DAC (using the HifiBerry driver) has no mixing function and ALSA is a single client tool. Either Mopidy or Subsonic would work but not both!

    Dmix to the rescue!

    Dmix is an ALSA plugin that allows for multiclient use of ALSA following a combo of guides found online I ended up with a working solution.

    Firstly edit /boot/config.txt (or on a dietpi system /Dietpi/config.txt) and add the line: dtoverlay=i2s-mmap

    Then edit /etc/asound.conf The config that worked for me was the one found towards the bottom of the page here: https://wiki.gentoo.org/wiki/ALSA (under the heading 'Soundcard only available for one application')

    I determined my sound card number and subdevice number with a quick aplay -l and edited that section of the file to suit, I also amended the sample rate to 44100 because all my files are at that sample rate and I didn't want any more 'messing' with the stream that absolutely necessary.

    A quick reboot and we're all up and running I can now switch between apps using Subsonic for local files and Spotmop for Spotify and so on (as a side note I've really not got on with Mopidy's implementation of MPD as I can't get it to play nice with GMPC, my preferred non-phone client, and this configuration allows me to install and run a 'proper' instance of MPD alongside Mopidy for Spotify.

    So my current setup is a Pi2 running Mopidy and Subsonic in to my 'big rig' and my old Pi1 running Mopidy and MPD (which is much lighter on processor than Subsonic) in my second system. I also have the Pi2 running Samba etc so I can load files in to it and then that drive is mounted by a Samba client in to the Pi1 with an rsync backup routine so each evening any changes to the main drive are mirrored to the second drive keeping them both up-to-date and backed up.

    If you want to try this on your own Pi and need any pointers just let me know and I'll do what I can to help.
    Last edited by Rothchild; 10-10-2016 at 20:59.

  2. #2
    Join Date: Feb 2012

    Location: Falun, Sweden

    Posts: 2,245
    I'm Mike.

    Default

    Thanks for the write-up Rothchild!
    I did have the very same dilemma before, trying to get Spotify Connect libs to play nice with moOde on the same Pi.
    At this moment though all issues are solved through using Roon, and using the Pi's as Bridges... Not much DIY in that path though!,

  3. #3
    Join Date: Sep 2012

    Location: East Anglia UK

    Posts: 1,219
    I'm Marc.

    Default

    Cheers Mike,

    Yeah, Roon is just to rich for my tastes and appears to need some quite heavyweight hardware to run on, I like Pi's for their tiny energy consumption. The next build-up is likely to be on a Nano-Pi Micro.

  4. #4
    Join Date: Sep 2012

    Location: East Anglia UK

    Posts: 1,219
    I'm Marc.

    Default

    The geeking continues.

    I wanted access to a better eq than the two tone knobs on my amp so I've installed and setup alsaeq a 10band 'graphic' equaliser and configured it to work with both MPD and Mopidy (Spotify).

    I wanted to run alsa eq on one of my setups, it was quite straightforward to getting it working with mpd but it's taken a bit longer to also have it work with mopidy, so here are the ingredients to enable both dmix and alsaequal so you can have both mpd and mopidy play nicely together on the same machine and have an eq for each of them. It's a further change and development to the settings shown above and still includes the 'dmix' facility.

    Curently my /etc/asound.conf file looks like this:

    Code:
    ctl.equal {
        type equal;
    }
    
    pcm.plugequal {
        type equal;
        # Modify the line below if you do not
        # want to use sound card 0.
        #slave.pcm "plughw:0,0";
        # by default we want to play from more sources at time:
        slave.pcm "plug:dmix";
    }
    
    # pcm.equal {
    # If you do not want the equalizer to be your
    # default soundcard comment the following
    # line and uncomment the above line. (You can
    # choose it as the output device by addressing
    # it with specific apps,eg mpg123 -a equal 06.Back_In_Black.mp3)
    pcm.!default {
        type plug;
        slave.pcm plugequal;
    }

    And the relevant section of /etc/mopidy/mopidy.conf now looks like this (I've also installed the package mopidy-alsamixer)

    Code:
    [audio]
    mixer = alsamixer
    output = alsasink device=plug:plugequal
    
    [softwaremixer]
    enabled = false
    
    [alsamixer]
    enabled = true
    card = 0
    control = Digital
    The bit that took a bit longer to work out is that there are different commands to get the right eq for the app you want to adjust so to tweak mpd I use:
    Code:
    alsamixer -D equal
    and for mopidy:
    Code:
    sudo -H -u mopidy alsamixer -D equal
    Obviously these are a pita to remember each time so a quick nano .bashrc in the root folder and add the following lines at the bottom
    Code:
    alias spoteq='sudo -H -u mopidy alsamixer -D equal'
    alias mpdeq='alsamixer -D equal'
    So if I want to eq mopidy I can just type: spoteq or for mpd it's mpdeq

    Now I'm going to try and marry up my new asound.conf with the old one to ensure there's minimal sample conversion or any other interference with the audio stream.

  5. #5
    Join Date: Sep 2012

    Location: East Anglia UK

    Posts: 1,219
    I'm Marc.

    Default

    Small update.

    Being the super responsive developer he is, the chap who runs Diet-Pi has included the Mopidy installation option by default in the new version (v.136).

    There's also a new partnership with these guys: https://www.justboom.co/ so there's also been some 'under-the-hood' enhancements which make setting up EQs, Mixers and (re)sample rates / bit depth a breeze too.

    Last weekend I DJ'd a party in Washington DC and played all my tracks streamed, from Subsonic, on a Pi 2 over my domestic ADSL line back in Cambridge - can't say it was good for my nerves, but it worked!

    Diet-Pi for Raspberry Pi (and a whole slew of other SBCs) available here: http://fuzon.co.uk/phpbb/viewforum.php?f=8

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •