Recording songs from Spotify

  1. Put this in $HOME/.asoundrc
  2. Start spotify.
  3. Listen to the song you want to record.

That's it, the song is now in /tmp/audiocap.wav. Encode to mp3 or ogg or whatever file-format you prefer for music. Notice /tmp/audiocap.wav will be overwritten as soon as a new song is played; that's a good thing (it makes it easy to record many songs), but you have to encode or copy the contents of /tmp/audiocap.wav before you listen to anything else, otherwise the first recorded song will be overwritten.

Not only spotify songs will be recorded, every sound that is played will recorded. That is useful, since you can record from webb-radio, youtube etc, but you might want to turn it off when you listen to music from your local box since it is pointless to record what you already got. Just remove the $HOME/.asoundrc to turn recording off.

Encoding

While encoding is not within the subject of recording, read on only if you want to encode as well. The reason I bring it up is that oggenc does not support 32 bit wavs (or 32 bit raw sound-files), which is what Spotify has changed its format to. lame works though:

lame -V2 /tmp/audiocap.wav One_day.mp3

For the archives

My previous post on how to record streaming audio also works, but note that Spotify have changed to 32 bit samples, so to play back use:

aplay -t raw -f S32_LE -c2 -r 48000 output.raw

This is merely of historical interest since recent versions of ALSA can write wav-files directly, which is easier to use since wav-files includes information on the format of the sound data in such files.

pcm.!default {
  type empty
  slave {
    pcm "tee:'plughw:0,0','/tmp/audiocap.wav',wav"
  }
}

comments powered by Disqus


Back to the index

Blog roll

R-bloggers, Debian Weekly
Valid XHTML 1.0 Strict [Valid RSS] Valid CSS! Emacs Muse Last modified: oktober 17, 2019