Hi. this is my first post here. I am starting a project at university in which a user can type a letter in, and the resulting music note comes out. I have created this using if/else, but on changing to switch I am having a problem. Everything works fine except the default line (in bold) executes regardless of whether the user presses one of the correct keys or not.
Below is my code.
Thanks, Adam
Below is my code.
Thanks, Adam
/* IPA main.cpp 2009/10 tjm */
#include "aservelibs/aservelib.h"
#include <stdio.h>
#include <math.h>
int main ()
{
char keys = 'l';
printf("Type a note and press 'Return'\n");
/*begin loop*/
while(keys != 'x')
{
scanf("%c", &keys);
switch (keys)
{
case 'a': case 'A':
aserveOscillator(0, 220.0, 1.0, 0);
break;
case 'b': case 'B':
aserveOscillator(0, 246.94, 1.0, 0);
break;
case 'c': case 'C':
aserveOscillator(0, 261.62, 1.0, 0);
break;
case 'd': case 'D':
aserveOscillator(0, 293.66, 1.0, 0);
break;
case 'e': case 'E':
aserveOscillator(0, (629.62/2), 1.0, 0);
break;
case 'f': case 'F':
aserveOscillator(0, 349.22, 1.0, 0);
break;
case 'g': case 'G':
aserveOscillator(0, 391.99, 1.0, 0);
break;
default:
printf("That's not a note silly!\n"); /*This is the problem*/
break;
}
aserveSleep(500);
aserveOscillator(0, 0, 0, 0);
}
aserveOscillator(0, 0, 0.0, 0);
return 0;
}