I have condition to give me Hz of the octave but I got an error 51:16: runtime error: signed integer overflow: 1845493760 * 2 cannot be represented in type 'int'
for line
for (int j = 0; 4 + j < octave; j++)
hz *= 2;
it looks like my loop for do not stop but i think it is made correct. My code looks like this:
int n = 0; // fraction(?) counter (n/12)
int octave = note[strlen(note) - 1];
int hz = 440; //Hz of A in the Octave
double noteHz ;
double temp ;
//1st step: calculate the A hrtz of octave
if (octave < 4)
{
for (int i = 0; 4 - i > octave; i++)
hz /= 2;
}
else if(octave > 4)
{
for (int j = 0; 4 + j < octave; j++)
hz *= 2;
}
else
hz = 440;