/* Fallunterscheidung mit Musik */ /* Datei: Musikm.c */ #include #include #include #include #include /* c,cis,d,dis,e,f,fis,g,gis,a,b, h, c */ /* 0,1 ,2, 3, 4,5, 6, 7, 8, 9,10,11,12 */ double toene[13]; // 12 Halbtöne +1 int main () { double konst, ton; int i, c; char kennung[20]; konst = pow (2.0, (double) 1/12); printf ("\x1b[2JFallunterscheidung mit Musik"); printf ("\n\nGeben Sie c, d, e .. für Töne."); printf ("\nStrg/Ctrl + c, d .. für Halbtöne."); printf ("\nShift / Umschalt + c gibt C\'\'"); printf ("\nBeenden mit: ESC."); printf ("\nViel Spaß!\n\n"); toene[9] = 440.0; // Kammerton for (i = 9; i < 12; i++) toene[i+1] = toene[i] * konst; for (i = 9; i > 0; i--) toene[i-1] = toene[i] / konst; while ((c = getch()) != '\x1b') { switch (c) { case 'c': ton = toene[0]; strcpy (kennung, "c\' "); break; case '\003': ton = toene[1]; strcpy (kennung, "cis\'"); break; case 'd': ton = toene[2]; strcpy (kennung, "d\' " ); break; case '\004': ton = toene[3]; strcpy (kennung, "dis\'"); break; case 'e': ton = toene[4]; strcpy (kennung, "e\' "); break; case 'f': ton = toene[5]; strcpy (kennung, "f\' "); break; case '\006': ton = toene[6]; strcpy (kennung, "fis\'"); break; case 'g': ton = toene[7]; strcpy (kennung, "g\' "); break; case '\007': ton = toene[8]; strcpy (kennung, "gis\'"); break; case 'a': ton = toene[9]; strcpy (kennung, "a\' "); break; case 'b': case '\001': case '\002': ton = toene[10]; strcpy (kennung, "b\' "); break; case 'h': ton = toene[11]; strcpy (kennung, "h\' "); break; case 'C': ton = toene[12]; strcpy (kennung, "C\'\' "); break; default: ton = 0.0; strcpy (kennung, " "); break; } printf ("\rTon: %s\tf: %3.6f",kennung,ton); sound (ton); delay (200); nosound (); delay (100); } printf ("\x1b[2JEnde der Musik.\nServus!\n\n"); return 0; }