GVSOC Audio Connection Example

Introduction

This example demonstrates how to establish audio connections between inputs and outputs on GVSOC. The ultimate goal is to model the feedback path and the feedforward path for running an Active Noise Cancellation ANC on GVSOC.

This particular example is extremely basic and simply aims to illustrate how to connect components together using custom boards. Two boards are provided in the example: one for feedback and one for feedforward.

In the feedback_board, shown below, dac_right is connected to mic_AL. Therefore, dac_left output contains a mix of dac_right output and mic_AL input.

../../../../../../_images/feedback_board.png

In the feedforward_board, shown below, mic_AL is connected to dac_right. Therefore, dac_right output contains a mix of dac_right output and mic_AL input.

../../../../../../_images/feedforward_board.png

The output of the dac are by default in the build directory in files named evk_gap9_ssm6515_left.wav and evk_gap9_ssm6515_right.wav.

Custom Board Creation

To implement these connections, users need to create their custom GVSOC boards based on existing ones. Two board examples are provided in the Python scripts feedforward_board.py and feedback_board.py. These scripts retrieve instances of DACs and microphones and instantiate a transfer function to model the audio path. The transfer function is then connected to the DAC and microphone audio connections.

# Example snippet from feedforward_board.py or feedback_board.py
dac_right = self.get_component('dac_right')
mic_AL = self.get_component('mic_AL')

transfer_function = TransferFunction(self, 'transfer_function', sample_rate=768000)
dac_right.o_AUDIO(transfer_function.i_AUDIO())
transfer_function.o_AUDIO(mic_AL.i_AUDIO())

In CMake, users specify their custom board using:

gvsoc_custom_board(feedback_board ${CMAKE_CURRENT_SOURCE_DIR})

This enables executing the code on GVSOC with the custom board as the target.

Control Script

Control and configuration of microphones, DACs, and transfer functions are managed using gvcontrol.py. This script retrieves instances of microphones and DACs and provides functions to control them. For example, set_input_file() provides an input file to the microphone, and set_generated_sine() generates a sine wave with the desired frequency and amplitude. Debug files can be activated to monitor the input and output of the transfer function. Debug files for microphones and DACs can be created using the debug_enabled(True) method.

To use the control script, a CMake command is available to start GVSOC and automatically launch the control script:

gvsoc_control_script("${CMAKE_CURRENT_SOURCE_DIR}/gvcontrol.py")

GAP Code

The code running on the GAP initializes the I2S interfaces, configures the DAC, and performs a simple PDM in -> PCM -> PDM out by demodulating at 768 kHz in the SFU. Therefore mic_AL is connected to dac_left and mic_AR is connected to dac_right.