Last active
April 12, 2021 13:58
-
-
Save wmmnola/980d92c7f069cd0d822419ece112ef40 to your computer and use it in GitHub Desktop.
Chebyshev Distortion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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).