Chebyshev Sine-->Saw ?

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

Hello,

I heard it is possible to use chebyshev polynomials to shape a sine wave into a saw wave.

Is this true? I am having trouble figuring out what to set the amplitudes of the individual polynomials to transform sine-->saw.

I have attached a patch in max/msp that uses the Percolate library (available in package manager) to generate the first 16 chebyshev polynomials, with amplitude control for each.

Thanks for any tips!

Peter
You do not have the required permissions to view the files attached to this post.

Post

I'll help you by saying "No way!" and somebody will then get creative enough to prove me wrong :-) Where did you hear that it was possible?
~stratum~

Post

Well, according to https://en.wikipedia.org/wiki/Chebyshev_polynomials
Tn (cost t) = cos (nt)

So this means that you can shape a cos into any arbitrary shape, using a sum of Chebyshev polynomials Tn, where Tn is scaled by amount of the nth harmonic for the desired target shape.

It's probably useless in practice because I can't see this method being very efficient.

Post

stratum wrote:I'll help you by saying "No way!" and somebody will then get creative enough to prove me wrong :-)
If a saw wave is built up from even and odd harmonic partials with relative amplitude of each partial at 1/partial_num, and even harmonics 180 degrees out of phase. . . it should be a simple task, I think ?? But I've yet to get it working.
It's probably useless in practice because I can't see this method being very efficient.
Useless, possibly. But if the function is calculated at load time, it should be at least somewhat efficient?

I am not a DSP expert. :)
Thanks for your thoughts.

Post

The first coefficient of Tn(x) is 2^(n-1). For a saw wave you would want to adjust the number of harmonics based on the frequency of the note you want to play. In any case, for low notes this 2^(n-1) could get very, very large.

Basically you would end up applying a polynom of degree n, with coefficients that are very large, with n potentially > 64. This is neither efficient, nor accurate.

Post

How does that map a single sine wave to a saw,considering that cos(pi/2) == cos(3*pi/2) and the period is 2*pi, looks impossible, did I miss something? How does that sum of polynomials output different values for the same input?
~stratum~

Post

Big Tick wrote:Basically you would end up applying a polynom of degree n, with coefficients that are very large, with n potentially > 64. This is neither efficient, nor accurate.
Could you suggest other options for efficient, accurate sine --> saw conversion? I need something that would respond well to FM/PM.

Especially if they offer the ability to sweep or mutate between the sine and saw waveforms, I am interested. I'm trying to create a Buchla 258 type oscillator in Max.

Post

You mean something like this ?

Image

That's easy to do with FM/PM. There was a DaFX paper some time ago, I don't have it handy but basically, one sine oscillator with feedback gives you a saw wave. For a square wave, you square the feeback.

Post

stratum wrote:How does that map a single sine wave to a saw,considering that cos(pi/2) == cos(3*pi/2) and the period is 2*pi, looks impossible, did I miss something? How does that sum of polynomials output different values for the same input?
Actually you're right, because the FFT of a saw gives you sine components, not cos. My bad. I should have said, "you can use these polynomials to generate any weighted sum of cosine harmonics (with identical phase) from a base cosine wave". Regardless, this is a fairly useless method anyway.

Post

Actually you're right, because the FFT of a saw gives you sine components, not cos. My bad. I should have said, "you can use these polynomials to generate any weighted sum of cosine harmonics (with identical phase) from a base cosine wave". Regardless, this is a fairly useless method anyway.
I still cannot see how these polynomials map a single (*) sine to a saw, but if we are talking about a set of sines or cosines, well, we all know that they can add up to any periodical wave, and if we are talking about generation of a signal instead of shaping an existing one, then it is yet another subject.

(*) Original post contains the phrase " shape a sine wave into a saw wave". Waveshapers map a single value to another value, they are stateless and often chebyshev polynomials are mentioned in their study so the description of the subject is a bit confusing in the things it recalls.
~stratum~

Post

stratum wrote:
Actually you're right, because the FFT of a saw gives you sine components, not cos. My bad. I should have said, "you can use these polynomials to generate any weighted sum of cosine harmonics (with identical phase) from a base cosine wave". Regardless, this is a fairly useless method anyway.
I still cannot see how these polynomials map a single (*) sine to a saw, but if we are talking about a set of sines or cosines, well, we all know that they can add up to any periodical wave, and if we are talking about generation of a signal instead of shaping an existing one, then it is yet another subject.

(*) Original post contains the phrase " shape a sine wave into a saw wave". Waveshapers map a single value to another value, they are stateless and often chebyshev polynomials are mentioned in their study so the description of the subject is a bit confusing in the things it recalls.
State isn't a problem. With a pure sinusoid we can waveshape to generate a new harmonic. I think the idea here is that you generate a single sine apply multiple polynomials and sum the resulting harmonics with the original sinusoid.

Post

State isn't a problem. With a pure sinusoid we can waveshape to generate a new harmonic.
Yes, it just won't look like a saw.
I think the idea here is that you generate a single sine apply multiple polynomials and sum the resulting harmonics with the original sinusoid.
That still wouldn't look like a saw, a sum of multiple polynomials is still a polynomial, and is a stateless function and wouldn't map a single sine to a saw, so if this method works, it's not working in a way I imagine (or in the way you describe), it's about something else entirely, but I couldn't see it.

p.s have a look at https://upload.wikimedia.org/wikipedia/ ... ne.svg.png sin(0) == sin(pi), these values need to be mapped to different values if this is going to look like a saw with the same period as the original sine.
~stratum~

Post

Well do you accept that a polynomial of a sinusoid can generate a new harmonic? If yes then we just create a wave additivly.

Edit: there could well be phase issues that make this impossible, but the sound should be close. But as was mentioned efficiency will be poor

Edit 2: This technique should work for stacked cosines not sines? In which case true saw wave is out.

Post

Edit: there could well be phase issues that make this impossible, but the sound should be close. But as was mentioned efficiency will be poor
Perhaps that's another way to say what I've tried to.
Edit 2: This technique should work for stacked cosines not sines? In which case true saw wave is out
What do you mean by stacked? If we are going to add sines and/or cosines with frequencies that are integer multiple of the base frequency, like it is done in inverse fourier transform, it's pretty sure one combination of them approximates a saw.

I'm sure there is something that works behind this idea, I just couldn't see what was meant.
~stratum~

Post

stratum wrote:What do you mean by stacked? If we are going to add sines and/or cosines with frequencies that are integer multiple of the base frequency, like it is done in inverse fourier transform, it's pretty sure one combination of them approximates a saw.
Yes, exactly. But you won'the get the same shapes if you switch from sines to cosines.
stratum wrote:I'm sure there is something that works behind this idea, I just couldn't see what was meant.
The idea is basically just additive synthesis.

Post Reply

Return to “DSP and Plugin Development”