Beginner Frequency Problem

Hello! :slight_smile:

This is my first post. I’m working on a Frequency analyzer.
The problem is that, when I sing G#4, it writes G#5 with wrong Herz.

How should I fix this code?
https://codepen.io/asinger/pen/pXWxZB

Thank you very much!