[solved] how do i convert a sawtooth into a sine?
[solved] how do i convert a sawtooth into a sine?
i want to modify an incoming beatclock which is basically like a sawtooth curve in a way that smooths the thing out like a sine. i tried the smooth modifier but that's either too smooth or too biased towards the sawtooth. i figured you math wizards know an easy answer?
Re: how do i convert a sawtooth into a sine?
Yup, you can use the Expression modifier for that.
The reason I made the Beat Clock do a sawtooth is that most math functions take a linear ramp as an input. A sawtooth is just a repeating linear ramp.
So you can try this:
Expression: sin(2*pi*x)
And it will give you a nice sine wave that repeats perfectly, because sines go from 0 to 2*pi, not from 0 to 1. Make sense?
If you want to be *really* complete though, you should do this (which you probably wouldn't have known):
sin(2*pi*x*23/24)
The Beat Clock starts and ends on the same value (0 and 1 are the same point when repeated), and it uses 24 ticks per beat, so you need to eliminate the last tick otherwise you'll get a stutter.
Try it out
Then if you want, you can add a Smooth modifier afterwards to make it a little less jerky (since 24 ticks at low BPMs is noticeable compared to 60fps).
The reason I made the Beat Clock do a sawtooth is that most math functions take a linear ramp as an input. A sawtooth is just a repeating linear ramp.
So you can try this:
Expression: sin(2*pi*x)
And it will give you a nice sine wave that repeats perfectly, because sines go from 0 to 2*pi, not from 0 to 1. Make sense?
If you want to be *really* complete though, you should do this (which you probably wouldn't have known):
sin(2*pi*x*23/24)
The Beat Clock starts and ends on the same value (0 and 1 are the same point when repeated), and it uses 24 ticks per beat, so you need to eliminate the last tick otherwise you'll get a stutter.
Try it out
Then if you want, you can add a Smooth modifier afterwards to make it a little less jerky (since 24 ticks at low BPMs is noticeable compared to 60fps).
Re: how do i convert a sawtooth into a sine?
awesome thanks. yeh from 0 to 2pi makes sense, i wouldnt have known though how to write this. so you multiply it with 2pi, that means when it's 1 it's 2pi and when it's 0 it's 0. but what exactly happens if you put that into sin(). resp. why does it make a sin curve then? O.o
Re: how do i convert a sawtooth into a sine?
Yup exactly.awesome thanks. yeh from 0 to 2pi makes sense, i wouldnt have known though how to write this. so you multiply it with 2pi, that means when it's 1 it's 2pi and when it's 0 it's 0.
Not sure if I'm understanding correctly, but if you look at a sine curve: You can see that as the x-value increases linearly from 0 to 2pi, the y-value oscillates between 1 and -1. It repeats exactly every 2pi. The sawtooth wave created by the Beat Clock is what supplies the linearly changing x-value between 0 and 1, which we are scaling so it goes between 0 and 2pi.but what exactly happens if you put that into sin(). resp. why does it make a sin curve then? O.o
The only thing is that the Beat Clock is actually decreasing from 1 to 0, not increasing from 0 to 1, but visually it doesn't really make a difference in this case.
Re: how do i convert a sawtooth into a sine?
but couldnt we then just write 2pi*x as an expression? sorry, this isnt propably the right place for me to deal with my math problems .
Re: how do i convert a sawtooth into a sine?
No worries . Do you mean 2pi*x instead of 2*pi*x? Either will work; they mean the same thing.
Re: how do i convert a sawtooth into a sine?
no i meant 2pi*x instead of sin(2pi*x). but in the mean time a friend who studies electrical engineering explained it to me and i understood it. i think . so it's fine, and thanks a lot for the expression
Re: how do i convert a sawtooth into a sine?
so.. this transformation moves the value into a sine that seems to go from -1 to 1, it's difficult to tell though, as the values are changing rapidly. but if this is correct, is it also correct that i can normalize it between 0 and 1 by using a scale of 0.5 and then an add of 0.5 ? i want to use this sine for a color value that's limited between 0 and 1. it seeems to work, but it's difficult to tell.
Re: how do i convert a sawtooth into a sine?
Yes, that will work.
Also, you could just use the SIN OSC(illator) modifier. It already is normalized to output from 0 to 1.
Also, you could just use the SIN OSC(illator) modifier. It already is normalized to output from 0 to 1.
Re: how do i convert a sawtooth into a sine?
okay thanks. i need to use the expression modifier because it transforms the incoming beatclock, which is basically a ramp.artnik wrote:Yes, that will work.
Also, you could just use the SIN OSC(illator) modifier. It already is normalized to output from 0 to 1.
Re: how do i convert a sawtooth into a sine?
Instead of using more modifiers, you could do:
Expression: sin(2*pi*x*23/24) * .5 + .5
Which is exactly the same as:
Expression: sin(2*pi*x*23/24)
Scale: .5
Offset: .5
Up to you .
Expression: sin(2*pi*x*23/24) * .5 + .5
Which is exactly the same as:
Expression: sin(2*pi*x*23/24)
Scale: .5
Offset: .5
Up to you .
Re: how do i convert a sawtooth into a sine?
right, i'm still thinking inside the box