pynq.lib.audio Module

The pynq.lib.audio module is a driver for reading and recording values from an on-board audio mirophone, loading preexisting audio files, or playing audio input to an output device.

class pynq.lib.audio.Audio(description, gpio_name=None)[source]

Bases: pynq.overlay.DefaultHierarchy

Class to interact with audio controller.

Each audio sample is a 32-bit integer. The audio controller supports only mono mode, and uses pulse density modulation (PDM).

mmio

MMIO – The MMIO object associated with the audio controller.

gpio

GPIO – The GPIO object associated with the audio controller.

buffer

numpy.ndarray – The numpy array to store the audio.

sample_rate

int – Sample rate of the current buffer content.

sample_len

int – Sample length of the current buffer content.

bypass_start()[source]

Stream audio controller input directly to output.

Returns:
Return type:None
bypass_stop()[source]

Stop streaming input to output directly.

Returns:
Return type:None
static checkhierarchy(description)[source]

Hierarchy can be bound if it contains the ‘d_axi_pdm_1’ IP and it contains exactly one GPIO pin.

static info(file)[source]

Prints information about pdm files.

The information includes name, channels, samples, frames, etc.

Note

The file will be searched in the specified path, or in the working directory in case the path does not exist.

Parameters:file (string) – File name, with a default extension of pdm.
Returns:
Return type:None
load(file)[source]

Loads file into internal audio buffer.

The recorded file is of format *.pdm.

Note

The file will be searched in the specified path, or in the working directory in case the path does not exist.

Parameters:file (string) – File name, with a default extension of pdm.
Returns:
Return type:None
play()[source]

Play audio buffer via audio jack.

Returns:
Return type:None
record(seconds)[source]

Record data from audio controller to audio buffer.

The sample rate per word is 192000Hz.

Parameters:seconds (float) – The number of seconds to be recorded.
Returns:
Return type:None
save(file)[source]

Save audio buffer content to a file.

The recorded file is of format *.pdm.

Note

The saved file will be put into the specified path, or in the working directory in case the path does not exist.

Parameters:file (string) – File name, with a default extension of pdm.
Returns:
Return type:None