Pretty much. The beatCounter++ line you replace with whatever you want to do with the beats, such as decreasing the counter, and at the end you can add other functionality.
And result should be an int - declared right there. Forgot that one (fixed now).