ANC Tuning & Performance Optimization

In engineering practice, the most time-consuming and experience-dependent part of an active noise control system is not algorithm selection, but parameter tuning and stability debugging. Filter order, step size, sampling rate — each parameter interacts with the others in ways that are not always obvious. This article draws from hands-on experience to cover the key parameter selection logic and common troubleshooting approaches in ANC tuning.

Filter Order Selection

The FIR filter order $N$ directly determines two core metrics: frequency resolution and computational complexity. Getting this choice wrong reveals itself early in debugging — poor noise reduction, slow convergence, or outright divergence.

An insufficient filter order means the filter cannot accurately model the secondary path impulse response. The secondary path typically comprises the acoustic responses of the speaker, cavity, microphone, and other components, with impulse responses spanning tens to hundreds of samples. If the order is shorter than this impulse response, the FXLMS algorithm loses its convergence reference and noise reduction depth will naturally be limited.

An excessively high order brings linearly increasing computation. A single FIR filter pass requires N multiply-accumulate operations. For a system at 16 kHz with N = 256, filtering alone consumes roughly 4 MIPS — before accounting for the FXLMS coefficient update. On a low-power MCU, this can easily crowd out other tasks.

A practical rule of thumb: for 16 kHz sampling with a minimum effective frequency of 100 Hz, N ≥ 160 is usually reasonable. However, a more accurate basis is the actual length of the secondary path impulse response, not a simple sampling-rate ratio. An effective approach is to measure the secondary path impulse response through offline identification, then determine the order based on how many samples are needed for the response to decay below the noise floor.

A common trade-off on embedded systems is to lower the sampling rate in exchange for better order utilization. Many ANC products drop the sampling rate to 8 kHz, where a 64-tap filter covers frequencies above 125 Hz. Halving the sampling rate cuts computation in half — critical for battery-powered devices.

Step Size Tuning

The step size $\mu$ is the single most trial-intensive parameter in ANC tuning. It controls how much the algorithm updates each iteration. Too small means slow convergence; too large means instability. The boundary between these regions is often only a factor of two or three apart.

Step size selection first depends on the noise characteristics. Stationary noise — fans, motors, and other constant-running equipment — does not require fast tracking. A smaller μ (e.g., 0.0001 to 0.001) works well, prioritizing steady-state noise reduction depth. Time-varying noise — engine RPM changes, impact noise — requires a larger μ (0.001 to 0.01), sacrificing some steady-state accuracy for faster tracking response.

In practice, start with a small step size: 0.0001 for narrowband tones, 0.0005 for broadband noise. Gradually increase the step size, observing convergence speed and steady-state residual at each step. When the system starts to oscillate or exhibit anomalous convergence, step back to the last stable value and leave at least 30% margin as the final operating parameter.

If the system experiences wide operating condition changes (e.g., switching from silence to a strong noise environment), a variable step size strategy can help: use a larger step size during the startup phase for fast convergence, then gradually reduce it after convergence is detected. This can be implemented with a simple exponential decay curve, or a normalized step size based on error signal power — larger step when error is large, smaller when error is small.

mermaid
flowchart TD
    A["Offline Ŝ(z) ID<br/>White noise excitation"] --> B["Set small µ<br/>Start N=64"]
    B --> C["Play target noise<br/>Observe convergence"]
    C --> D{"Converged & stable?"}
    D -->|"Diverges"| E["Reduce µ<br/>Check Ŝ(z) accuracy"]
    E --> B
    D -->|"Slow convergence"| F["Increase µ<br/>Observe steady-state error"]
    F --> C
    D -->|"Good convergence<br/>but insufficient NR"| G["Increase N<br/>or lower sample rate"]
    G --> C
    D -->|"Meets target"| H["Leave 30% margin<br/>Lock parameters"]

    classDef start fill:#FF9800,color:#fff
    classDef loop fill:#2196F3,color:#fff
    classDef problem fill:#f44336,color:#fff
    classDef done fill:#4CAF50,color:#fff
    class A start
    class B,C,F,G loop
    class E problem
    class H done

The effect of different step sizes μ is clear at a glance — the three curves below compare μ=0.001 / 0.01 / 0.05 convergence behavior:

收敛曲线
1.00.750.500.250.00255075100迭代次数误差初始阶段收敛阶段稳态阶段
μ = 0.001
μ = 0.01
μ = 0.05

Stability Analysis

The stability of an ANC system is less straightforward to analyze than traditional feedback control, because the secondary path introduces a delay and magnitude/phase transformation. Most divergence issues encountered in practice fall into one of three categories.

Secondary path modeling error is the most common cause of FXLMS divergence. FXLMS uses $\hat{S}(z)$ to filter the reference signal, but if $\hat{S}(z)$ differs too much from the true $S(z)$, the update direction becomes incorrect and the algorithm diverges instead of converging. For single-frequency noise, the sufficient condition for FXLMS stability can be expressed as:

$$ \mu < \frac{2}{P_x \cdot |S(e^{j\omega})| \cdot |\hat{S}(e^{j\omega})| \cdot \cos(\theta_{\text{err}})} $$

where $\theta_{\text{err}}$ is the phase difference between $S(e^{j\omega})$ and $\hat{S}(e^{j\omega})$. When the phase difference exceeds 90°, $\cos(\theta_{\text{err}})$ becomes negative and the right-hand side becomes negative — meaning no positive μ can satisfy the stability condition. This is the theoretical basis for why secondary path modeling must guarantee phase accuracy within ±90°.

Each term in the formula has an intuitive physical meaning:

  • $P_x$: Reference signal power. A stronger reference signal produces larger coefficient updates for the same step size, reducing the maximum allowable step size.
  • $|S| \cdot |\hat{S}|$: The product of the true and estimated secondary path magnitudes. Larger magnitude discrepancy between the two shrinks the stability boundary.
  • $\cos(\theta_{\text{err}})$: The cosine of the phase difference — the most critical factor. $\theta_{\text{err}} = 0°$ gives 1 (most stable), $\theta_{\text{err}} = 90°$ gives 0 (critical), and above 90° gives a negative value (inevitable divergence).

Key insight: Phase accuracy in secondary path identification matters far more than magnitude accuracy. Even with a 20% magnitude error, the system remains stable as long as phase error stays within ±90°. Conversely, a 100° phase error guarantees divergence even with perfect magnitude matching.

Numerical example: $P_x = 1$, $|S| = |\hat{S}| = 1$, $\theta_{\text{err}} = 30°$. Then $\mu < 2 / (1 \cdot 1 \cdot 1 \cdot 0.866) \approx 2.31$. In practice, set μ = 1.0 to reserve over 50% margin for non-ideal system factors.

Quick Tuning Reference

Parameter tuning follows a practical three-step workflow:

  1. Start with N=32, increase to 64/128 only if performance is insufficient. Excessively high orders waste computational resources and actually slow convergence.
  2. Start μ at 0.0001, multiply by 3 each step (i.e., 0.0003 → 0.001 → 0.003 → …), until the system shows signs of divergence.
  3. When divergence occurs, step back to 70% of the last stable value. For example, if 0.003 diverges and 0.001 is stable, use 0.0007 as the final value.

The logic: each 3× step size increase improves convergence speed by roughly $\sqrt{3}$, but shrinks stability margin linearly. Find the point where it “just becomes unstable,” step back, and you have the optimal practical parameter.

Acoustic feedback is an easily overlooked issue. The anti-noise wave from the speaker propagates not only to the error microphone but also back to the reference microphone. If this feedback signal is strong enough, it forms a positive feedback loop — the reference microphone continuously receives the speaker’s own output, causing self-sustained oscillation. Solutions include physical isolation (increasing the acoustic distance between the reference microphone and the speaker), adaptive feedback cancellation (adding an extra filter to estimate and cancel the feedback path), or using a single-microphone feedforward structure to fundamentally avoid feedback.

Excessive delay is particularly prominent in high sampling-rate systems. ADC conversion delay, DSP computation delay, DAC output delay — if the sum of these fixed delays exceeds half the noise period, phase compensation fails. For example, a 500 Hz noise has a 2 ms period and a 1 ms half-period. If the total system delay exceeds 1 ms, no amount of algorithmic phase compensation can output the anti-noise wave at the correct time. Key approaches to reduce delay include: using low-latency codecs, optimizing interrupt priorities to prevent DSP task preemption, and selecting a sampling rate no higher than what the system bandwidth actually requires.

mermaid
flowchart TD
    DIV["System divergence"] --> Q1{"Secondary path<br/>model accurate?"}
    Q1 -->|"No"| F1["Ŝ(z) vs S(z) phase >90°<br/>→ Re-identify<br/>→ Increase ID duration"]
    Q1 -->|"Yes"| Q2{"Acoustic<br/>feedback?"}
    Q2 -->|"Yes"| F2["Speaker → Ref mic<br/>feedback path<br/>→ Physical isolation<br/>→ Feedback cancellation filter"]
    Q2 -->|"No"| Q3{"Total delay<br/>< noise half-period?"}
    Q3 -->|"No"| F3["Excessive delay<br/>→ Lower sample rate<br/>→ Optimize IRQ priority<br/>→ Reduce block size"]
    Q3 -->|"Yes"| OK["Check other causes<br/>Quantization noise / nonlinearity"]

    classDef problem fill:#f44336,color:#fff
    classDef check fill:#2196F3,color:#fff
    classDef fix fill:#4CAF50,color:#fff
    class DIV problem
    class Q1,Q2,Q3 check
    class F1,F2,F3,OK fix

A stability margin of at least 50% is recommended for production systems. The theoretical boundary assumes an ideal linear time-invariant system, while real systems include nonlinearities, time-varying behavior, quantization noise, and other uncertainties.

Debugging Toolchain

ANC debugging has an extra dimension compared to ordinary audio algorithm debugging: you cannot directly perceive the “noise” — you can only infer cancellation performance through the residual at the error microphone. Having the right tools dramatically shortens problem diagnosis time.

An audio analyzer is the standard tool for ANC tuning. It measures the frequency response curve and noise reduction depth precisely, replacing subjective ear-based judgment. The measurement procedure is: play a swept-sine signal, record the frequency response with ANC on and off, and subtract the two to get the noise reduction depth curve. This is more comprehensive than single-frequency measurements — you can see at a glance which frequency bands perform well and which ones have issues.

J-Link RTT enables real-time variable output without interrupting real-time execution. Embedding RTT log points in the ANC control loop — such as error signal power and coefficient delta at each iteration — lets you observe the algorithm’s internal state from the PC in real time. The waveform plot feature in RTT Viewer can even show convergence speed comparisons before and after step size adjustments.

STM32 CubeMonitor is well suited for visualizing DSP variable trends over time. It operates at a higher level than RTT, mapping variables directly to line charts or bar graphs. When debugging step size convergence, displaying $\mu$, error power, and filter coefficient norm simultaneously reveals how these variables interact.

MATLAB / Python offline simulation is the best way to verify algorithms and parameters before hardware debugging. Import reference and error signals captured from hardware, run the same algorithm on the computer, and tweak parameters to see the effect. Compared to repeated firmware flashing on hardware, an offline simulation iteration takes only seconds. Recommended workflow: use simulation to determine the approximate parameter range, then fine-tune within that range on hardware.

An oscilloscope is mainly used for timing verification. Measure the delay from ADC sample completion to DAC output update — this deterministic delay sets the upper bound on the noise frequencies the system can handle. Probing the codec’s LRCLK, the MCU’s GPIO toggles, and the DAC output with an oscilloscope lets you calculate each segment of the delay precisely.

mermaid
flowchart TD
    subgraph Hardware Debug
        A["Audio Analyzer<br/>NR depth curve"]
        B["Oscilloscope<br/>End-to-end latency"]
        C["J-Link RTT<br/>Real-time variables"]
        D["CubeMonitor<br/>Variable trend viz"]
    end
    subgraph Offline Analysis
        E["MATLAB/Python<br/>Algorithm simulation"]
        F["Import real data<br/>Parameter sweep"]
    end
    E -->|"Determine param range"| A
    A -->|"Find issues"| E
    C -->|"Variable trends"| D

    classDef hw fill:#2196F3,color:#fff
    classDef sw fill:#9C27B0,color:#fff
    class A,B,C,D hw
    class E,F sw

Testing and Validation

Parameter validation cannot rely on simulation alone. Systematic testing under real conditions is essential.

Anechoic chamber testing is the most basic validation step. Play narrowband tones at different frequencies in the chamber, measure noise reduction depth at each frequency, and plot the noise reduction depth vs. frequency curve. This reveals filter design issues — a sudden drop in noise reduction at a particular frequency often indicates a phase mismatch problem in that region.

KEMAR (Head and Torso Simulator) testing is closer to real-world usage than single-point microphone measurements. The microphone inside the KEMAR ear canal is positioned similarly to a human ear, so results better reflect actual listening perception. The difference is often significant: a location showing 20 dB reduction with a single-point measurement may only show 15 dB on KEMAR, because the ear canal structure affects the sound field distribution.

Subjective listening tests use MOS (Mean Opinion Score) to evaluate perceived noise reduction quality. 15 dB of objective reduction might not sound as good as 12 dB — if that 15 dB is concentrated in a narrow band while other frequencies have almost no reduction. The MOS test procedure: play a noise segment, have testers switch between ANC on and off, and rate the perceived noise reduction on a 1–5 scale. At least 10 testers with multiple different noise samples are needed for statistically meaningful results.

Long-duration stability testing is the final gate before deployment. Run the system continuously for 24–48 hours, monitoring the RMS of the error signal over time. Typical divergence precursors include: a slow rise in error signal power, sustained growth of certain filter coefficients, or uncontrollable low-frequency oscillations. When these signs appear, revisiting the step size and secondary path modeling accuracy usually identifies the root cause.

Open-Source Ecosystem

Embedded ANC development relies on underlying DSP library support. CMSIS-DSP (ARM official) provides optimized FIR, FFT, matrix operations, and vector math functions, with SIMD and saturated arithmetic optimizations for Cortex-M cores. ESP-DSP (Espressif) does similar work for the Xtensa processors in ESP32. Both libraries offer FIR functions with circular buffer and block processing modes, which can be directly used as the implementation basis for $W(z)$ and $\hat{S}(z)$ in ANC. Checking target platform support for these libraries during the selection phase avoids extensive hand-written assembly optimization later.