Audio using the Base Overlay

The PYNQ-Z1 board contains an integrated MIC, and line out connected to a 3.5mm jack. Both these interfaces are connected to the FPGA fabric of the Zynq® chip. The Microphone has a PDM interface, and the line out is a PWM driven mono output.

It is possible to play back audio from the board in a notebook, and to capture audio from other interfaces like HDMI, or a USB audio capture device. This notebook will only consider the MIC and line out interfaces on the board.

The Microphone is integrated onto the board, as indicated in the image below. The MIC hole should not be covered when capturing audio.

Audio IP in base overlay

To use audio on the PYNQ-Z1, audio controllers must be included in a hardware library or overlay. The base overlay contains a the PDM capture and PWM driver for the two audio interfaces as indicated in the image below:

The Audio IP in the base overlay consists of a PDM block to interface the MIC, and an Audio Direct IP block to drive the line out (PWM). There are three multiplexors. This allows the line out to be driven from the PS, or the MIC can be streamed directly to the output. The line out can also be disabled.

Using the MIC

To use the MIC, first create an instance of the Audio class. The audio class can be used to access both the MIC and the line out.

In [1]:
from pynq.drivers import Audio
audio = Audio()

Capture audio

Capture a 4 second sample from the microphone, and save the raw pdm file to disk:

In [2]:
# Record a sample
# Save recorded sample"Recording_1.pdm")

Playback on the board

Connect headphones, or speakers to the 3.5mm line out and playback the captured audio:

In [3]:
# Play recorded sample

You can also playback from a pre-recorded pdm file

In [4]:
# Load a sample
# Play loaded sample