MATLAB Examples

Parametric Audio Equalizer

This example shows how to use Audio File Read and Audio Playback blocks from the Simulink® Support Package for Android™ Devices to implement a parametric audio equalizer algorithm with a Simulink model and run the model on an Android device to hear and visualize output of it.

Contents

Introduction

Parametric equalizers are used to adjust the frequency response of audio systems. For example, a parametric equalizer can be used to compensate for biases with specific speakers that have peaks and dips at different frequencies.

In this example, you will implement a parametric audio equalizer with a Simulink model and then run that model on an Android device. The parametric equalizer algorithm in this example provides three second-order (bi-quadratic) filters whose coefficients can be adjusted to achieve a desired frequency response. A graphical user interface (GUI) is used in simulation to dynamically adjust filter coefficients and explore behavior.

The following sections will describe how the parametric equalizer algorithm is specified, how the performance can be assessed through simulation, and how the model is run on an Android device. You will also learn how the Audio File Read and Playback blocks are used to input and output audio signals.

Prerequisites

Required Products

  • DSP System Toolbox™

Required Hardware

  • Android device, configured using androidhwsetup
  • USB cable to connect the device to host computer
  • Headphones or speakers

Task 1 - Connect Audio Output

Connect a speaker or headphones to the headphone jack of your Android device. The audio read from file will be equalized on the device and sent to the speakers/headphones.

Task 2 - Configure and Run the Basic Parametric Equalizer Model

In this task, you will configure and run the parametric equalizer model on the device.

1. Open the Basic Parametric Audio Equalizer model.

2. In your Simulink model, click Simulation > Model Configuration Parameters to open Configuration Parameters dialog.

3. Select the Hardware Implementation pane and review the parameters on the page that opens.

4. In the Simulink model, double-click on the Audio File Read block. Note that the File name is set as 'guitartune.wav' and the Frame size is set to 4410. You can find audio sampling frequency which is 44100 Hz, of that audio file on the block mask. With these settings, the Equalizer algorithm processes 4410/44100(Hz) = 0.1 seconds of audio data at each sample time hit.

5. In the model, make sure that the Simulation mode on the toolbar is set to External.

6. In the model, click the Run button on the toolbar to run the model on the device.

Task 3 - Change the Frequency Response of the Parametric Equalizer

1. As the model is running on the device, you will hear audio from the speakers/headphones connected to the device. You will also see gain plotted on device screen.

2. A GUI displaying the frequency response of the audio equalizer will appear as shown in the picture below:

3. Click and drag the markers or lines in the Three Band Equalizer GUI to specify the desired filter response characteristics. Note the change in audio output as the frequency response of the equalizer changes.

4. Press the Stop button on the model to stop model execution.

Other Things to Try

  • Change the volume of the sound sent to speakers/headphones by tuning the appropriate parameter in the model.
  • Change the audio source file in 'Audio File Read' block to your favorite music file.
  • Replace the 'Audio File Read' block with 'Audio Capture' block of Simulink Support Packages for Android Devices.
  • Advanced Parametric Audio Equalizer Example

Summary

This example showed a Simulink model of a parametric audio equalizer. Using External mode, equalizer settings were changed in real-time as the model executed on an Android device.