/*
What is this?
This is a little tool to help other animators to sync their cycle animations perfectly to the music,
avoiding those times when you play an animation and it slowly unsyncs with the music
until its completely out of beat.

How do I use it?
If you want to make a little animation to sync to a song you want,
you have to find the BPM of the song first,
then you have to decide the speed of the animation (FPS),
and then you can calculate the Frames Per Beat,
which are the number of frames that each beat of the song lasts.

For example, if my song has 120BPM and I want my animation to have 24FPS,
then I should use 12 frames for each beat, which means that on the frames 12, 24, 36, etc
I will draw the character in an extreme position and then draw the inbetweens.
Since you cant have half frames, the FPB shouldn't have a decimal value,
so play around with the FPS (or even the BPM if you want to change the speed of the song)
until you get a whole number.

In theory it should be perfectly synced, but in practice, there is latency, lag, slow computers,
songs with uneven tempo and many other things that may unsync the animation slowly, but it's a start!

-----------------------------------------------------------------------------------------------------------------------
Understanding Tempo:
The key to animating dance is to let the tempo of the music drive the animation.
Determining the tempo simply requires a watch.
Count the number of beats in six seconds of music.
Multiply this by 10 to get the beats per minute (BPM).
When you have this, you can determine how many frames you'll need per beat of music.
For example, a common BPM is 120. At 24 frames per second (fps), the frames per beat would be this:

24 fps x 60 seconds = 1440 frames/minute (fpm)

1440 fpm/120 BPM = 12 frames/beat

-----------------------------------------------------------------------------------------------------------------------
Frame Rates:
30
29.97 NTSC
25 PAL
24
23.976 NTSC
*/

slider1:0<0,4,1{FPB,FBS,BPM}>Calculate
slider2:120<40,240,1>BPM
slider3:24<20,30,1>Frame Rate (FPS)
slider4:12<5,45,1>Frames per Beat (FPB)

in_pin:none
out_pin:none

@block

BPM=slider2;
FPS=slider3;
FPB=slider4;

slider1 == 0 ? (
slider4 = FPS / (BPM / 60); // FPB
sliderchange(slider4);
);

slider1 == 1 ? (
slider3 = (FPB * BPM) / 60; // FPS
sliderchange(slider3);
);

slider1 == 2 ? (
slider2 = FPS / FPB * 60; // BPM
sliderchange(slider2);
);
