torchlpc
provides a PyTorch implementation of the Linear Predictive Coding (LPC) filter, also known as all-pole filter.
It's fast, differentiable, and supports batched inputs with time-varying filter coefficients.
Given an input signal
import torch
from torchlpc import sample_wise_lpc
# Create a batch of 10 signals, each with 100 time steps
x = torch.randn(10, 100)
# Create a batch of 10 sets of LPC coefficients, each with 100 time steps and an order of 3
A = torch.randn(10, 100, 3)
# Apply LPC filtering
y = sample_wise_lpc(x, A)
# Optionally, you can provide initial values for the output signal (default is 0)
zi = torch.randn(10, 3)
y = sample_wise_lpc(x, A, zi=zi)
pip install torchlpc
or from source
pip install git+https://github.com/yoyololicon/torchlpc.git
The details of the derivation can be found in our preprints12.
We show that, given the instataneous gradient
The initial conditions provide an entry point at
In practice, we pad
In the time-invariant setting,
The gradients
This algorithm is more efficient than 3 because it only needs one pass of filtering to get the two gradients while the latter needs two.
- Use PyTorch C++ extension for faster computation.
- Use native CUDA kernels for GPU computation.
- Add examples.
- torchcomp: differentiable compressors that use
torchlpc
for differentiable backpropagation. - jaxpole: equivalent implementation in JAX by @rodrigodzf.
If you find this repository useful in your research, please cite our work with the following BibTex entries:
@misc{ycy2024diffapf,
title={Differentiable All-pole Filters for Time-varying Audio Systems},
author={Chin-Yun Yu and Christopher Mitcheltree and Alistair Carson and Stefan Bilbao and Joshua D. Reiss and György Fazekas},
year={2024},
eprint={2404.07970},
archivePrefix={arXiv},
primaryClass={eess.AS}
}
@misc{ycy2024golf,
title = {Differentiable Time-Varying Linear Prediction in the Context of End-to-End Analysis-by-Synthesis},
author = {Yu, Chin-Yun and Fazekas, György},
year={2024},
eprint={2406.05128},
archivePrefix={arXiv},
primaryClass={eess.AS}
}