Chebyshev Sine-->Saw ?
-
- KVRist
- Topic Starter
- 64 posts since 9 Jun, 2005
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
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.
-
- KVRAF
- 3388 posts since 29 May, 2001 from New York, NY
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.
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.
-
- KVRist
- Topic Starter
- 64 posts since 9 Jun, 2005
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.stratum wrote:I'll help you by saying "No way!" and somebody will then get creative enough to prove me wrong
Useless, possibly. But if the function is calculated at load time, it should be at least somewhat efficient?It's probably useless in practice because I can't see this method being very efficient.
I am not a DSP expert.
Thanks for your thoughts.
-
- KVRAF
- 3388 posts since 29 May, 2001 from New York, NY
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.
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.
-
- KVRAF
- 2256 posts since 29 May, 2012
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~
-
- KVRist
- Topic Starter
- 64 posts since 9 Jun, 2005
Could you suggest other options for efficient, accurate sine --> saw conversion? I need something that would respond well to FM/PM.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.
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.
-
- KVRAF
- 3388 posts since 29 May, 2001 from New York, NY
You mean something like this ?
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.
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.
-
- KVRAF
- 3388 posts since 29 May, 2001 from New York, NY
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.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?
-
- KVRAF
- 2256 posts since 29 May, 2012
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.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.
(*) 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~
-
- KVRian
- 1273 posts since 9 Jan, 2006
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.stratum wrote: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.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.
(*) 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.
-
- KVRAF
- 2256 posts since 29 May, 2012
Yes, it just won't look like a saw.State isn't a problem. With a pure sinusoid we can waveshape to generate a new harmonic.
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.I think the idea here is that you generate a single sine apply multiple polynomials and sum the resulting harmonics with the original sinusoid.
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~
-
- KVRian
- 1273 posts since 9 Jan, 2006
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.
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.
-
- KVRAF
- 2256 posts since 29 May, 2012
Perhaps that's another way to say what I've tried to.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
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.Edit 2: This technique should work for stacked cosines not sines? In which case true saw wave is out
I'm sure there is something that works behind this idea, I just couldn't see what was meant.
~stratum~
-
- KVRian
- 1273 posts since 9 Jan, 2006
Yes, exactly. But you won'the get the same shapes if you switch from sines to cosines.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.
The idea is basically just additive synthesis.stratum wrote:I'm sure there is something that works behind this idea, I just couldn't see what was meant.