Main Content

Implement Biquad and IIR Notch Filter for Noise Filtering Using Android Devices

This example shows how to use the Simulink® Support Package for Android® Devices to implement a biquadratic and notch infinite impulsive response (IIR) filter for noise filtering.

Prerequisites

Required Hardware

  • Android device such as a phone or tablet

  • USB cable

  • Headphones with microphones

Hardware Setup

  1. Connect your Android device to the host computer using the USB cable.

  2. Connect the headphones to your Android device.

Configure androidAudioFilteringNoise Simulink Model and Calibrate Parameters

Open the androidAudioFilteringNoise Simulink model.

Algorithm

The manual switch in the Algorithm area controls the data input to the Biquad filter block. The data input is an audio sine wave signal from the Simulation Sources area or the Audio Capture output from the Android Input area. The Biquad Filter (DSP System Toolbox) block filters each channel of the input signal with the specified biquadratic infinite impulse response filter. Specify the numerator and denominator coefficients of the biquad filter using the Constant blocks.

Configure these parameters in the Block Parameters dialog box of the Biquad Filter (DSP System Toolbox) block.

  1. Set Coefficient source to Input port(s).

  2. Set Scale values mode to Assume all are unity and optimize.

  3. Set Input processing to Columns as channels (frame based).

For more information on how to configure the Simulation Sources, Android Inputs, Display and Visualization, and Android Output areas of the androidAudioFilteringNoise Simulink model, see Implement Bandpass Filter Using Android Devices.

Run androidAudioFilteringNoise Simulink Model

  1. Position the manual switch in the Algorithm area to receive the simulation output from the Sine Wave block in the Simulation Sources area.

  2. On the Simulation tab of the Simulink model, click Run.

  3. Move the slider to change the frequency of the sinusoidal signal and observe the output on the spectrum analyzer and time scope.

Run androidAudioFilteringNoise Simulink Model in External Mode

  1. Position the manual switch in the Algorithm area of the model to receive output from the Sine Wave block in the Simulation Sources area.

  2. On the Hardware tab of the Simulink model, in the Mode section, click Run on board. In the Run on Hardware section, click Monitor & Tune. The androidAudioFilteringNoise application launches automatically on your Android device.

  3. Connect headphones to your Android device and listen to the audio signal.

Deploy androidAudioFilteringNoise Simulink Model on Android Device

1. Position the manual switch in the Algorithm area of the model to receive output from the Sine Wave block in the Simulation Sources area.

2. On the Hardware tab of the Simulink model, in the Mode section, click Run on board. In the Run on Hardware section, click Monitor & Tune. The androidAudioFilteringNoise application launches automatically on your Android device.

3. Connect headphones to your Android device and listen to the audio signal.

4. On the Dashboard tab of the application, change the frequency of the audio signal using the slider.

5. On the App tab of the application, observe the output of the biquad filter.

6. Position the manual switch in the Algorithm area of the model to receive output from the Audio Capture block in the Android Inputs area.

7. Redeploy the Simulink model. The androidAudioFilteringNoise application launches automatically on your Android device.

8. Play a noisy audio file on your mobile phone and place it close to the microphone interfaced with the Android device. Observe the audio signal on the App tab of the application.

Configure androidAudioFilteringNoiseIIRnotch Simulink Model and Calibrate Parameters

This example uses a preconfigured Simulink model from the Simulink Support Package for Android Devices to implement an IIR notch filter for noise filtering. Use this Simulink model to filter noise at a known frequency.

Open the androidAudioFilteringNoiseIIRnotch Simulink model.

Simulation Sources

For simulation purposes, use the default configuration settings for the Audio File Read block.

Algorithm

The Sine Wave block adds noise to the audio signal. The frequency of the noisy audio signal is 300 Hz. The function in the MATLAB Function block calculates the coefficients for the Biquad Filter block for the frequency of 300 Hz and the quality factor of 20.

For more information on how to configure the Android Inputs, Display and Visualization, and Android Output areas of the androidAudioFilteringNoise Simulink model, see Implement Bandpass Filter Using Android Devices.

Run androidAudioFilteringNoiseIIRnotch Simulink Model

1. Position the manual switch in the Algorithm area to receive the simulation output from the Audio File Read block in the Simulation Sources area.

2. On the Simulation tab of the Simulink model, click Run. Observe the Time Scope and Spectrum Analyzer block outputs.

In time scope, the blue signal represents the clean audio signal output.

Deploy androidAudioFilteringNoiseIIRnotch Simulink Model on Android Device

1. Position the manual switch in the Algorithm area of the model to receive output from the Audio File Read block in the Simulation Sources area.

2. On the Hardware tab of the Simulink model, in the Mode section, click Run on board. In the Deploy section, click Build, Deploy & Start. The androidAudioFilteringNoiseIIRnotch application launches automatically on your Android device.

3. On the App tab of the application, observe that after a while a clear audio signal is played.

4. Position the manual switch in the Algorithm area of the model to receive output from the Audio Capture block in the Android Inputs area.

5. Redeploy the Simulink model. The androidAudioFilteringNoiseIIRnotch application launches automatically on your Android device.

6. Play a noisy audio file on your mobile phone and place it close to the microphone interfaced with the Android device.

7. On the App tab of the application, observe the audio signal.

8. Press Bypass to toggle the output between the noisy and clear audio signals. Observe the difference in both these signals.

Other Things to Try

Use the androidAudioFilteringNoiseIIRnotch Simulink model to determine the coefficients of a five-band graphics equalizer. For more information, see Implement Parametric Audio Equalizer on Android Device.

See Also