Main Content

Parametric Audio Equalizer for Qualcomm Hexagon DSP

This example shows how to generate and run the optimized code of a three band parametric audio equalizer on Qualcomm Hexagon Simulator using Embedded Coder® Support Package for Qualcomm® Hexagon® Processors. The optimized code uses Qualcomm Hexagon QHL CRL for replacing second-order section (SOS) filter and few math operators in the equalizer.

Introduction

Audio systems often use parametric equalizers to adjust frequency response. For example, a parametric equalizer compensates for physical speakers with peaks and dips at different frequencies.

In this example, the parametric equalizer algorithm provides a second-order section (SOS) filter, allowing for coefficient adjustment to achieve the desired frequency response. The Parametric Equalizer Design (Audio Toolbox) methodology fine-tunes these coefficients. Users can dynamically adjust filter coefficients and explore behavior through the simulation's user interface.

In this example, you learn:

  • How to specify the parametric equalizer algorithm.

  • How to explore parametric equalizer algorithm behavior through simulation.

  • How to generate the code.

Supported Hardware

  • Qualcomm Hexagon Simulator

  • Qualcomm Hexagon Android Board

Prerequisites

Launch the hardware setup and install the Qualcomm SDK. For more information, see Launch Hardware Setup.

Required Hardware

You need the following hardware to run this example:

  • Supported Qualcomm Hexagon Simulator

Available Models

Explore Parametric Equalizer Behavior Through Simulation

In this example, the top model (HexagonParametricAudioEqualizerDemo.slx) includes an excitation source, specifies each band's equalizer settings (such as gain, center frequency, and bandwidth), and features a panel of user interface knobs. These knobs allow users to adjust the filter settings interactively.

The model reference (ParametricAudioEqMdlRef.slx) implements the three-band equalizer. It generates the coefficients and cascades them into the SOS filter, ensuring precise signal processing according to the specified equalizer parameters.

To open the model, enter this command:

open_system('HexagonParametricAudioEqualizerDemo')

You can observe the behavior of this equalizer by adjusting the specified parameters, such as gain, center frequency, and bandwidth. The model dynamically generates the SOS filter coefficients based on these settings. Although you can explore this directly on the Qualcomm Hexagon Simulator, it may run slower due to simulation constraints. To facilitate tuning in the host simulation environment, set the Simulation mode to Normal in the block parameters of the model reference (equalizer). Additionally, increase the Stop Time parameter to allow sufficient time for tuning the parameters as needed.

For more information on equalizer parameters, refer to Parametric Equalizer Design (Audio Toolbox) block.

You can view the tuned equalizer's magnitude using the Filter Visualizer, which displays the magnitude response of the three-band equalizer. The default simulation time is set to 1 second; increase the simulation time to allow for a more comprehensive analysis.

Verify Equalizer on Target

To deploy the equalizer on to the target, follow these steps.

  • Select the Equalizer block, to enable MODEL BLOCK on the Simulink® tool strip.

  • Set the Simulation Mode of the model reference block (Equalizer) to Processor-in-the-Loop (PIL).

Ensure the following parameters are configured in the model reference (Click Open as Top Model in above image). Open Configuration Parameters by pressing Ctrl+E.

  • Hardware Implementation > Hardware board and select Qualcomm Hexagon Simulator.

  • Code Generation > System target file to ert.tlc

  • Code Generation > Build Configuration to Faster Runs

  • Code Generation > Interface > Code replacement libraries include Qualcomm Hexagon QHL.

  • Code Generation > Report > enable Create code generation report

  • Code Generation > Report > enable Summarize which blocks triggered code replacements

  • Code Generation > Verification > enable Measure task execution time

  • Additionally, you can ensure that Code Generation > Verification > enable Measure task execution time parameter in the top model (hexagon_audio_eq.slx) for enabling the profiling.

Once you complete all the configurations, the model is ready to execute the equalizer (model reference) on the target.

sim('HexagonParametricAudioEqualizerDemo','StopTime','1')

You can now use the model to run the equalizer (model reference) on the target.

  • Go to the SIMULATION tab in the tool strip and click on Run. Since the target is set to Qualcomm Hexagon simulator, the simulation may be very slow. To increase simulation efficiency, consider reducing the Stop Time to 1 second.

  • Once the artifacts are built successfully, verify the replacements from the code generation report.

  • You can view code execution metrics from either the Code Profile Analyzer or the Code Execution Profiling Report.

The Total Execution Time In Ticks of the mdlRef step shows consumption of 6,887,178 cycles. Without selecting the Qualcomm Hexagon QHL CRL, total cycles consumed are around 17,148,486, indicating approximately a 2.5x speedup in performance by using this CRL.

Note: For numerical verification, perform a SIL/PIL verification. For more information, see generating optimized C Code for Qualcomm Hexagon DSP using CRL.

More About