Warped Linear Prediction

Link to GitHub repo. This project contains a collection of Jupyter notebooks to demonstrate Warped Linear Prediction techniques in DSP, including filter design and audio codecs.

Motivation

I was looking to implement Tolonen and Karjalainen's summary autocorrelation method in "A computationally efficient multipitch analysis model." I needed a WLP pre-whitening filter as a first step to the algorithm. To that end, I gathered as many resources (papers, online lectures, blog posts, etc.) as I could find on Warped Linear Prediction. I chose Jupyter notebooks to show my work and annotate my thought process as I tried to develop an understanding of how to implement WLP.

Results

As a final artifact to demonstrate the correct working of the WLP filter, I designed my own version of a WLPAC (Warped Linear Prediction audio codec), loosely based on the Harma and Laine's "WLPAC - a perceptual audio codec in a nutshell."

In [1]:
from wlpac import wlpac_encode, wlpac_decode
import scipy.io, scipy.io.wavfile


wlpac_encode('speech_m.wav', 'speech_m.wlpac', quality=0.3)
wlpac_decode('speech_m.wlpac', 'speech_m_roundtrip.wav')

fs, x = scipy.io.wavfile.read('speech_m.wav')
fs, x_wlpac = scipy.io.wavfile.read('speech_m_roundtrip.wav')
Wrote speech_m.wlpac with quality 0.3, 35.93% smaller
In [2]:
from IPython.display import Audio


Audio(x, rate=fs)
Out[2]:
In [3]:
Audio(x_wlpac, rate=fs)
Out[3]:

Contents

  1. First-order all-pass filter
  2. Higher-order filters and the WFIR
  3. Why warp? A brief introduction to psychoacoustics
  4. Listening tests, speech and music
  5. Reconstructing the original signal
  6. Quantization and the WLPAC

Use this project for:

  • Filter basics: transfer functions, the z-1-transform, frequency response, impulse response, etc.
  • Scipy/numpy/matplotlib DSP: applying filters to audio signals, plotting spectrograms, etc.
  • Basic algebra on transfer function polynomials, and some numpy poly1d
  • Signal quantization and the design of an arbitrary audio codec

The code is MIT-licensed so you can borrow code at will. Error reports and feedback are welcome and appreciated via GitHub issues.