-
-
Save zeffii/7720878 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// score.ck | |
625::ms => dur unit_time; | |
/* | |
0.74 => float swing_amt; | |
unit_time/2 == swing_amt*a + a; | |
(unit_time/2) - a == swing_amt*a; | |
(625/2) -a == 0.74 * a; | |
312.5 -a == 0.74 * a; | |
(1.0/0.74) * (312.5 -a) == a; | |
1.3513513513513513 * (312.5 -a) == a; | |
*/ | |
// first pass, narrow it down before using small increments | |
2 => int epsilon; | |
find_quick_position(epsilon, 625) => float start_from; | |
find_fine_position(start_from, 0.0001) => float final_value; | |
<<< start_from >>>; | |
<<< final_value >>>; | |
fun float find_quick_position(int epsilon, int ms_four_ticks){ | |
for(0 => int a; a<625; a++){ | |
1.3513513513513513 * (312.5 -a) => float a_out; | |
a $ float => float a_in; | |
if (Math.max(a_out, a_in) - Math.min(a_out, a_in) < epsilon){ | |
return(Math.min(a_out, a_in)); | |
} | |
} | |
} | |
fun float find_fine_position(float a, float epsilon2){ | |
0.000001 => float granularity; | |
float a_out; | |
float current_difference; | |
while(true){ | |
1.3513513513513513 * (312.5 -a) => a_out; | |
Math.max(a, a_out) - Math.min(a, a_out) => current_difference; | |
if (current_difference <= epsilon2){ | |
return a; | |
} | |
else { granularity +=> a; } | |
} | |
} | |
final_value::ms => dur long_tick; | |
long_tick * .74 => dur swing_tick; | |
unit_time * .25 => dur offhat_delay_time; | |
now => time start; | |
0::ms => dur start_2; | |
<<< now >>>; | |
<<< start + ticks_to_time(8) >>>; | |
<<< start + ticks_to_swingtime(8) >>>; | |
fun dur ticks_to_time(int ticks){ | |
return (unit_time/4) * (ticks); | |
} | |
fun dur ticks_to_swingtime(int ticks){ | |
for(0 => int i; i<ticks; i++){ drive_time(i); } | |
return start_2; | |
} | |
fun void drive_time(int i){ | |
i%2 => int tick_type; | |
if (tick_type==0) long_tick +=> start_2; | |
else swing_tick +=> start_2; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment