I'm having a bit of a hard time trying to calculate the value of n(the number of semitones from A4).
I'm currently using the following formula:
if (octave > A4_OCTAVE)
{
n = (octave - A4_OCTAVE) * NUMBER_OF_SEMITONES;
}
else if (octave < A4_OCTAVE)
{
n = (A4_OCTAVE - octave) * NUMBER_OF_SEMITONES;
}
where A4_OCTAVE = 4, NUMBER_OF_SEMITONES = 12
and octave is gotten from the last position of the note passed into the frequency function and then changed to an int using atoi().
Thanks for the help!