Record audio on your Raspberry Pi

 

Record audio on your Raspberry Pi

Hardware

HiFiBerry offers the following sound cards that can be used as an audio input device:

  • DAC+ ADC
  • DAC+ ADC Pro
  • DAC+ DSP
  • Beocreate 4 channel amplifier
  • Digi+ I/O

To find out what card is the best choice for your use, have a look at our comparison.

Simple recording from command line

Most Linux distributions include the simple tool “arecord” that can be used to record audio and save it to a file.

Just configure your Raspberry Pi and run the command

arecord -d 60 -c 2 recording.wav

This will record one minute of audio and save it to a WAV file. While arecord does not support file formats like MP3, OGG or FLAC, you can use additional tools (e.g. SoX) to convert this recording to another format. Also, check out the main page of arecord for all supported command-line options to fine-tune your recordings.

Audacity

If you not only want to record but also edit audio on the Raspberry Pi, a more powerful tool is needed. The most popular application for this use case is Audacity, a powerful digital audio workstation.

We have created a small guide how to setup the system for Audacity and start recording.

Record and stream audio

Another interesting use case is to record and stream audio – to other rooms or even to the Internet (think: ‘podcast’). While both use cases seem to be very similar, we recommend using different software. Internet streaming often does not guarantee a specific bandwidth. Therefore, buffering and a robust protocol is needed. Streaming servers like Icecast are designed specifically for this use case. Check out our guide!

Streaming within your own home network can be done with less buffering and streaming clients specifically designed for this. Our guide for Logitech Media Server shows how to do this. Clients that can be used for this are HiFiBerryOS, Max2Play, PiCorePlayer or others that include the “squeezelite” client.

Process audio

You want to record audio, and process it as well? If you just want to do this offline, Audacity is still your best choice. If you want to process it in real-time, additional software like Zynthian or PureData can do this.

Have a look at our guide how to build a Zynthian box. While this guide does not include the DAC+ ADC, newer Zynthian boxes come with this board and therefore also offer recording.