sum and freq, you can
consider using signed types. If you do this, you don't need to track
the signs of acceleration and velocity separately, and it simplifies
comparisons. However, this also means that you need to change the
way you compare sum with base_freq, as well as how you
reset sum once it exceeds the limits.