# How to create Sine "Pulse" with math nodes and "From/To" inputs Amplitude?

Based on this answer:Sine wave using only Math nodes?

I have the ability to create an animated waveform with an amplitude from 0 to 1.

Very interesting and useful.

But now I would like to ask the more complex question:

How to change the Minimum and Maximum values of Amplitude with the input values of a group node?

It sounded easy, but math isn't my forte, and I'm getting lost in my problem with it.

For example I would like to set from 0.1 to 0.9 or, do from 2.5 to 100.

I don't know if there is something universal Formula, my idea is that it exists, but I am not able to correctly analyze the formulas present on the internet, as my mathematics is very limited

• I don't know any "Sine Pulse". But if you are talking about waveforms, do you mean a Pulse Wave? Would your input values then be the pulse width? Commented May 5, 2022 at 7:44

Do I understand it correctly that you want to convert the standard sine wave with an amplitude going from -1 to 1 to something else like going from 0.1 to 0.9 or 2.5 to 100?

Why not simply use a Map Range node after the Sine node? Since we know the output values of the Sine node are From Min = -1 and From Max = 1, just set the other values accordingly to your desired target range, for example To Min = 0.1 and To Max = 0.9 as in the following screenshot:

Of course, if you would want this inside the Group Node, you would maybe again place a Multiply node before the Sine which combines the Speed group input with the driver value and connect the From group input to the To Min input of the Map Range as well as the To group input to the To Max input.

If this isn't what you want you might have to explain a little more what you're aiming for.

For the mathematical background, the group in your screenshot is doing something like the Map Range, just split up in single functions. To make the Map Range conversion of sine from the -1 to 1 range to a different one just with math nodes, you can make the following considerations and computations (forgive me my quite arbitrary variables):

The peak-to-peak-amplitude of the sine function is:

$$sin_{amp}=sin_{max}-sin_{min}= 1-(-1)=1+1=2$$

The peak-to-peak-amplitude of the target range is:

$$t_{amp}=t_{max}-t_{min}= 0.9-0.1=0.8$$

The ratio between those two amplitudes is:

$$R_{t,sin}=\frac{t_{amp}}{sin_{amp}}=0.4$$

The proportional shift from the initial sine minimum to the target minimum (this works if you replace the minima with the maxima as well):

$$S_{t,sin}=t_{min}\cdot\frac{sin_{amp}}{t_{amp}}-sin_{min}=0.1\cdot\frac{2}{0.8}-(-1)=0.25+1=1.25$$

So you get the final formula to map the sine function from [-1, 1] to [0.1, 0.9] if you add the proportional shift to the result of the sine function and multiply it by the amplitude ratio:

$$(sin(x)+S_{t,sin})\cdot R_{t,sin}=(sin(x)+1.25)\cdot0.4$$

And to not have to calculate everything over and over again, this is a node setup for these equations... by the way, if you input any other value instead of a sine function and exchange the s_min and s_max values for any other range, they would resemble the To Min and To Max of the Map Range node and the result of the node tree would work like the Map Range node set to Linear with Clamp disabled.

• Hey Gordon this answer is very brilliant and works great. It would also be nice to learn some math, but I think this is what I was looking for with very little effort. You saved me a lot of headaches 🙏 Commented May 5, 2022 at 8:59
• @NoobCat Wait a few minutes, I'm working on the maths ;) Commented May 5, 2022 at 9:00
• @NoobCat I've edited my answer to add some formulas... Commented May 5, 2022 at 9:46
• This answer satisfies my question 200% you did a lot more than I was asking. I hope it will be useful to many people. Commented May 6, 2022 at 3:37

I understood that you want to create a pulse wave.

For this you actually only need a rounding up and down of your values.

Since the node Sinus always gives you float values between $$-1$$ and $$1$$, you can round them up or down to exactly $$-1$$, $$0$$ or $$1$$ with the node Round.

The node Map Range will then generate the values you need (either in the range $$-1$$ - $$1$$, or $$0$$ - $$1$$, depending on the values you have reached before).