just some simple BPM & triangle wave code sin() cos() tan() millis()

edited November 2016 in Share Your Work

working on a sequencer couldnt find a decent method for BPM so i used a simple method.

ZVmod=200 tan(radians(tan(radians(87cos(radians(millis()0.180)) ))sin(radians(millis()*0.180)) )) ;

by dividing millis() using *0.180 = 1000 * 0.180 = 180 deg inside sin cos etc this produces 60BPM at each 1 sec. 0.36 = 120BPM = 360 deg 0.70 = 240BPM = 720 deg

the equation above produces a saw triangle + - wave. tangent is only effective at about 87 deg so not perfect before it goes off the scale.

60BPM ramp triangle wave equation.

ZVmod=200 tan(radians(tan(radians(80cos(radians(millis()0.180)) ))sin(radians(millis()*0.180)) )) ;

positive negative 60BPM triangle wave.

ZVmod=200 sin(radians(tan(radians(60sin(radians(millis()0.180)) ))sin(radians(millis()0.180)) )); ZVmod=200 *-sin(radians(tan(radians(60sin(radians(millis()0.180)) ))sin(radians(millis()*0.180)) ));

Sharp Triangle 60BPM wave.

ZVmod=200 -sin(radians(tan(radians(60sin(radians(millis()*0.180)) )) ));

my BPM counter said 30BPM on this but thats because its + - i only tested one direction.

Simple ramp pulse 60BPM

ZVmod=200 -sin(radians(tan(radians(millis()0.180)) )) ;

basically this is how you implement easy waves using sin cos tan.

i just tried to view this on opera and it missed out some of the ******* in the equation????? why does this forum never post correctly?????

Comments

Sign In or Register to comment.