If pitch is a known constant, it can be made easier.
in the first post of OP - pitch is set in set_freq() outside the Interrupt routine, so it is possibly not constant
If pitch is a known constant, it can be made easier.
in the first post of OP - pitch is set in set_freq() outside the Interrupt routine, so it is possibly not constant