One thing I enjoy is not having a laptop open as I play (I spend my working life staring at a screen). But I still want to be able to record audio as I experiment on the Digitakt and Digitone so I don’t lose cool music along the way. I came up with a neat way to use a Raspberry Pi3 as a background session recorder to capture 4 channels of audio from my mixer which is saved on the Pi’s memory card as mp3 files. Now when I’m experimenting in my home studio I’m constantly recording what I come up with so later on I can go back if I stumbled upon something really cool, and no laptop needed!

My goals for this little project:
  1. No laptop!
  2. Have it run automatically in the background as soon as I turn on my RaspPi
  3. Capture 4 channels of audio
  4. Create an MP3 file for each hour of studio session time.

Tutorial Video

Step-by-Step Guide

  1. Get a RaspPi and install Raspbian on it. I’ve tested this on a RPi3, but a Pi2 would work. My Pi3 has 4 USB ports on it; for the Digitone, Digitakt, Arturia MiniLab2 MIDI controller and USB audio output from my Behringer 404HD.
  2. Log into your RaspPi and open a command terminal.
  3. Install the ffmpeg package: sudo apt-get install ffmpeg
    I’m using the ffmpeg package to capture four channels of audio over USB from the mixer.
  4. Install the lame package to process MP3 files: sudo apt-get install lame
    Lame is a Linux package that converts file formats to MP3, as to store 1 hour of 4 channel audio as a wav file takes a lot of disk space! The 4 channels of audio will be mixed down to a 2 channel stereo MP3 file.
  5. Determine the USB device name of your mixer; run aplay -l and look for the audio mixer entry. For example, here’s what my output looks like:
    pi@raspberrypi:~ $ aplay -l
    **** List of PLAYBACK Hardware Devices **** card 1: U192k [UMC404HD 192k], device 0: USB Audio [USB Audio] Subdevices: 1/1 Subdevice #0: subdevice #0
    In this case the name of my U404 appears as U192k – remember this for the next step!
  6. Capture the audio channels and start recording manually: ffmpeg -y -nostats -nostdin -f alsa -ac 4 -i plughw:CARD=U192k -t 3599 -acodec libmp3lame /home/pi/session_$(date +\%Y_\%m_\%d_\%H_\%M_\%S).mp3
    This command looks complicated but it breaks down very simply; tell ffmpeg to use the ALSA sound input, with 4 channels, from the U192k (the Behringer), for 3599 seconds, and encode using the Lame codec (for MP3s) and save it to a file named after the current date and time.
  7. Play music! The MP3 file will grow in size as you record. In my experiments an hour of recording gives a 57MB file.
  8. Make all of this happen automatically. For this you’ll edit a special file on the Pi called crontab which runs commands periodically. Run crontab -e and in the editor enter this line at the bottom of the file:
    * */1 * * * ffmpeg -y -nostats -nostdin -f alsa -ac 4 -i plughw:CARD=U192k -t 3599 -acodec libmp3lame /home/pi/session_$(date +\%Y_\%m_\%d_\%H_\%M_\%S).mp3
    Remember: keep this all on one line.
  9. Now you can log out of the Pi and every hour a new session recording file will be created and stored on the Pi’s memory card as you play!
Hope this is useful to someone – the Raspberry Pi is a very versatile MIDI tool in the studio!