Improved octave calculation

Improved the calculation of the octave and frequency.

Hope this helps :)