This directory contains the PCAN (Per-Channel Automatic Gain Control Normalization) library for Sound Open Firmware (SOF), integrating Google's upstream microfrontend library from TFLite Micro under the Apache 2.0 license with express patent grant protection.
PCAN applies per-channel adaptive dynamic gain control and root dynamic range compression across time to linear filterbank energies (e.g. Mel spectrogram bins), suppressing stationary background noise while enhancing transient acoustic events (speech onsets, keywords).
+-------------------------------------------------------------+
| Input Filterbank Energy Matrix |
| E_in[channel, frame] |
+-------------------------------------------------------------+
|
v
+---------------------------------------------------------------------------------------------+
| PCAN Processing Stages |
| |
| 1. Temporal Noise Estimation (IIR Smoothing): |
| E_est[k] = ((E_in[k] << smoothing_bits)*alpha_s + E_est[k]*(1 - alpha_s)) >> 14 |
| |
| 2. Piecewise Quadratic Octave Gain Lookup: |
| gain[k] = WideDynamicFunction(E_est[k], gain_lut) |
| - Fast single-cycle CLZ/MSB (AE_NSAU on Tensilica HiFi) |
| - 10-bit fractional index quadratic interpolation |
| |
| 3. Dynamic Gain & Root Polynomial Compression: |
| SNR[k] = ((uint64_t)E_in[k] * gain[k]) >> snr_shift |
| E_out[k] = PcanShrink(SNR[k]) |
| - If SNR[k] < 8192 (2 << 12): SNR[k]^2 >> 20 |
| - If SNR[k] >= 8192: (SNR[k] >> 6) - 64 |
+---------------------------------------------------------------------------------------------+
|
v
+-------------------------------------------------------------+
| PCAN-Normalized Feature Tensor |
| E_out[channel, frame] |
+-------------------------------------------------------------+
The PCAN math library requires the following tools and repositories:
| Dependency | Required Version | Description |
|---|---|---|
West Manifest (submanifests/tflm.yml) |
Pulls tflite-micro workspace dependency via west update
|
|
| TFLite-Micro | Git revision e86d97b6
|
Upstream Google microfrontend C source files (pcan_gain_control.c, noise_reduction.c, log_scale.c, bits.h) |
| CMake | SOF build and configuration system | |
| Host Toolchain | GCC |
For building Zephyr native_sim ZTest unit tests |
| DSP Toolchains | Zephyr SDK / Xtensa XCC / Clang | For building target firmware with HiFi3 / HiFi4 / HiFi5 intrinsics |
| Zephyr ZTest | Built with SOF/Zephyr | Unit testing framework (west twister) |
| GNU Octave | Reference modeling and golden test vector generation |
Ensure tflite-micro is pulled and synchronized in your workspace:
cd /path/to/sof-workspace
west updateConfigure and run the 5-phase PCAN unit test suite on native_sim:
west twister -T sof/test/ztest/unit/math/advanced/pcan -p native_sim -vTo re-generate or verify golden test headers from the Octave reference suite:
cd test/ztest/unit/math/advanced/pcan
octave-cli --eval "ref_pcan"This updates ref_pcan_lut.h, ref_pcan_func.h, ref_pcan_stream.h, and ref_pcan_corners.h.
When building SOF for a target DSP platform (e.g. Intel ACE15 / Meteor Lake / Arrow Lake):
west build -b intel_adsp/ace15_mtpm sof/appCONFIG_MATH_PCAN: Enables building the PCAN math library and links Google's microfrontend C source files.