PDM INPUT-OUTPUT + FFT Example

Description

This example is meant to run on the GAP9 EVK with the Audio Add-On board.

It takes input samples from one of the PDM micrphones on the Audio Add-On board, downsample it in the SFU to 48 or 16 KHz and store them in L2 memory within a ring buffer. The ring buffer size is defined by the FRAME_SIZE chosen in the CMakeLists.txt. A real-FFT is applied to the Ring Buffer and just after that an inverse real-FFT. The FFT functions are generated using nntool and Autotiler in the fft_nntool_script.py. The script is used from the CMakeLists.txt using the selected FRAME_SIZE/FRAME_STEP options. The hop size (FRAME_STEP) between 2 consecutive frames is exactly one half of the FRAME_SIZE. After the Inverse FFT the frames are reconstructed by using the Overlapp and ADD feature of the Hanning window applied durin the forward pass of the RFFT (note argument window_type in the fft_nntool_script.py)

Then the output is then upsampled, converted in PDM and sent to the PDMAmp stereo minijack on the Audio Add-On board.

This example is useful to understand how to code applications that work with both audio in/out interfaces and NN and/or DSP functionalities within the GAPflow (e.g. denoiser applications).

Instructions

Warning

Pay attention to required jumper settings (see GAP9_EVK User Manual) Note that by default the printfs output are redirected to UART, use cutecom or other tools to read the serial port.

Exercized hardware

  • Audio Add-on board

Run on GVSOC

This app can also be run as is on GVSOC. You need to select the platform from make menuconfig and also activate the GVSOC proxy mode under the GVSOC options menu that will appear just below the platform. NOTE: also remember to set the IO type to JTAG in the Utils -> IO menu.

To run the app in GVSOC:

make run

and in another terminal:

./gvcontrol --port 30000

On GVSOC mode the app will take the pdm in from a file (actually saved in pcm format and specified in gvcontrol), and will write out the pdm into another file (named “output.wav” also specified in the gvcontrol script). GVSOC will take care of the on-the-fly conversion from pcm to pdm and viceversa.