commit ce0d6424ca093024b516454badfced4c3f5d4d15 from: Sven M. Hallberg date: Mon Oct 23 16:07:47 2023 UTC rename sound() <-> play() The function sound(char) is now the audio hook required by teach.c and should "sound" the given character. The function play(char *) is internal to morse.c for "playing" a sequence of dits and dahs, given as a string of dots and dashes. The morseplay utility (as before) exposes the same functionality. This change also matches function name and signature of play() in the FreeBSD version of morse.c. commit - cce21a4d4fb1285fd07ce47c0cc5a57392e09026 commit + ce0d6424ca093024b516454badfced4c3f5d4d15 blob - 7b3e12e6316f21c3873224b7d83ce8618e86883c blob + a17e9f627e9042947ee425f134ee7d3a07e7f30a --- morse.c +++ morse.c @@ -130,7 +130,7 @@ int lookup(char *); void decode(char *); char *encode(int); void show(char *); -void sound(char *); +void play(char *); static int sflag = 0; static int dflag = 0; @@ -300,7 +300,7 @@ decode(char *s) } if (aflag) - sound(s); /* play back iff decoded */ + play(s); /* play back iff decoded */ if (x < 0) /* negative means prosign */ printf(" %s ", ps[-x].c); /* surround with whitespace */ @@ -357,12 +357,12 @@ show(char *s) putchar('t'); } if (aflag) - sound(s); + play(s); printf("\n"); } void -sound(char *s) +play(char *s) { if (*s == '\0') silence(7 * pditlen - ditlen); /* inter-word pause */ blob - f9c5ded420dd99b2d8720ee47b9b856e47c4ecd7 blob + e554dc61f8bb868917fd0a06b18d214ef45cd015 --- morseteach.c +++ morseteach.c @@ -11,7 +11,7 @@ FILE *fout, *fin; /* our pipes to 'morse -a' */ int Dflag = 0; /* level of diagnostic output */ void -play(char c) +sound(char c) { fputc(c, fout); while (fgetc(fin) != '\n') ; /* wait for sound to finish */ blob - 4ddc1dec8e7c451562d62bdd2d557bf4e60485f5 blob + 289fb07b979f6ac168b2a56edc7428966155dd3c --- teach.c +++ teach.c @@ -60,7 +60,7 @@ struct timespec tpause; /* time spent paused */ /* externally supplied */ extern int Dflag; /* level of diagnostic output */ -void play(char); /* sound output routine */ +void sound(char); /* sound output routine */ double square(double x) @@ -133,19 +133,19 @@ pause(void) putchar('\n'); printscores(); fputs("- pause (press Return to continue, ^D to quit) - ", stdout); - play('&'); /* wait */ + sound('&'); /* wait */ while ((input = getchar()) != '\n' && input != 4) ; clock_gettime(CLOCK_MONOTONIC, &t1); timespecsub(&t1, &t0, &delta); timespecadd(&tpause, &delta, &tpause); if (input == 4) { puts("^D"); - play('+'); /* end of transmission */ - play('\n'); + sound('+'); /* end of transmission */ + sound('\n'); return -1; /* quit */ } - play('\a'); /* attention / start of transmission */ - play('\n'); /* inter-word pause */ + sound('\a'); /* attention / start of transmission */ + sound('\n'); /* inter-word pause */ puts("\r "); return 0; @@ -169,8 +169,8 @@ trial(int i, int ch) * shown them after playback. */ if (failprob[i] > 0.9) - play(' '); /* inter-word pause */ - play(ch); + sound(' '); /* inter-word pause */ + sound(ch); clock_gettime(CLOCK_MONOTONIC, &t0); if (failprob[i] > 0.9) printf("%c\b", ch); @@ -196,7 +196,7 @@ trial(int i, int ch) return -1; /* otherwise resound, reset timer, and restart */ - play(ch); + sound(ch); clock_gettime(CLOCK_MONOTONIC, &t0); continue; } @@ -204,8 +204,8 @@ trial(int i, int ch) /* if ^D pressed, then quit */ else if (input == 4) { puts("^D"); - play('+'); /* end of transmission */ - play('\n'); + sound('+'); /* end of transmission */ + sound('\n'); printscores(); return -1; } @@ -215,7 +215,7 @@ trial(int i, int ch) /* if space pressed, resound and show hint */ if (input == ' ') { printf("%c\b", ch); - play(ch); + sound(ch); printf(" \b"); continue; } @@ -243,7 +243,7 @@ trial(int i, int ch) break; } else if (taken > avgtime + sigma) { /* resound the symbol */ - play(ch); + sound(ch); } } @@ -332,8 +332,8 @@ teach(void) if (input == 4) puts("^D"); else if (input == '\n') { - play('\a'); /* attention / start of transmission */ - play('\n'); /* inter-word pause */ + sound('\a'); /* attention / start of transmission */ + sound('\n'); /* inter-word pause */ puts("\r "); }