The function computes the BPM based on the current tempo, speed and ticks per row according to the chosen

tempo mode. The table in the linked wiki page explains how the computation works in theory, but in practice one has to take some rounding inaccuracies into account that appear only in classic and alternative tempo mode, so the end result is not exactly the same as those formulas would suggest.