could you help me to look at my codes, all my output frequency turn out 440. I am stuck in this for a week.
int accidental = 0;
int octave;
if (strlen(note) == 3 )
{
octave = atoi(¬e[2]);
if(note[1] == '#')
{
accidental += 1;
}
else if(note[1] == 'b')
{
accidental -= 1;
}
}
else
{
octave = atoi(¬e[1]);
}
char c = note[0];
switch (c)
{
case 'A': accidental += 0;
break;
case 'B': accidental += 2;
break;
case 'C': accidental -= 9;
break;
case 'D': accidental -= 7;
break;
case 'E': accidental -= 5;
break;
case 'F': accidental -= 4;
break;
case 'G': accidental -= 2;
break;
}
accidental += (octave-4)*12;
float power = accidental/12;
float frequency = round(pow(2, power)*440);
return frequency;
}