1

I am currently building a light-weighted audio system using my rasperry Pi zero.

I am looking to enable my Pi to have the following 2 functionalities:

1) be able to record from a microphone

2) be able to play back from what is recorded.


I am wondering if you guys know any off the shelf code (perferrably written in C) that I can use, to enable my Pi to have the following functionalities?

user3222184
  • 119
  • 3

2 Answers2

2

The Pi Zero doesn't have a built-in Microphone input nor Audio output, therefore, you will need either a USB Sound Card or a pHAT. In case it helps, I bought a "USB Sound Card for Pi" on ebay for $3, which has two inputs, mic and stereo jack, and I use Audacity on the Pi to record and play audio, and it works great. If you already have all the necessary hardware and want to 'program' a way to record and then play the recording, I would recommend looking into PyAudio in Python.

Ricardo
  • 1,068
  • 8
  • 7
0

PyAudio, mentioned by user3222184 is just a python wrapper for PortAudio (http://portaudio.com/), which can definitely be used to do what you want. It's a cross-platform C / C++ library.

I've use PyAudio with PortAudio on a Raspberry Pi, so I know that it works. It can be tricky if you're trying to do any audio processing to ensure that the processing runs fast enough to keep up with real-time audio, but that won't be an issue for simple recording and playback.

PortAudio won't write mp3 files itself. It does understand wave files, and I don't know off the top of my head what other formats it may support.

ViennaMike
  • 119
  • 4