How to play Spotify on your A500

Being kind of a newbie regarding linux, it was quite hard for me to pull this of. However, with a little help from my friend, who gave me the right tools to work with, I finally got this mojo working! This is the story of how I managed to get Spotify to play on my Amiga πŸ™‚

I got the idea after I played an mp3 via my A314 - a trapdoor expansion with a Raspberry Pi as co-processor. The PiAudio-service is piping the audio via an Advanced Linux Sound Architecture (ALSA) plug called amiga. This plug pipes the raw audio via the memory that the Raspberry Pi and the Amiga shares. On the Amiga side the piped audio goes to the sound chip Paula, that takes care of the playback. Note that the Raspberry Pi takes care of the decoding.

The example for PiAudio at A314@GitHub uses mpg123 to play song.mp3:
        mpg123 -a amiga song.mp3
The argument -a amiga sends the sound stream to the device of your choice, in this case the A314's ALSA plug amiga.

However, the mpg123 is not very convenient when it comes to playing mp3's. This made me think of Spotify and the nice Spotify Connect solution.
- Now that would be convenient, maybe you could pipe that to the ALSA plug!
I mentioned this to my friend David - a couple of minutes later he sent me a link to raspotify, and that lit my fire!

For some reason I did not manage to pipe the audio from librespot (that raspotify uses) to my ALSA plug. After many hours of googling, all I had learnt was to understand how the ALSA plug worked, and managed to rewrite the original to a more readable form. Not too bad, but very frustrating!

After some more discussion with my friend David, he gave me this great tool - SoX, Sound eXchange - that finally got me in the right direction. After a couple of hours, I nailed it! Below follows the instructions on how to setup your Raspberry Pi and Amiga to be able to play Spotify through your Paula chip.

Setting up Raspotify - a Spotify Connect client for Raspberry Pi.

Prerequisites - An A314 with a Raspberry Pi up and running on your Amiga.

Install Raspotify:
        curl -sL https://dtcooper.github.io/raspotify/install.sh | sh
Move raspotify.service to a <folder-path> of your choice for storage. You will need to temporarily put it back for updates, or if you want to remove the installation:
        sudo mv /lib/systemd/system/raspotify.service <folder-path>

Install SoX, and needed libraries:
        sudo apt install sox libsox-fmt-all
        sudo apt install libasound2-plugins libasound2-dev

To launch Raspotify from your Amiga, you will have to make an executable bash script. This script will launch the Spotify Connect device called "A314spot" and pipe the audio to SoX. SoX will receive the raw data and put it through another pipe to our ALSA plug called amiga. The ALSA plug will then finally pipe it to your Amiga.

To do this, first log in as super user (su):
        sudo su
Create a bash script called Spotify. Copy and paste all text below, and hit <enter>:
echo '#\!/bin/sh' > /usr/local/bin/Spotify
echo 'librespot --name A314spot --device-type computer \
--initial-volume 100 --backend pipe | \
sox -t raw -b 16 -e signed -c 2 -r 44.1k - \
-b 16 -e signed -c 2 -r 44.1k -t alsa amiga' >> /usr/local/bin/Spotify

Make file executable for all users:
        chmod a+x /usr/local/bin/Spotify
Press <ctrl+d> to exit su promt.

Edit Shell-startup on your Amiga.

Add the following line to SYS:S/Shell-Startup:
        Alias spotify pi bash Spotify

Time to play.

I presume that you already have followed my tutorial that sets up the Amiga side with PiAudio, otherwise take a look at the Edit SYS:S/Shell-Startup-part.
Now you should be ready to rock the world!

Start your AmigaShell and enter:
        spotify
Be sure that your "smart device" has WiFi turned on and then start the Spotify app,
go to settings and scroll down to Devices,
click Connect to a device and choose A314spot,
pick a song or album then hit play and enjoy!

I hope that you'll like this sound-mojo of mine.
Please stay tuned for more tips and trix! πŸ™‚

Meanwhile check out these links:
Join the A314 discussion @discord
A314 @GitHub
A314 - The RPi co-processor Official thread @EAB

Spread the love

11 thoughts on “How to play Spotify on your A500

  1. Pingback: βœ…Blog | Hackaday | Hacks frescos todos los dΓ­as - 【la-tecnologia 】

  2. Pingback: Expansion Board Puts Spotify On The Amiga 500 | 3d print ......errori ed esperienze,

  3. Pingback: You Can Now Listen to Spotify on Your Vintage Commodore Amiga 500 - PC Solution

  4. Hi, i’m folloiwng your guide an this command:

    sudo apt install libasound2-plugins libasound2-python

    returns this error on the Pi:

    E: Unable to locate package libasound2-python

    • Hi Andy! πŸ™‚

      Good catch, and thanks for the feedback.
      I think it shall be libasound2-dev instead.
      Please try, and tell me if you still have problem! πŸ˜‰

      Best regards/
      Daniel

  5. Hi Daniel, no problems, I have installed -dev instead. I am just in the process of setting up my sd card with your two guides. My A314 should be here in a few days so I will report back when it arrives πŸ™‚

    • Fingers crossed that you do not run into any more problems with my tutorials, or actually it would be great if your do! πŸ˜‰

      If you run into any more problems, please pop in at the irc channel #a314 if I do not answer directly!
      Keep me posted on the progress πŸ™‚

  6. Ok, A314 and Pi are running! PiDisk works fine and i can play MP3s! However, Spotify does not seem to work – when I type Spotify i get this output:

    https://youtu.be/mvziJlQTId0

    I have checked that I have followed the instructions correctly πŸ™‚

    Any ideas? Seems that SOX has a problem

  7. Ok, this is the correcy txt for the Spotiy file:

    #\!/bin/sh
    librespot –name A314spot –device-type computer –initial-volume 100 –backend pipe | sox -t raw -b 16 -e signed -c 2 -r 44.1k – -b 16 -e signed -c 2 -r 44.1k -t alsa amiga

    all one line, with \\ removed

    Cool, thanks for the tips on efnet πŸ™‚

    • Glad to hear you solved it!
      It’s really weird that I doesn’t work with the break line, I have to take a look at this later tonight.

      Anyhow, welcome to the fun world of A314!

    • I have now looked at my script, it looks like there was one back slash too much in my tutorial!
      Can you please try to remove your script and redo the copy paste from the edited tutorial and tell me if that works?
      Would be much appreciated! πŸ˜‰

Leave a Reply

Your email address will not be published. Required fields are marked *