License: CC BY-NC-SA 4.0
arXiv:2402.06896v1 [eess.SY] 10 Feb 2024

Implementation of Kalman Filter Approach for Active Noise Control by Using MATLAB: Dynamic Noise Cancellation

Abstract

This article offers an elaborate description of a Kalman filter code employed in the active control system. Conventional active noise management methods usually employ an adaptive filter, such as the filtered reference least mean square (FxLMS) algorithm, to adjust to changes in the primary noise and acoustic environment. Nevertheless, the slow convergence characteristics of the FxLMS algorithm typically impact the effectiveness of reducing dynamic noise. Hence, this study suggests employing the Kalman filter in the active noise control (ANC) system to enhance the efficacy of noise reduction for dynamic noise. The ANC application effectively utilizes the Kalman filter with a novel dynamic ANC model. The numerical simulation revealed that the proposed Kalman filter exhibits superior convergence performance compared to the FxLMS algorithm for handling dynamic noise. The code is available on GitHub and MathWorks.

\criartitulo

1 Introduction

Active Noise Control (ANC) represents an advanced methodology for mitigating undesirable acoustic phenomena through the deployment of controlled anti-noise signals, which neutralize the primary noise via destructive interference—a nuanced application of the superposition principle within wave physics [1, 2]. The effectiveness of ANC in attenuating low-frequency noise, coupled with its compact form factor, has facilitated its widespread adoption across various domains where noise interference poses significant challenges, including but not limited to, headphones [3, 4, 5, 6, 7, 8], automotive industries, and architectural acoustics [9, 10, 11, 12, 13, 14, 15, 16, 17].

With the development of the adaptive filter theory, many adaptive algorithms have gradually evolved to be applied in the active noise control field. These derivative algorithms empower the ANC system with the ability to adapt to the variations of the noise and acoustic environments [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39]. Moreover, because these algorithms usually aim to realize optimal control, the adaptive ANC system also has the potential to achieve the best noise reduction. During these algorithms, the filtered reference least mean square (FxLMS) algorithm plays a central role in implementing the real-time ANC system due to its high computational efficiency. Its derivative algorithms also prevail in practical applications to solve different engineering problems.

However, these active control algorithms based on the least mean square (LMS) class still encounter an inherent issue: their sluggish convergence impacts the adaptive ANC system’s ability to effectively reduce dynamic noise. The slow convergence of the ANC system also impacts consumers’ perception of rapidly changing noises. Although some modified algorithms improve the response speed of the ANC system to quickly varying noise [40, 41, 42, 43, 44, 45, 46, 47, 48, 49], they are still feeble to cope with some dynamic and non-stationary noises.

The Kalman filter is known for its superior ability to track dynamic and non-stationary noise compared to traditional adaptive filter methods. Therefore, it appears to be a highly suitable choice for enhancing the convergence performance of the adaptive ANC system. However, the Kalman filter cannot be directly applied in ANC applications without an appropriate model. Hence, this study presents an innovative active noise control (ANC) dynamic model specifically designed for the Kalman filter. Moreover, the altered ANC structure is employed to implement this Kalman filter technique. The numerical simulation results confirm the efficacy of the proposed strategy. The proposed method exhibits significantly accelerated convergence speed in attenuating dynamic noise in comparison to the conventional FxLMS algorithm.

2 Filtered-x least mean square (FxLMS) algorithm

The filtered-x least mean square (FxLMS) is among the most practical adaptive algorithms proposed to compensate for the influence of the secondary path in an ANC system. This section introduces the FxLMS algorithm used in feedforward single- and multichannel ANC applications. The block diagram of FxLMS algorithm is illustrated in Fig. 1. In the figure, P(z)𝑃𝑧P(z)italic_P ( italic_z ) denotes the transfer function of the primary path from the reference microphone to the error microphone; W(z)𝑊𝑧W(z)italic_W ( italic_z ) represents the control filter; S(z)𝑆𝑧S(z)italic_S ( italic_z ) stands for the transfer function of the secondary path from the secondary source to the error microphone, and its estimation is S^(z)^𝑆𝑧\hat{S}(z)over^ start_ARG italic_S end_ARG ( italic_z ).

Refer to caption
Figure 1: Block diagram of the FxLMS algorithm applied in a single-channel feedforward ANC system. (1) Green color denotes the acoustic field, and (2) Blue color denotes the digital field [50].

The vector 𝐱(n)𝐱𝑛\mathbf{x}(n)bold_x ( italic_n ) represents the reference signal and is defined as [x(n),x(n1),,x(nN+1)]𝑥𝑛𝑥𝑛1𝑥𝑛𝑁1\left[x(n),x(n-1),\cdots,x(n-N+1)\right][ italic_x ( italic_n ) , italic_x ( italic_n - 1 ) , ⋯ , italic_x ( italic_n - italic_N + 1 ) ]. Let TT\mathrm{T}roman_T denote the transpose operation and N𝑁Nitalic_N represent the length of the control filter. Therefore, the resultant output of the control filter is

y(n)=𝐰T(n)𝐱(n)𝑦𝑛superscript𝐰T𝑛𝐱𝑛y(n)=\mathbf{w}^{\mathrm{T}}(n)\mathbf{x}(n)italic_y ( italic_n ) = bold_w start_POSTSUPERSCRIPT roman_T end_POSTSUPERSCRIPT ( italic_n ) bold_x ( italic_n ) (1)

where, 𝐰(n)𝐰𝑛\mathbf{w}(n)bold_w ( italic_n ) represents the coefficient vector of the control filter. The residual error signal can be expressed as

e(n)=d(n)s(n)[𝐰T(n)𝐱(n)]𝑒𝑛𝑑𝑛𝑠𝑛delimited-[]superscript𝐰T𝑛𝐱𝑛e(n)=d(n)-s(n)\ast\left[\mathbf{w}^{\mathrm{T}}(n)\mathbf{x}(n)\right]italic_e ( italic_n ) = italic_d ( italic_n ) - italic_s ( italic_n ) ∗ [ bold_w start_POSTSUPERSCRIPT roman_T end_POSTSUPERSCRIPT ( italic_n ) bold_x ( italic_n ) ] (2)

where, d(n)𝑑𝑛d(n)italic_d ( italic_n ) and s(n)𝑠𝑛s(n)italic_s ( italic_n ) denote the primary disturbance and the impulse response of secondary path, respectively; \ast is the linear convolution. To minimize the instantaneous squared error, J(n)=e2(n)𝐽𝑛superscript𝑒2𝑛J(n)=e^{2}(n)italic_J ( italic_n ) = italic_e start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ( italic_n ), the most widely used method to achieve this objective is the gradient descent method, which updates the coefficient vector in the negative gradient direction with step size μ𝜇\muitalic_μ:

𝐰(n+1)=𝐰(n)μ2J(n)𝐰𝑛1𝐰𝑛𝜇2𝐽𝑛\mathbf{w}(n+1)=\mathbf{w}(n)-\frac{\mu}{2}\nabla J(n)bold_w ( italic_n + 1 ) = bold_w ( italic_n ) - divide start_ARG italic_μ end_ARG start_ARG 2 end_ARG ∇ italic_J ( italic_n ) (3)

where J(n)𝐽𝑛\nabla J(n)∇ italic_J ( italic_n ) denotes the instantaneous estimate of the MSE gradient at time n𝑛nitalic_n, and can be expressed as

J(n)=e2(n)=2𝐱(n)e(n).𝐽𝑛superscript𝑒2𝑛2superscript𝐱𝑛𝑒𝑛\nabla J(n)=\nabla e^{2}(n)=-2\mathbf{x}^{\prime}(n)e(n).∇ italic_J ( italic_n ) = ∇ italic_e start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT ( italic_n ) = - 2 bold_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ( italic_n ) italic_e ( italic_n ) . (4)

The filtered reference signal vector is given by

𝐱(n)=s^(n)𝐱(n)superscript𝐱𝑛^𝑠𝑛𝐱𝑛\mathbf{x}^{\prime}(n)=\hat{s}(n)\ast\mathbf{x}(n)bold_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ( italic_n ) = over^ start_ARG italic_s end_ARG ( italic_n ) ∗ bold_x ( italic_n ) (5)

where we replace the impulse response s(n)𝑠𝑛s(n)italic_s ( italic_n ) with its estimate s^(n)^𝑠𝑛\hat{s}(n)over^ start_ARG italic_s end_ARG ( italic_n ). Hence, substituting (4) and (5) into (3) yields the update equation of the FxLMS algorithm

𝐰(n+1)=𝐰(n)+μe(n)𝐱(n).𝐰𝑛1𝐰𝑛𝜇𝑒𝑛superscript𝐱𝑛\mathbf{w}(n+1)=\mathbf{w}(n)+\mu e(n)\mathbf{x}^{\prime}(n).bold_w ( italic_n + 1 ) = bold_w ( italic_n ) + italic_μ italic_e ( italic_n ) bold_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ( italic_n ) . (6)

If the group delay of the secondary path is assumed to be Dssubscript𝐷sD_{\mathrm{s}}italic_D start_POSTSUBSCRIPT roman_s end_POSTSUBSCRIPT, the bound of the step size μ𝜇\muitalic_μ in the FxLMS algorithm is given by

0<μ<1λmaxDs0𝜇1subscript𝜆maxsubscript𝐷s0<\mu<\frac{1}{\lambda_{\mathrm{max}}D_{\mathrm{s}}}0 < italic_μ < divide start_ARG 1 end_ARG start_ARG italic_λ start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT italic_D start_POSTSUBSCRIPT roman_s end_POSTSUBSCRIPT end_ARG (7)

where λmaxsubscript𝜆max\lambda_{\mathrm{max}}italic_λ start_POSTSUBSCRIPT roman_max end_POSTSUBSCRIPT represents the maximum eigenvalue of the auto-correlation matrix R𝐱=𝔼[𝐱T(n)𝐱(n)]subscript𝑅superscript𝐱𝔼delimited-[]superscriptsuperscript𝐱T𝑛superscript𝐱𝑛R_{\mathrm{\mathbf{x}^{\prime}}}=\mathbb{E}[\mathbf{x^{\prime}}^{\mathrm{T}}(n% )\mathbf{x^{\prime}}(n)]italic_R start_POSTSUBSCRIPT bold_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT end_POSTSUBSCRIPT = blackboard_E [ bold_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT start_POSTSUPERSCRIPT roman_T end_POSTSUPERSCRIPT ( italic_n ) bold_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ( italic_n ) ] of the filtered reference signal.

3 Kalman Filter Approach for Active Noise Control

Refer to caption
Figure 2: Block diagram of the modified ANC structure based on the FxLMS algorithm [51]

Another renowned approach for adaptive active noise reduction is the modified FxLMS algorithm, depicted in Figure 2. The internal model technique utilizes the secondary path estimate to recover the disturbance from the error signal, enabling the use of the traditional least mean square (LMS) algorithm for noise control. This altered configuration can also be employed to implement the Kalman filter methodology, wherein the LMS model is substituted with the Kalman filter to complete the updating of the control filter.

In order to employ the Kalman filter methodology, the initial step entails establishing the state function. The subsequent paragraphs will elucidate the state function definition of the ANC system. As we know, when the adaptive algorithm converges, the ANC system should achieve the optimal control filter, which is a constant solution:

𝐰(n+1)=𝐰(n)=𝐰o,𝐰𝑛1𝐰𝑛subscript𝐰o\mathbf{w}(n+1)=\mathbf{w}(n)=\mathbf{w}_{\text{o}},bold_w ( italic_n + 1 ) = bold_w ( italic_n ) = bold_w start_POSTSUBSCRIPT o end_POSTSUBSCRIPT , (8)

where 𝐰osubscript𝐰o\mathbf{w}_{\text{o}}bold_w start_POSTSUBSCRIPT o end_POSTSUBSCRIPT denotes the optimal control filter. Meanwhile, the attenuated noise can be expressed as

eo(n)=d(n)i=0L1s^l𝐱T(ni)𝐰o(n),subscript𝑒o𝑛𝑑𝑛subscriptsuperscript𝐿1𝑖0subscript^𝑠𝑙superscript𝐱T𝑛𝑖subscript𝐰o𝑛e_{\mathrm{o}}(n)=d(n)-\sum^{L-1}_{i=0}\hat{s}_{l}\mathbf{x}^{\mathrm{T}}(n-i)% \mathbf{w}_{\mathrm{o}}(n),italic_e start_POSTSUBSCRIPT roman_o end_POSTSUBSCRIPT ( italic_n ) = italic_d ( italic_n ) - ∑ start_POSTSUPERSCRIPT italic_L - 1 end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_i = 0 end_POSTSUBSCRIPT over^ start_ARG italic_s end_ARG start_POSTSUBSCRIPT italic_l end_POSTSUBSCRIPT bold_x start_POSTSUPERSCRIPT roman_T end_POSTSUPERSCRIPT ( italic_n - italic_i ) bold_w start_POSTSUBSCRIPT roman_o end_POSTSUBSCRIPT ( italic_n ) , (9)

where d(n)𝑑𝑛d(n)italic_d ( italic_n ) and 𝐱(n)superscript𝐱𝑛\mathbf{x}^{\prime}(n)bold_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ( italic_n ) represent the disturbance signal and the reference vector, respectively, and s^^𝑠\hat{s}over^ start_ARG italic_s end_ARG stands for the i𝑖iitalic_i-th coefficient of the secondary path estimate. Since the optimal control filter is a constant vector, (9) can be rewritten to

d(n)=𝐱T(n)𝐰o(n)+eo(n),𝑑𝑛superscriptsuperscript𝐱T𝑛subscript𝐰o𝑛subscript𝑒o𝑛d(n)={\mathbf{x}^{\prime}}^{\mathrm{T}}(n)\mathbf{w}_{\mathrm{o}}(n)+e_{% \mathrm{o}}(n),italic_d ( italic_n ) = bold_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT start_POSTSUPERSCRIPT roman_T end_POSTSUPERSCRIPT ( italic_n ) bold_w start_POSTSUBSCRIPT roman_o end_POSTSUBSCRIPT ( italic_n ) + italic_e start_POSTSUBSCRIPT roman_o end_POSTSUBSCRIPT ( italic_n ) , (10)

and the filtered reference signal is given by

𝐱(n)=i=0L1s^i𝐱(ni).superscript𝐱𝑛subscriptsuperscript𝐿1𝑖0subscript^𝑠𝑖𝐱𝑛𝑖\mathbf{x}^{\prime}(n)=\sum^{L-1}_{i=0}\hat{s}_{i}\mathbf{x}(n-i).bold_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ( italic_n ) = ∑ start_POSTSUPERSCRIPT italic_L - 1 end_POSTSUPERSCRIPT start_POSTSUBSCRIPT italic_i = 0 end_POSTSUBSCRIPT over^ start_ARG italic_s end_ARG start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT bold_x ( italic_n - italic_i ) . (11)
Refer to caption
Figure 3: Signal-flow graph representation of a linear, discrete-time dynamic ANC model

It is natural to let (8) and (10) be the state equation and the observation equation, respectively, as shown in Figure 3. The Kalman filter recursive equations are listed as

  1. 1.

    The prediction for the new state:

    𝐰^(n)=𝐰(n1)N×1.^𝐰𝑛𝐰𝑛1superscript𝑁1\hat{\mathbf{w}}(n)=\mathbf{w}(n-1)\in\mathbb{R}^{N\times 1}.over^ start_ARG bold_w end_ARG ( italic_n ) = bold_w ( italic_n - 1 ) ∈ blackboard_R start_POSTSUPERSCRIPT italic_N × 1 end_POSTSUPERSCRIPT . (12)

    where N𝑁Nitalic_N denotes the length of the control filter.

  2. 2.

    The prediction of the auto-correlation matrix of the state error:

    𝐏(n,n1)=𝐏(nn)N×N.𝐏𝑛𝑛1𝐏𝑛𝑛superscript𝑁𝑁\mathbf{P}(n,n-1)=\mathbf{P}(n-n)\in\mathbb{R}^{N\times N}.bold_P ( italic_n , italic_n - 1 ) = bold_P ( italic_n - italic_n ) ∈ blackboard_R start_POSTSUPERSCRIPT italic_N × italic_N end_POSTSUPERSCRIPT . (13)

    Here, we assumed that the variance of the final state error equals 00.

  3. 3.

    The Kalman gain matrix is obtained from

    𝐊(n)=𝐏(n,n1)𝐱(n)[𝐱(n)T𝐏(n,n1)𝐱(n)+q(n)]1,𝐊𝑛𝐏𝑛𝑛1superscript𝐱𝑛superscriptdelimited-[]superscript𝐱superscript𝑛T𝐏𝑛𝑛1superscript𝐱𝑛𝑞𝑛1\mathbf{K}(n)=\mathbf{P}(n,n-1)\mathbf{x}^{\prime}(n)\left[\mathbf{x}^{\prime}% (n)^{\mathrm{T}}\mathbf{P}(n,n-1)\mathbf{x}^{\prime}(n)+q(n)\right]^{-1},bold_K ( italic_n ) = bold_P ( italic_n , italic_n - 1 ) bold_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ( italic_n ) [ bold_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ( italic_n ) start_POSTSUPERSCRIPT roman_T end_POSTSUPERSCRIPT bold_P ( italic_n , italic_n - 1 ) bold_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ( italic_n ) + italic_q ( italic_n ) ] start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT , (14)

    where q(n)𝑞𝑛q(n)italic_q ( italic_n ) denotes the variance of the observe error:

    q(n)=𝔼[eo2(n)].𝑞𝑛𝔼delimited-[]subscriptsuperscript𝑒2o𝑛q(n)=\mathbb{E}[e^{2}_{\mathrm{o}}(n)].italic_q ( italic_n ) = blackboard_E [ italic_e start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT start_POSTSUBSCRIPT roman_o end_POSTSUBSCRIPT ( italic_n ) ] . (15)
  4. 4.

    The estimate of the state is given by

    𝐰(n)=𝐰^(n)+𝐊(n)[d(n)𝐱(n)T𝐰^(n)].𝐰𝑛^𝐰𝑛𝐊𝑛delimited-[]𝑑𝑛superscript𝐱superscript𝑛T^𝐰𝑛\mathbf{w}(n)=\hat{\mathbf{w}}(n)+\mathbf{K}(n)\left[d(n)-\mathbf{x}^{\prime}(% n)^{\mathrm{T}}\hat{\mathbf{w}}(n)\right].bold_w ( italic_n ) = over^ start_ARG bold_w end_ARG ( italic_n ) + bold_K ( italic_n ) [ italic_d ( italic_n ) - bold_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ( italic_n ) start_POSTSUPERSCRIPT roman_T end_POSTSUPERSCRIPT over^ start_ARG bold_w end_ARG ( italic_n ) ] . (16)
  5. 5.

    The auto-correlation matrix of the state error:

    𝐏(n)=[𝐈𝐊(n)𝐱(n)T]𝐏(n,n1).𝐏𝑛delimited-[]𝐈𝐊𝑛superscript𝐱superscript𝑛T𝐏𝑛𝑛1\mathbf{P}(n)=\left[\mathbf{I}-\mathbf{K}(n)\mathbf{x}^{\prime}(n)^{\mathrm{T}% }\right]\mathbf{P}(n,n-1).bold_P ( italic_n ) = [ bold_I - bold_K ( italic_n ) bold_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ( italic_n ) start_POSTSUPERSCRIPT roman_T end_POSTSUPERSCRIPT ] bold_P ( italic_n , italic_n - 1 ) . (17)

Therefore, the whole Kalman filter algorithm can be summarized as

Algorithm 3.1: Kalman filter algorithm The predicted novel state: 𝐰^(n)=𝐰(n1)^𝐰𝑛𝐰𝑛1\hat{\mathbf{w}}(n)=\mathbf{w}(n-1)over^ start_ARG bold_w end_ARG ( italic_n ) = bold_w ( italic_n - 1 ) The predicted state-error auto-correlation matrix: 𝐏(n,n1)=𝐏(nn)𝐏𝑛𝑛1𝐏𝑛𝑛\mathbf{P}(n,n-1)=\mathbf{P}(n-n)bold_P ( italic_n , italic_n - 1 ) = bold_P ( italic_n - italic_n ) Kalman gain: 𝐊(n)=𝐏(n,n1)𝐱(n)[𝐱(n)T𝐏(n,n1)𝐱(n)+q(n)]1𝐊𝑛𝐏𝑛𝑛1superscript𝐱𝑛superscriptdelimited-[]superscript𝐱superscript𝑛T𝐏𝑛𝑛1superscript𝐱𝑛𝑞𝑛1\mathbf{K}(n)=\mathbf{P}(n,n-1)\mathbf{x}^{\prime}(n)\left[\mathbf{x}^{\prime}% (n)^{\mathrm{T}}\mathbf{P}(n,n-1)\mathbf{x}^{\prime}(n)+q(n)\right]^{-1}bold_K ( italic_n ) = bold_P ( italic_n , italic_n - 1 ) bold_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ( italic_n ) [ bold_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ( italic_n ) start_POSTSUPERSCRIPT roman_T end_POSTSUPERSCRIPT bold_P ( italic_n , italic_n - 1 ) bold_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ( italic_n ) + italic_q ( italic_n ) ] start_POSTSUPERSCRIPT - 1 end_POSTSUPERSCRIPT The estimated state: 𝐰(n)=𝐰^(n)+𝐊(n)[d(n)𝐱(n)T𝐰^(n)]𝐰𝑛^𝐰𝑛𝐊𝑛delimited-[]𝑑𝑛superscript𝐱superscript𝑛T^𝐰𝑛\mathbf{w}(n)=\hat{\mathbf{w}}(n)+\mathbf{K}(n)\left[d(n)-\mathbf{x}^{\prime}(% n)^{\mathrm{T}}\hat{\mathbf{w}}(n)\right]bold_w ( italic_n ) = over^ start_ARG bold_w end_ARG ( italic_n ) + bold_K ( italic_n ) [ italic_d ( italic_n ) - bold_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ( italic_n ) start_POSTSUPERSCRIPT roman_T end_POSTSUPERSCRIPT over^ start_ARG bold_w end_ARG ( italic_n ) ] The state-error auto-correlation matrix: 𝐏(n)=[𝐈𝐊(n)𝐱(n)T]𝐏(n,n1).𝐏𝑛delimited-[]𝐈𝐊𝑛superscript𝐱superscript𝑛T𝐏𝑛𝑛1\mathbf{P}(n)=\left[\mathbf{I}-\mathbf{K}(n)\mathbf{x}^{\prime}(n)^{\mathrm{T}% }\right]\mathbf{P}(n,n-1).bold_P ( italic_n ) = [ bold_I - bold_K ( italic_n ) bold_x start_POSTSUPERSCRIPT ′ end_POSTSUPERSCRIPT ( italic_n ) start_POSTSUPERSCRIPT roman_T end_POSTSUPERSCRIPT ] bold_P ( italic_n , italic_n - 1 ) .

It should be emphasized that the algorithm assumes a variance of 00 for the state error, while still accounting for the observed error. This implies that the control filter’s transition has a greater level of confidence compared to the observation function. Certainly, the user can also modify the two variations while controlling the process, based on the particular application.

4 Code Explanation

The section provides a concise introduction to the KF.matformulae-sequence𝐾𝐹𝑚𝑎𝑡KF.matitalic_K italic_F . italic_m italic_a italic_t file, which implements the Kalman filter method for a single-channel active noise control (ANC) application. Furthermore, the FxLMS algorithm is conducted as a comparative analysis. The Kalman filter technique employs the modified feed-forward active noise control (ANC) structure, whereas the FxLMS algorithm uses the conventional feed-forward ANC structure.

4.1 Cleaning the memory and workspace

This segment of code is utilized to clean the memory and workspace of the MATLAB software.

1close all ;
2clear     ;
3clc       ;

4.2 Loading the primary and secondary path

This part of the code loads the primary path and secondary path from the Mat files: PriPath_3200.matformulae-sequence𝑃𝑟𝑖𝑃𝑎𝑡_3200𝑚𝑎𝑡PriPath\_3200.matitalic_P italic_r italic_i italic_P italic_a italic_t italic_h _ 3200 . italic_m italic_a italic_t and SecPath_200_6000.matformulae-sequence𝑆𝑒𝑐𝑃𝑎𝑡_200_6000𝑚𝑎𝑡SecPath\_200\_6000.matitalic_S italic_e italic_c italic_P italic_a italic_t italic_h _ 200 _ 6000 . italic_m italic_a italic_t. All these paths are synthesized from the band-pass filters, whose impulse responses are illustrated in Figure 4.

1load(’PriPath_3200.mat’);
2load(’SecPath_200_6000.mat’);
3figure;
4subplot(2,1,1)
5plot(PriPath);
6title(’PrimaryPath’);
7gridon␣␣␣␣␣␣;
8subplot(2,1,2);
9plot(SecPath);
10title(’SecondaryPath’);
11xlabel(’Taps’);
12gridon␣␣␣␣␣␣;
Refer to caption
Figure 4: The impulse response of the primary path and the secondary path.

4.3 Simulation system configuration

The sampling rate of the active noise control (ANC) system is set to 16000160001600016000 Hz, and the simulation duration is 0.250.250.250.25 second. To simulate the dynamic noise, the primary noise in this ANC system is a chirp signal, whose frequency gradually varies from 20202020 Hz to 1600160016001600 Hz, as shown in Figure 5.

Parameter Definition Parameter Definition
fs Sampling rate T Simulation duration
y Primary noise N Simulation taps
1fs = 16000     ; % sampling rate 16 kHz.
2T  = 0.25      ; % Simulation duration (seconds).
3t  = 0:1/fs:T  ;% Time variable.
4N  = length(t) ;
5fw = 500       ;
6fe = 300       ;
7y = chirp(t,20,T,1600);
8figure   ;
9plot(t,y);
10title(’Referencesignalx(n)’);
11xlabel(’Time(seconds)’);
12ylabel(’Magnitude’)␣␣␣␣␣␣;
13axis([-infinf-1.051.05]);
14gridon;
Refer to caption
Figure 5: The waveform of the reference signal that is a chirp signal ranging from 20202020 to 1600160016001600 Hz.

4.4 Creating the disturbance and filtered reference

The disturbance and filtered reference used in the ANC system are created by passing the chirp signal through the loaded primary and secondary paths.

Parameter Definition Parameter Definition
X Reference signal vector y Primary noise
D Disturbance vector PriPath Primary path vector
Rf Filtered reference vector SecPath Secondary path vector
1%X  = 0.4*sin(2*pi*fw*t)+0.3*sin(2*pi*fe*t);
2X = y;
3%plot(X(end-100:end))
4D  = filter(PriPath,1,X);
5Rf = filter(SecPath,1,X);
6%plot(D(end-100:end))

4.5 Dynamic noise cancellation by the single-channel FxLMS algorithm

In this part, the single-channel FxLMS algorithm is used to reduce the chirp disturbance. The length of the control filter in the FxLMS algorithm has 80808080 taps, and the step size is set to 0.00050.00050.00050.0005. Figure 6 shows the error signal picked up by the error sensor in the ANC system. This figure shows that the FxLMS algorithm can not fully attenuate this dynamic noise during the 0.250.250.250.25 second.

Parameter Definition Parameter Definition
X Reference signal vector y Control signal
D Disturbance vector e Error signal
L Length of the control filter muW Step size
1L   = 80    ;
2muW = 0.0005;
3noiseController = dsp.FilteredXLMSFilter(’Length’,L,’StepSize’,muW,...
4␣␣␣␣’SecondaryPathCoefficients’,SecPath);
5[y,e]=noiseController(X,D);
6figure;
7plot(t,e);
8title(’FxLMSalgorithm’)␣␣␣;
9ylabel(’Errorsignale(n)’);
10xlabel(’Time(seconds)’)␣␣␣;
11gridon;
Refer to caption
Figure 6: The error signal of the single-channel ANC system based on the FxLMS algorithm.

4.6 Dynamic noise cancellation by the Kalman filter approach

The Kalman filter is employed in the signal-channel ANC system to track the fluctuation of the chirp disturbance. The variance of the observed noise is initially set to 0.0050.0050.0050.005, and the auto-correlation matrix of the state error is initially set to 𝐈𝐈\mathbf{I}bold_I, respectively. Figure 7 shows the error signal of the Kalman filter algorithm. Additionally, Figure 8 illustrates the variation of the coefficients w5(n)subscript𝑤5𝑛w_{5}(n)italic_w start_POSTSUBSCRIPT 5 end_POSTSUBSCRIPT ( italic_n ) and w60(n)subscript𝑤60𝑛w_{60}(n)italic_w start_POSTSUBSCRIPT 60 end_POSTSUBSCRIPT ( italic_n ) as time progresses. The outcome illustrates that the Kalman filter effectively mitigates the chirp disturbances. The Kalman filter approach has markedly superior convergence behavior compared to the FxLMS method, as illustrated in Figure 9.

Parameter Definition Parameter Definition
q Variance of observe error P Cross-correlation matrix of state error
W Control filter ek Error signal
Xd Input vector yt Anti-noise
Rf Reference signal vector
1q  = 0.005;
2P  = eye(L);
3W  = zeros(L,1);
4Xd = zeros(L,1);
5ek = zeros(N,1);
6w5 = zeros(N,1);
7w60 = zeros(N,1);
8
9%-----------Kalman Filer---------
10for ii =1:N
11    Xd     =[Rf(ii);Xd(1:end-1)];
12    yt     = Xd’*W;
13␣␣␣␣ek(ii)=D(ii)-yt;
14␣␣␣␣K␣␣␣␣␣␣=P*Xd/(Xd’*P*Xd+q);
15␣␣␣␣W␣␣␣␣␣␣=W+K*ek(ii)␣␣␣␣␣␣␣␣;
16␣␣␣␣P␣␣␣␣␣␣=(eye(L)-K*Xd’)*P␣␣␣␣;
17␣␣␣␣%---------------------------
18␣␣␣␣w5(ii)␣␣=W(5);
19␣␣␣␣w60(ii)=W(60);
20␣␣␣␣%---------------------------
21end
22%-------------------------------
23figure;
24plot(t,ek);
25title(’Kalmanalgorithm’)␣␣␣;
26ylabel(’Errorsignale(n)’);
27xlabel(’Time(seconds)’)
28gridon;
29figure
30plot(t,w5,t,w60);
31title(’ControlFilterWeights’);
32xlabel(’Time(seconds)’);
33legend(’w_5’,’w_{60}’);
34gridon;
35figure;
36plot(t,e,t,ek);
37title(’FxLMSvsKalman’)␣␣␣;
38ylabel(’Errorsignale(n)’);
39xlabel(’Time(seconds)’)␣␣␣;
40legend(’FxLMSalgorithm’,’KFalgorithm’);
41gridon;
Refer to caption
Figure 7: The error signal of the single-channel ANC system based on the Kalman filter.
Refer to caption
Figure 8: The time history of the coefficients w5(n)subscript𝑤5𝑛w_{5}(n)italic_w start_POSTSUBSCRIPT 5 end_POSTSUBSCRIPT ( italic_n ) and w60(n)subscript𝑤60𝑛w_{60}(n)italic_w start_POSTSUBSCRIPT 60 end_POSTSUBSCRIPT ( italic_n ) in the control filter.
Refer to caption
Figure 9: Comparison of the error signals in the FxLMS algorithm and the Kalman filter.

5 Conclusion

This document provides a detailed introduction to the Kalman filter code used in the active control system. Traditional active noise control typically adapts the adaptive filter, such as the filtered reference least mean square (FxLMS) algorithm, to adapt to the variations of the primary noise and acoustic environment. However, the sluggish convergence behavior of the FxLMS algorithm usually affects the noise reduction for the dynamic noise. Therefore, this work proposes using the Kalman filter in the ANC system to improve the noise reduction performance for dynamic noise. With a novel dynamic ANC model, the Kalman filter is excellently deployed in the ANC application. The numerical simulation demonstrated that the proposed Kalman filter has a much better convergence performance than the FxLMS algorithm in dealing with dynamic noise.

References

  • [1] Bhan Lam et al. “Ten questions concerning active noise control in the built environment” In Building and Environment 200 Pergamon, 2021, pp. 107928
  • [2] Dongyuan Shi et al. “Active noise control in the new century: The role and prospect of signal processing” In INTER-NOISE and NOISE-CON Congress and Conference Proceedings 268.3, 2023, pp. 5141–5151 Institute of Noise Control Engineering
  • [3] Xiaoyi Shen, Dongyuan Shi, Santi Peksi and Woon-Seng Gan “Implementations of wireless active noise control in the headrest” In INTER-NOISE and NOISE-CON Congress and Conference Proceedings 265.4, 2023, pp. 3445–3455 Institute of Noise Control Engineering
  • [4] Xiaoyi Shen, Dongyuan Shi, Santi Peksi and Woon-Seng Gan “A multi-channel wireless active noise control headphone with coherence-based weight determination algorithm” In Journal of Signal Processing Systems 94.8 Springer US New York, 2022, pp. 811–819
  • [5] Xiaoyi Shen, Dongyuan Shi and Woon-Seng Gan “A hybrid approach to combine wireless and earcup microphones for ANC headphones with error separation module” In ICASSP 2022-2022 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), 2022, pp. 8702–8706 IEEE
  • [6] Xiaoyi Shen, Dongyuan Shi, Woon-Seng Gan and Santi Peksi “Adaptive-gain algorithm on the fixed filters applied for active noise control headphone” In Mechanical Systems and Signal Processing 169 Academic Press, 2022, pp. 108641
  • [7] Xiaoyi Shen, Woon-Seng Gan and Dongyuan Shi “Alternative switching hybrid ANC” In Applied Acoustics 173 Elsevier, 2021, pp. 107712
  • [8] Xiaoyi Shen, Dongyuan Shi and Woon-Seng Gan “A wireless reference active noise control headphone using coherence based selection technique” In ICASSP 2021-2021 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), 2021, pp. 7983–7987 IEEE
  • [9] Bhan Lam, Chuang Shi, Dongyuan Shi and Woon-Seng Gan “Active control of sound through full-sized open windows” In Building and Environment 141 Elsevier, 2018, pp. 16–27
  • [10] Bhan Lam et al. “Active control of broadband sound through the open aperture of a full-sized domestic window” In Scientific reports 10.1 Nature Publishing Group, 2020, pp. 1–7
  • [11] Bhan Lam et al. “Active control of low-frequency noise through a single top-hung window in a full-sized room” In Applied Sciences 10.19 MDPI, 2020, pp. 6817
  • [12] Bhan Lam et al. “Anti-noise window: Subjective perception of active noise reduction and effect of informational masking” In Sustainable Cities and Society 97 Elsevier, 2023, pp. 104763
  • [13] Chuang Shi et al. “On algorithms and implementations of a 4-channel active noise canceling window” In 2017 International Symposium on Intelligent Signal Processing and Communication Systems (ISPACS), 2017, pp. 217–221 IEEE
  • [14] Rina Hasegawa, Dongyuan Shi, Yoshinobu Kajikawa and Woon-Seng Gan “Window active noise control system with virtual sensing technique” In INTER-NOISE and NOISE-CON Congress and Conference Proceedings 258.1, 2018, pp. 6004–6012 Institute of Noise Control Engineering
  • [15] Chuang Shi et al. “Understanding multiple-input multiple-output active noise control from a perspective of sampling and reconstruction” In 2017 Asia-Pacific Signal and Information Processing Association Annual Summit and Conference (APSIPA ASC), 2017, pp. 124–129 IEEE
  • [16] Chung Kwan Lai, **g Sheng Tey, Dongyuan Shi and Woon-Seng Gan “Robust estimation of open aperture active control systems using virtual sensing” In INTER-NOISE and NOISE-CON Congress and Conference Proceedings 265.4, 2023, pp. 3397–3407 Institute of Noise Control Engineering
  • [17] Chuang Shi et al. “Open loop active control of noise through open windows” In Proceedings of Meetings on Acoustics 29.1, 2016 AIP Publishing
  • [18] Dongyuan Shi, Chuang Shi and Woon-Seng Gan “A systolic FxLMS structure for implementation of feedforward active noise control on FPGA” In 2016 Asia-Pacific Signal and Information Processing Association Annual Summit and Conference (APSIPA), 2016, pp. 1–6 IEEE
  • [19] DongYuan Shi, Woon-Seng Gan, Bhan Lam and Chuang Shi “Two-gradient direction FXLMS: An adaptive active noise control algorithm with output constraint” In Mechanical Systems and Signal Processing 116 Elsevier, 2019, pp. 651–667
  • [20] Shulin Wen, Woon-Seng Gan and Dongyuan Shi “Convergence behavior analysis of FXLMS algorithm with different leaky term” In INTER-NOISE and NOISE-CON Congress and Conference Proceedings 261.6, 2020, pp. 728–739 Institute of Noise Control Engineering
  • [21] Dongyuan Shi, Woon-Seng Gan, Jianjun He and Bhan Lam “Practical implementation of multichannel filtered-x least mean square algorithm based on the multiple-parallel-branch with folding architecture for large-scale active noise control” In IEEE Transactions on Very Large Scale Integration (VLSI) Systems 28.4 IEEE, 2019, pp. 940–953
  • [22] Zhengding Luo, Dongyuan Shi, Junwei Ji and Woon-seng Gan “Implementation of multi-channel active noise control based on back-propagation mechanism” In arXiv preprint arXiv:2208.08086, 2022
  • [23] Dongyuan Shi et al. “Multiple parallel branch with folding architecture for multichannel filtered-x least mean square algorithm” In 2017 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), 2017, pp. 1188–1192 IEEE
  • [24] Dongyuan Shi, Bhan Lam, Woon-Seng Gan and Shulin Wen “Block coordinate descent based algorithm for computational complexity reduction in multichannel active noise control system” In Mechanical Systems and Signal Processing 151.0888-3270 Academic Press, 2021, pp. 107346
  • [25] Dongyuan Shi, Bhan Lam and Woon-seng Gan “Analysis of multichannel virtual sensing active noise control to overcome spatial correlation and causality constraints” In ICASSP 2019-2019 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), 2019, pp. 8499–8503 IEEE
  • [26] Dongyuan Shi et al. “Active Noise Control based on the Momentum Multichannel Normalized Filtered-x Least Mean Square Algorithm” In In Inter-Noise 2020. The International Institute of Noise Control Engineering., 2020
  • [27] Dongyuan Shi, Bhan Lam, Shulin Wen and Woon-Seng Gan “Multichannel active noise control with spatial derivative constraints to enlarge the quiet zone” In ICASSP 2020-2020 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), 2020, pp. 8419–8423 IEEE
  • [28] Dongyuan Shi, Bhan Lam, Xiaoyi Shen and Woon-Seng Gan “Multichannel two-gradient direction filtered reference least mean square algorithm for output-constrained multichannel active noise control” In Signal Processing 207 Elsevier, 2023, pp. 108938
  • [29] Dongyuan Shi et al. “Computation-efficient solution for fully-connected active noise control window: Analysis and implementation of multichannel adjoint least mean square algorithm” In Mechanical Systems and Signal Processing 199 Academic Press, 2023, pp. 110444
  • [30] Dongyuan Shi et al. “What is behind the meta-learning initialization of adaptive filter?—A naive method for accelerating convergence of adaptive multichannel active noise control” In Neural Networks Elsevier, 2024, pp. 106145
  • [31] Junwei Ji et al. “A Computation-efficient Online Secondary Path Modeling Technique for Modified FXLMS Algorithm” In arXiv preprint arXiv:2306.11408, 2023
  • [32] Dong Yuan Shi, Bhan Lam and Woon-Seng Gan “A novel selective active noise control algorithm to overcome practical implementation issue” In 2018 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), 2018, pp. 1130–1134 IEEE
  • [33] Chung Kwan Lai, Dongyuan Shi, Bhan Lam and Woon-Seng Gan “MOV-Modified-FxLMS algorithm with Variable Penalty Factor in a Practical Power Output Constrained Active Control System” In IEEE Signal Processing Letters IEEE, 2023
  • [34] Chung Kwan Lai, Bhan Lam, Dongyuan Shi and Woon-Seng Gan “Real-time modelling of observation filter in the Remote Microphone Technique for an Active Noise Control application” In ICASSP 2023-2023 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), 2023, pp. 1–5 IEEE
  • [35] Dongyuan Shi, Woon-Seng Gan, Bhan Lam and Xiaoyi Shen “Comb-partitioned frequency-domain constraint adaptive algorithm for active noise control” In Signal Processing 188 Elsevier, 2021, pp. 108222
  • [36] Dongyuan Shi, Woon-Seng Gan, Bhan Lam and Xiaoyi Shen “A Frequency-Domain Output-Constrained Active Noise Control Algorithm Based on an Intuitive Circulant Convolutional Penalty Factor” In IEEE/ACM Transactions on Audio, Speech, and Language Processing 31 IEEE, 2023, pp. 1318–1332
  • [37] Zhengding Luo et al. “Performance Evaluation of Selective Fixed-filter Active Noise Control based on Different Convolutional Neural Networks” In INTER-NOISE and NOISE-CON Congress and Conference Proceedings 265.6, 2023, pp. 1615–1622 Institute of Noise Control Engineering
  • [38] Dongyuan Shi, Bhan Lam, Woon-Seng Gan and Shulin Wen “Optimal leak factor selection for the output-constrained leaky filtered-input least mean square algorithm” In IEEE Signal Processing Letters 26.5 IEEE, 2019, pp. 670–674
  • [39] Dongyuan Shi et al. “Optimal output-constrained active noise control based on inverse adaptive modeling leak factor estimate” In IEEE/ACM Transactions on Audio, Speech, and Language Processing 29 IEEE, 2021, pp. 1256–1269
  • [40] Zhengding Luo, Dongyuan Shi, Woon-Seng Gan and Qirui Huang “Delayless Generative Fixed-filter Active Noise Control based on Deep Learning and Bayesian Filter” In IEEE/ACM Transactions on Audio, Speech, and Language Processing IEEE, 2023
  • [41] Zhengding Luo et al. “GFANC-Kalman: Generative Fixed-Filter Active Noise Control with CNN-Kalman Filtering” In IEEE Signal Processing Letters IEEE, 2023
  • [42] Zhengding Luo et al. “Deep Generative Fixed-Filter Active Noise Control” In ICASSP 2023-2023 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), 2023, pp. 1–5 IEEE
  • [43] Junwei Ji et al. “A practical distributed active noise control algorithm overcoming communication restrictions” In ICASSP 2023-2023 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), 2023, pp. 1–5 IEEE
  • [44] Zhengding Luo, Dongyuan Shi and Woon-Seng Gan “A hybrid sfanc-fxnlms algorithm for active noise control based on deep learning” In IEEE Signal Processing Letters 29 IEEE, 2022, pp. 1102–1106
  • [45] Dongyuan Shi et al. “Selective fixed-filter active noise control based on convolutional neural network” In Signal Processing 190 Elsevier, 2022, pp. 108317
  • [46] Dongyuan Shi et al. “Transferable latent of cnn-based selective fixed-filter active noise control” In IEEE/ACM Transactions on Audio, Speech, and Language Processing IEEE, 2023
  • [47] Dongyuan Shi, Woon-Seng Gan, Bhan Lam and Kenneth Ooi “Fast adaptive active noise control based on modified model-agnostic meta-learning algorithm” In IEEE Signal Processing Letters 28 IEEE, 2021, pp. 593–597
  • [48] Xiaoyi Shen et al. “A Momentum Two-Gradient Direction Algorithm with Variable Step Size Applied to Solve Practical Output Constraint Issue for Active Noise Control” In ICASSP 2023-2023 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), 2023, pp. 1–5 IEEE
  • [49] Dongyuan Shi, Woon-Seng Gan, Bhan Lam and Shulin Wen “Feedforward selective fixed-filter active noise control: Algorithm and implementation” In IEEE/ACM Transactions on Audio, Speech, and Language Processing 28 IEEE, 2020, pp. 1479–1492
  • [50] Dongyuan Shi “Algorithms and implementations to overcome practical issues in active noise control systems” Nanyang Technological University, 2020
  • [51] Muhammad Tahir Akhtar, Masahide Abe and Masayuki Kawamata “A new variable step size LMS algorithm-based method for improved online secondary path modeling in active noise control systems” In IEEE Transactions on Audio, Speech, and Language Processing 14.2 IEEE, 2006, pp. 720–726