If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
Irregular Sine Waves
Re: Irregular Sine Waves
martinvicanek wrote: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.
I just insist that the curve should be sinusoidal at all times. A sine wave is convex at all times. Here's what happens, when you squeeze a sine (see .fsm). You can clearly see it stays convex, no matter how much you push.
I just got another answer from the other forum, which is using polynomials and a gauss function. It is visual and behaves correctly inbetween a certain limit. I have to convert it first for you to be able to see it, but it really seems cubic is the correct way to go. And that probably isn't doable at samplerate
- Attachments
-
- sine_stretching.fsm
- (6.78 KiB) Downloaded 826 times
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Irregular Sine Waves
You are missing the point... We are not merely sqeezing (half)sines - we also want them to seamlessly joint.
I think I know about a reasonable compromise. the second half of the sine is convex and first half is concave. Perhaps if we start to drop the crurvature just after it crosses zero (instead of before) to reach correct curvature... with the FM this can be done by phase-shifting the modulation signal forward a little. With my approach of distorting the ramp, I have no idea...
I think I know about a reasonable compromise. the second half of the sine is convex and first half is concave. Perhaps if we start to drop the crurvature just after it crosses zero (instead of before) to reach correct curvature... with the FM this can be done by phase-shifting the modulation signal forward a little. With my approach of distorting the ramp, I have no idea...
- KG_is_back
- Posts: 1196
- Joined: Tue Oct 22, 2013 5:43 pm
- Location: Slovakia
Re: Irregular Sine Waves
The ramp IS the phase. Distorting the ramp IS phase modulation.
-
martinvicanek - Posts: 1328
- Joined: Sat Jun 22, 2013 8:28 pm
Re: Irregular Sine Waves
Maybe we just talked past another?
The lines enclosed in red are not sinusoidal waves (they are the "opposite", so to speak), the ones in green are.
Here is an example of a fully sinusoidal wave that is continuous on either side and in the center:
Also, I converted the project from the second answer for you to see. It is an online interactive page. Just click the link, wait for the start screen to vanish and then move the slider to see the changes. Note that it is fully sinusoidal AND continuous. Link: https://db.tt/ILkzu55c
I've attached the math used to do this. It is a text file of javascript code. The function "calc_coefs" is called with m (the mid point's relative x position) on every change of the slider to get the 10(!) unknowns to solve the equation of
The lines enclosed in red are not sinusoidal waves (they are the "opposite", so to speak), the ones in green are.
Here is an example of a fully sinusoidal wave that is continuous on either side and in the center:
Also, I converted the project from the second answer for you to see. It is an online interactive page. Just click the link, wait for the start screen to vanish and then move the slider to see the changes. Note that it is fully sinusoidal AND continuous. Link: https://db.tt/ILkzu55c
I've attached the math used to do this. It is a text file of javascript code. The function "calc_coefs" is called with m (the mid point's relative x position) on every change of the slider to get the 10(!) unknowns to solve the equation of
- Code: Select all
if x < m
y = (a0*x^4+b0*x^3+c0*x^2+d0*x+e0)
else
y = (a1*x^4+b1*x^3+c1*x^2+d1*x+e1)
- Attachments
-
- (irregular sine)js.rar
- contains a .txt file. This ending is not allowed to be attached, therefore an archive.
- (932 Bytes) Downloaded 948 times
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Irregular Sine Waves
To get the same shape sine as in the link simply PM/FM the sine with a second sine offset by 90 degrees
you will not be able to get full PW mod before it distorts but you will get as much as is displayed in the link.
Edit added example
you will not be able to get full PW mod before it distorts but you will get as much as is displayed in the link.
Edit added example
- Xtinct
- Posts: 106
- Joined: Fri Feb 11, 2011 12:06 am
Re: Irregular Sine Waves
Hello gang,
Just another way to get close to this "Irregular Sine Wave"
Kind of fun, lots of different ways here! Also tried integrating a pulse wave but it had to much dc offset.
P.S., does anyone have a GOOD dc blocker?
Later then, BobF.....
- BobF
- Posts: 598
- Joined: Mon Apr 20, 2015 9:54 pm
Re: Irregular Sine Waves
[...] does anyone have a GOOD dc blocker?
A simple 1 pole highpass with cutoff = 20 Hz should do the job. FS Guru is your friend.
A simple 1 pole highpass with cutoff = 20 Hz should do the job. FS Guru is your friend.
-
martinvicanek - Posts: 1328
- Joined: Sat Jun 22, 2013 8:28 pm
Re: Irregular Sine Waves
Guys I love your examples. They all show the creativity we all have.
@xtinct
It is awesome to see with how little effort this behaviour at least can be achieved.
@all
Maybe I seem like a child that is stubborn just because. But I assure you I'm not. It is rather that I see how close we are. I see Martin's awesome algorithmic oscillators. They consist of just one ASM code module. You input frequency and phase and it spits out a stable waveform, whose cycle is constant in length for a given freq.
I so hoped that this irregular thing could also end like this, just an ASM module with a freq input and some kind of phase input, only that it not just moves the start point of the cycle around, but instead moves the mid-point.
And I know it can be done. I know it because I already have done it. Just not for audio. I can shape curves to look exactly like the audio signals should be. And I don't use magic - it is just plain cubic interpolation. Those of you who are reading here and are not quite sure what I mean, look at the images:
Here you see two points connected by a line. But that line doesn't exist. It is completely estimated by cubic interpolation. The only known values are the two points, and then math calculates how to connect them. Such a thing like the above can also be done with linear interpolation (aka lerp).
Here you see a third point. This one is used indirectly. It means that the calculation tries to connect the two outer points, but while doing so tends towards the third point. Something like this can also be achieved with quadratic interpolation (aka qarp)
Now there are two additional points. But you already know the game. The math tries to connect the outer points, but tends towards the two other points while doing so. This is cubic interpolation (aka cubic). The additional points are so called control points. They only influence the line, but they are not connected to it. Each end point has one control point.
For the irregular wave we use 3 instead of two points, the line has to connect. That makes a total of two cubic lines generated from 3 base points and 4 control points. For example:
Now you may think, this is all so complicated. But it isn't. I talked about lerp earlier. If you lerp two lerps, the result is a qarp.
The equation for a lerp is
so lerping two lerps is
We made qarp.
And yes, it is just as easy to get to cubic. cubic is just lerping two qarps
If you do this for enough t-values you get a line a curve, etc. Since this math is so simple (no exponents, no roots, just multiplication and addition/subtraction), I am absolutely sure it can be done in DSP/ASM.
Maybe we should forget about the word "sine" and call it a spline oscillator instead. We would have created something completely new, that is sonically rich and useful, plus works in realtime, without any wavetables. That makes it very versatile and modulator-friendly.
Is it really just a dream?
@xtinct
It is awesome to see with how little effort this behaviour at least can be achieved.
@all
Maybe I seem like a child that is stubborn just because. But I assure you I'm not. It is rather that I see how close we are. I see Martin's awesome algorithmic oscillators. They consist of just one ASM code module. You input frequency and phase and it spits out a stable waveform, whose cycle is constant in length for a given freq.
I so hoped that this irregular thing could also end like this, just an ASM module with a freq input and some kind of phase input, only that it not just moves the start point of the cycle around, but instead moves the mid-point.
And I know it can be done. I know it because I already have done it. Just not for audio. I can shape curves to look exactly like the audio signals should be. And I don't use magic - it is just plain cubic interpolation. Those of you who are reading here and are not quite sure what I mean, look at the images:
Here you see two points connected by a line. But that line doesn't exist. It is completely estimated by cubic interpolation. The only known values are the two points, and then math calculates how to connect them. Such a thing like the above can also be done with linear interpolation (aka lerp).
Here you see a third point. This one is used indirectly. It means that the calculation tries to connect the two outer points, but while doing so tends towards the third point. Something like this can also be achieved with quadratic interpolation (aka qarp)
Now there are two additional points. But you already know the game. The math tries to connect the outer points, but tends towards the two other points while doing so. This is cubic interpolation (aka cubic). The additional points are so called control points. They only influence the line, but they are not connected to it. Each end point has one control point.
For the irregular wave we use 3 instead of two points, the line has to connect. That makes a total of two cubic lines generated from 3 base points and 4 control points. For example:
Now you may think, this is all so complicated. But it isn't. I talked about lerp earlier. If you lerp two lerps, the result is a qarp.
The equation for a lerp is
- Code: Select all
pos = a*(1-t) + b*t
# with a and b the start and end points and t the t-value (in case of audio either the time or sample pos)
# if t = 0 then pos = a and if t = 1 then pos = b and if 1 > t > 0 then somewhere between a and b
so lerping two lerps is
- Code: Select all
pos1 = a*(1-t) + b*t
pos2 = b*(1-t) + c*t
q = pos1*(1-t) + pos2*t
# with a and c being the end points and b the control point
We made qarp.
And yes, it is just as easy to get to cubic. cubic is just lerping two qarps
- Code: Select all
pos1 = a*(1-t) + b*t
pos2 = b*(1-t) + c*t
pos3 = b*(1-t) + c*t
pos4 = c*(1-t) + d*t
q1 = pos1*(1-t) + pos2*t
q2 = pos3*(1-t) + pos4*t
cubic = q1*(1-t) + q2*t
# with a and d being the end points and b and c the control points
If you do this for enough t-values you get a line a curve, etc. Since this math is so simple (no exponents, no roots, just multiplication and addition/subtraction), I am absolutely sure it can be done in DSP/ASM.
Maybe we should forget about the word "sine" and call it a spline oscillator instead. We would have created something completely new, that is sonically rich and useful, plus works in realtime, without any wavetables. That makes it very versatile and modulator-friendly.
Is it really just a dream?
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Irregular Sine Waves
Wow forget about sine, just when I'd come up with a new version, oh well here it is anyway.
- Xtinct
- Posts: 106
- Joined: Fri Feb 11, 2011 12:06 am
Re: Irregular Sine Waves
Xtinct wrote:Wow forget about sine, just when I'd come up with a new version, oh well here it is anyway.
Haha, don't worry! There's a difference between "forget about sine" and "forget about the word sine", so keep it coming!
This last version seems to work differently by shaping the sine to the right? Looking at the ASM-code doesn't help me as you might have guessed already, but whatever you cook there - don't stop!
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Who is online
Users browsing this forum: No registered users and 50 guests