0

I am trying to implement a Chebyshev waveshaper according to the description on the bottom post here:

Add odd/even harmonics to signal?

It looks similar to the algorithm here: http://www.juce.com/forum/topic/voice-changer-plugin

The results for any odd order setting sound good. But all even order results just end up in massive distortion. I also tried x * abs(x) instead of x², but the result is similar. How should I handle the even order terms? Or do I have to use a completely different method for producing even harmonics?

  • Could you post the relevant section of your code? – JRE May 22 '15 at 07:37
  • What is your input signal? Could overflow be a problem? – Matt L. May 22 '15 at 07:58
  • For 2nd order it's simply: outputBuffer[i] = 2 * pow(inputBuffer[i], 2) - 1; – user2561735 May 22 '15 at 08:00
  • 4th order: outputBuffer[i] = (8 * pow(inputBuffer[i], 4) - 8 * pow(inputBuffer[i], 2) + 1); – user2561735 May 22 '15 at 08:03
  • There are two strange things I discovered in this calculation methods: For a 24bit recording I have 16777216 possible amplitude values. 8388608 negative values, 0 and 8388607 positive values. So the possible interval is [-1, 0.999999881] (1 / (2^24 / 2) * 8388607) ... – user2561735 May 22 '15 at 08:36
  • ... If I now take the 2nd order example and put the maximum negative and maximum positive values through the function the results are: f(-1) = 1, f(1) = 1 So, both values greater than the maximum possible amplitude level. Yes, obviously an overflow problem. The other strange thing I do not understand is, how can the maximum negative value and the maximum positive value result in the positive maximum. Looks like a strange kind of wave shaping!? ... – user2561735 May 22 '15 at 08:37
  • So my questions: Is this method correct for 2nd order harmonics anyway? And how could I handle the overflow problem? Just reducing all values >= 0.999999881 to 0.999999881? – user2561735 May 22 '15 at 08:37
  • Can you provide (links to) plots of your output signal for even order Chebyshev polynomials? Just use a sine as input signal. As far as I can see there is no principal problem with the approach. – Matt L. May 22 '15 at 11:54
  • does the pow() function work right when the first argument is 0 or less? usually i think that pow(x,n)=exp(n*log(x)), but if n is an integer, i s'pose they could implement pow(x,n) with x times itself n times. anyway, i would say that implementing Tchebyshev polynomials using pow() is pedantic. might not be such a good idea. – robert bristow-johnson May 22 '15 at 15:12
  • This is how the shaped sine waves look like: http://www.tomkincodes.com/img/chebyshev.gif – user2561735 May 22 '15 at 22:19
  • @robert: i just made a test.. the pow() function works right with all values. – user2561735 May 22 '15 at 22:32
  • hmmm, i wonder what pow(-1.0,0.5) would look like? – robert bristow-johnson May 23 '15 at 04:35
  • robert, why? the exponents are always integers. – user2561735 May 23 '15 at 06:30
  • Putting a normalized sine through looks different: http://www.tomkincodes.com/img/chebyshev_1.gif – user2561735 May 23 '15 at 08:30
  • And this is how it looks on a song file: http://www.tomkincodes.com/img/chebyshev_song.gif – user2561735 May 23 '15 at 09:11
  • I just realized I made a mistake in my problem description. It's not "massive distortion", it just looks like that on the meter.. There is a humming noise over the resulting distorted "modified" sound. It is also audible in the empty passages. So I realized this is a DC signal. The empty passages should be 0, so I put 0 through the 2nd order function and calculated the result, which is 2 * 0² - 1 = -1. – user2561735 May 23 '15 at 23:54
  • Today I also discovered this part in the link I provided myself on the other posting: "If you want to add only even harmonics, put your signal through a transfer function that's even symmetric plus an identity function, to keep the original fundamental. Something like y = x + x^4 or y = x + abs(x)." This means I have to add x to the polynomial for the even order calculations.

    To get rid of the DC signal I should omit the - 1 and divide by 2 instead.

    – user2561735 May 24 '15 at 00:02

0 Answers0