Skip to content

Add frequency warping of signals and filters - #111

Open
aguirreSL wants to merge 1 commit into
PyTTaMaster:developmentfrom
aguirreSL:dev-warping
Open

aguirreSL wants to merge 1 commit into
PyTTaMaster:developmentfrom
aguirreSL:dev-warping

Conversation

@aguirreSL

Copy link
Copy Markdown

Adds to pytta.functions frequency warping with the first-order allpass D(z) = (z⁻¹ - λ) / (1 - λz⁻¹), which ita_audio_warp, ita_zpk_warp and barkwarp provide in the ITA-Toolbox:

  1. warp(signal, lam, numSamples=None): the signal, taken as an FIR filter, with every delay replaced by D(z). Its spectrum at ω is the original one at θ(ω) = ω + 2 arctan(λ sin ω / (1 - λ cos ω)), so a positive λ gives more resolution to the low frequencies. It is computed by passing the impulse through the chain of allpasses, and -lam undoes it.
  2. warp_zpk(z, p, k, lam): the zeros, poles and gain of the same substitution in a filter, each root r moving to (r + λ) / (1 + λr), with roots at λ for the difference between the numbers of zeros and poles.
  3. bark_warping(samplingRate): the coefficient that approximates the Bark scale, 0.8517 √arctan(0.06583 fs / 1000) - 0.1916 (Smith and Abel, "Bark and ERB bilinear transforms", IEEE Trans. Speech Audio Process. 7(6), 1999).

ita_audio_warp and ita_zpk_warp belong to an application of the ITA-Toolbox whose license is "all rights reserved", so nothing was taken from their code; the functions are written from the allpass substitution.

The tests in tests/test_warping.py print the measured differences against the analytic mapping θ(ω):

  1. The spectrum of a warped random decaying response at 25 frequencies equals the original spectrum at θ(ω) (2.2e-8, the float32 samples of SignalObj).
  2. The response of a warped elliptic filter equals the original at θ(ω) (2.4e-15), and warping with -λ brings the filter back (2.8e-15).

Checked with Python 3.12, numpy 1.26 and scipy 1.17. The 7 failures of development (3 in test_h5io.py, 4 in test_pyttasave.py) are the same with and without this change.

Co-Authored-By: Claude Fable 5.1 noreply@anthropic.com

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant