Page 3 of 6

Re: Irregular Sine Waves

Posted: Mon Nov 02, 2015 4:43 pm
by Spogg
If I understood a word of it I could maybe help!
At least we know what it sounds like now.
Over to the maths guys then...

Cheers

Spogg

Re: Irregular Sine Waves

Posted: Mon Nov 02, 2015 5:56 pm
by martinvicanek
Here is a comparison of Spoggs sketches and phase modulation waveforms taken from my demo on page 1. Hmmm....

Re: Irregular Sine Waves

Posted: Mon Nov 02, 2015 6:01 pm
by tulamide
martinvicanek wrote:Here is a comparison of Spoggs sketches and phase modulation waveforms taken from my demo on page 1. Hmmm....

You can clearly see the difference. There are spikes where a curve should be. I don't know how to express it correctly in english, but the left line is "konkav" instead of "konvex" and the right line "konvex" instead of "konkav"

EDIT: Martin, just before Spogg's last post I posted an answer I got on another forum. Does it help in terms of dsp/asm code conversion?

Re: Irregular Sine Waves

Posted: Mon Nov 02, 2015 6:35 pm
by tulamide
Here's visualized what the answer is talking about. Once again done with my spline class. Unfortunately I didn't build the cubic splines for the spline class with polynomials, but with cubic interpolation. The latter is easier to comprehend. That brings up another question: Is it possible that I already solved the math a year or longer ago? Because my spline class not only calculates each point of the spline but is also able to spit out any number of values for both, x- and y-axis, which make up the spline. So I could, for example spit out 512 or 44100 y-values, that describe one wave cycle.

If this is a good way to try it, I would provide the calculations I did and comments. But I can't translate it to DSP code.

Re: Irregular Sine Waves

Posted: Mon Nov 02, 2015 7:31 pm
by KG_is_back
Tulamide, you seem to be quite good at math... I think I've come up with better approach. Instead of finding equation for a distorted sinewave, we may just find equation for distorted ramp and feed that to the sin1(x) function.

I've done two examples. First one uses the two straight lines and is dis not smooth at endpoints and midpoint (where it crosses zero). Does pretty much the same thing what spoggs example does.
Second example is continuous in the midpoint but still not in the ends.

From the screenshots martin provided, it seems that derivative at x=0 and x=1 and x=mod is 1 (or at least equal). So the function for ramp distortion needs to satisfy following (mod is the parameter):
y(x)'=y(x+1)'{=y(mod)'=1} and y(0)=0 and y(1)=1 and y(mod)=0.5 ( what written in {} is just a guess).

I'm incapable of comming up with such a function... Martin? Tulamide? anyone?

Re: Irregular Sine Waves

Posted: Mon Nov 02, 2015 8:20 pm
by Spogg
Wow!!!
I think KG has done it!
Such talent :D

Cheers

Spogg

Re: Irregular Sine Waves

Posted: Mon Nov 02, 2015 9:26 pm
by tulamide
KG_is_back wrote:Tulamide, you seem to be quite good at math... I think I've come up with better approach. Instead of finding equation for a distorted sinewave, we may just find equation for distorted ramp and feed that to the sin1(x) function.

I've done two examples. First one uses the two straight lines and is dis not smooth at endpoints and midpoint (where it crosses zero). Does pretty much the same thing what spoggs example does.
Second example is continuous in the midpoint but still not in the ends.

From the screenshots martin provided, it seems that derivative at x=0 and x=1 and x=mod is 1 (or at least equal). So the function for ramp distortion needs to satisfy following (mod is the parameter):
y(x)'=y(x+1)'{=y(mod)'=1} and y(0)=0 and y(1)=1 and y(mod)=0.5 ( what written in {} is just a guess).

I'm incapable of comming up with such a function... Martin? Tulamide? anyone?

We're coming closer. The second example indeed is continuous at the midpoint. So this could be the base to work with. I'm just afraid that you will take the example images from Martin, since they are not correct in the sense that they don't provide continuous waves. The curvature is reversed on one side (the left point on the first screen, the right point on the third screen). The wave should behave like in the irregular_sine_animated.fsm in terms of curvature.

I will give my very best to help, but I avoided derivatives already in the spline class, so I don't think I will come to a conclusion.

Re: Irregular Sine Waves

Posted: Mon Nov 02, 2015 10:03 pm
by KG_is_back
I've given it some thought. The concavity is inevitable. Let's look at the third wave. It starts as a rather slow sine wave, which means it has low curvature. the end of the wave is a fast sine wave, which has high curvature. In order for the wave to joint smoothly, the curvature in the end has to drop, which results in that concavous shape.

Your animated example is not a sine wave - it's two half-ellipses. Sine wave crosses x-axis at 45degrees. Kind of like this (see the modified FSM).

Re: Irregular Sine Waves

Posted: Mon Nov 02, 2015 10:15 pm
by tulamide
I see what you mean. My wave wasn't correct, but with the sine wave I discovered the issue. It is that the control points stay the same. But they shouldn't (since the upper and lower part of the wave change in dimension, the control points should as well). It's too late right now, but I'll post an example tomorrow.

Re: Irregular Sine Waves

Posted: Mon Nov 02, 2015 11:25 pm
by martinvicanek
Tulamide, why do you insist that the wave be convex in the upper half and concave in the lower? KG is right, such a requirement leaves very little headroom for modulation if you want the wave to have continuous slope at the joints. It feels unnatural to me, I don't see the rationale behind it.