Skip to content

Instantly share code, notes, and snippets.

@wmmnola
Last active April 12, 2021 13:58
Show Gist options
  • Save wmmnola/980d92c7f069cd0d822419ece112ef40 to your computer and use it in GitHub Desktop.
Save wmmnola/980d92c7f069cd0d822419ece112ef40 to your computer and use it in GitHub Desktop.
Chebyshev Distortion
import numpy as np
def cheb(n,x):
if(n == 1): return x
if(n == 0): return 1
else: return 2*x*cheb(n-1, x) - cheb(n-2, x)
def add_cheb_distortion(signal, n, ampl = lambda x: 1):
squash = lambda x,k,L,A: (L-A)/(1+np.exp(k*x))
output = np.zeros_like(signal)
for i in range(0,4):
output += ampl(i) * cheb(i, inSig)
return squash(output,-2, 40, 0)
@wmmnola
Copy link
Author

wmmnola commented Jun 21, 2019

Chebyshev Polynomials have deep relationships with pure harmonics.

This algorithim is an implementation of A Tutorial on Non-Linear Distortion or Waveshaping Synthesis by C.Roads published in Computer Music Journal Vol. 3, No. 2 (Jun., 1979).

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