Hi all! Noob here! First time posting! I'm attempting to run a sine wave through a chebyshev polynomial in order to get a given spectrum. I can provide code but unfortunately it's in Java inside Max. I have it working *I think* but I have one thing I'm trying to wrap my brain around: DC My impression (Although I very well could be wrong) is that chebyshev polynomials act like traditional distortion in that the smaller the amplitude of the input sine wave, the less overtones I'm going to see/hear. Is this true? Because, while the output spectrum appears to be operating correctly no matter what, any amount of scaling the input signal or any complex harmonic combinations throw the DC out and the symmetry of wack. Is this how things are supposed to work? I'm getting great *sounding* results. I just want to be sure I'm not doing something completely wrong. To make sure I'm not doing something completely moronic, I've included the log output of my code. It displays the equation for each harmonic and a simplified equation which sums all the terms for the actual DSP call. Thanks for your help, -Matthew Aidekman //This is what I'd do to raise a sine wave by an octave. 0.0(1.0x^0) 0.0(1.0x^1) 1.0(-1.0x^0 + 2.0x^2) 0.0(-3.0x^1 + 4.0x^3) 0.0(1.0x^0 + -8.0x^2 + 8.0x^4) 0.0(5.0x^1 + -20.0x^3 + 16.0x^5) SIMPLIFIED RESULT: 1.0(-1.0x^0 + 2.0x^2) //This is what my DSP loop runs
Scaled Sines into Chebyshev
Started by ●August 19, 2013
Reply by ●August 20, 20132013-08-20
matthewaudio@gmail.com wrote:> Hi all! Noob here! First time posting! > > I'm attempting to run a sine wave through a chebyshev polynomial in > order to get a given spectrum. I can provide code but unfortunately > it's in Java inside Max. > > I have it working *I think* but I have one thing I'm trying to wrap > my brain around: DC > > My impression (Although I very well could be wrong) is that chebyshev > polynomials act like traditional distortion in that the smaller the > amplitude of the input sine wave, the less overtones I'm going to > see/hear. Is this true?Partially. Chebyshev polynomials only "work" when the input is at full scale. Try it - run a fs0.5 vs a fs1.0 sine wave and note the differences. You can find two VST plugins to experiment with them: http://www.kvraudio.com/product/andchebyshev_by_soundhack That one's pretty raw - it will put out DC offset, so be careful. This one seems to be more nuanced: http://www.kvraudio.com/product/func-shaper-by-rs-met I recall vaguely that something could also be done with Octave... I found it useful to do that "same" thing with multiple tools to make sure of what my 'C' code was doing, but the definitions were still the simplest way. Look at "Explicit expressions."> Because, while the output spectrum appears > to be operating correctly no matter what, any amount of scaling the > input signal or any complex harmonic combinations throw the DC out > and the symmetry of wack. Is this how things are supposed to work? >Yep.> I'm getting great *sounding* results. I just want to be sure I'm not > doing something completely wrong. > > To make sure I'm not doing something completely moronic, I've > included the log output of my code. It displays the equation for > each harmonic and a simplified equation which sums all the terms for > the actual DSP call. >Remember that there are phase shifts.> > Thanks for your help, -Matthew Aidekman > > > > > //This is what I'd do to raise a sine wave by an octave. > > 0.0(1.0x^0) 0.0(1.0x^1) 1.0(-1.0x^0 + 2.0x^2) 0.0(-3.0x^1 + 4.0x^3) > 0.0(1.0x^0 + -8.0x^2 + 8.0x^4) 0.0(5.0x^1 + -20.0x^3 + 16.0x^5) > > SIMPLIFIED RESULT: 1.0(-1.0x^0 + 2.0x^2) //This is what my DSP > loop runs >-- Les Cargill
Reply by ●August 20, 20132013-08-20
Les I can't thank you enough. Now that I know these results aren't necessarily caused by a poor implementation, I'm pretty sure I've got it right. I think I'm going to try and keep it. I'm attempting to model an acoustically recorded sound and this gives a pretty convincing decay. I'll probably just see if I can calculate and makeup for the DC at the output. (Or use a DC blocker) So far phase doesn't seem to be an issue. Also, love that sound hack plugin. Used it for all sorts of voodoo in my mixes. Thanks again.
Reply by ●August 20, 20132013-08-20
On 8/19/13 10:10 PM, MatthewA wrote:> Les I can't thank you enough. Now that I know these results aren't necessarily caused by a poor implementation, I'm pretty sure I've got it right. I think I'm going to try and keep it. I'm attempting to model an acoustically recorded sound and this gives a pretty convincing decay. I'll probably just see if I can calculate and makeup for the DC at the output. (Or use a DC blocker) >i think you'll get DC problem only for the even-ordered Tchebyshev polynomials. they do not go to zero when the input goes to zero. but what you *can* do is take out the constant term out of each even-ordered Tchebyshev term. that might cure the DC problem. but a DC blocker on both input (if it gets more general than sines) and output might be good. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Reply by ●August 20, 20132013-08-20
On Tuesday, August 20, 2013 1:53:55 AM UTC-4, robert bristow-johnson wrote:> On 8/19/13 10:10 PM, MatthewA wrote: > > > Les I can't thank you enough. Now that I know these results aren't necessarily caused by a poor implementation, I'm pretty sure I've got it right. I think I'm going to try and keep it. I'm attempting to model an acoustically recorded sound and this gives a pretty convincing decay. I'll probably just see if I can calculate and makeup for the DC at the output. (Or use a DC blocker) > > > > > > > i think you'll get DC problem only for the even-ordered Tchebyshev > > polynomials. they do not go to zero when the input goes to zero. > > > > but what you *can* do is take out the constant term out of each > > even-ordered Tchebyshev term. that might cure the DC problem. > > > > but a DC blocker on both input (if it gets more general than sines) and > > output might be good. > > > > -- > > > > r b-j rbj@audioimagination.com > > > > "Imagination is more important than knowledge."I played with this idea once a long time ago. If you are using only the X^2 polynomial, then the consequence of having the wrong input amplitude is only that the DC will be off, and the level of the 2X frequency will vary by the square of the input; but at least there are no other frequencies. In the case of the high-order polynomials, though, as you ramp the input AC level from 0 to 1.0, other frequencies will come and go until you arrive at the correct value, so it's doubtful you would enjoy the sound of that process with real-world audio inputs, even if that input is a time-varying single-frequency input (an oxymoron, I know). When I played with this, I tried to overcome the amplitude effect by pre-processing the input signal with a feed-forward infinite compressor, and then after the polynomial you multiply the signal by (1/(compressor_gain) to get back the original amplitude. Of course there are dynamic effects when the signal is changing, and multiple input frequencies still cause intermodulation products to appear so there's no way to make a broad-band octave doubler this way. In your X^2 system, you get a 2:1 amplitude expansion effect from the squaring, but if you precede the polynomial with a 2:1 compressor, then the output of the polynomial has "normal" dynamics again (in other words, if the input changes by 2dB, the compressor output changes by 1 dB and the polynomial output changes by 2dB, matching the input change). Bob
Reply by ●August 20, 20132013-08-20
MatthewA wrote:> Les I can't thank you enough. Now that I know these results aren't > necessarily caused by a poor implementation,The easiest way to check the implementation is to use the canonical form described on the Wikipedia page - cos(n*arccos(x)) or cosh(n*arccosh(x))> I'm pretty sure I've got > it right. I think I'm going to try and keep it. I'm attempting to > model an acoustically recorded sound and this gives a pretty > convincing decay. I'll probably just see if I can calculate and > makeup for the DC at the output. (Or use a DC blocker) >Or investigate Hilbert transformers...> So far phase doesn't seem to be an issue.It should be if you're using the definition of Chebyshev polynomials.> Also, love that sound > hack plugin. Used it for all sorts of voodoo in my mixes. >That one is fun, but FuncShaper has more uses in my experience. The Sound Hack plugin definitely demonstrates the DC offset and general phase problem. It's closer to being from the definitions.> Thanks again. >-- Les Cargill