When I ran audio/morseplayer, I got a strange audio output. When I monitored it in Audacity, I found that the waveform was quite distorted; it appeared that the PCM digits had overflowed and were being folded back.
See the video of this tweet: https://twitter.com/yoshi_kaw/status/1692411414718419377 The following diff was modified by morseplayer to output a sine wave. In addition, I added some morse characters that were not in the original. --- morseplayer.c.orig Fri Aug 18 13:34:11 2023 +++ morseplayer.c Fri Aug 18 13:37:21 2023 @@ -255,14 +255,25 @@ { '7', "--..." }, { '8', "---.." }, { '9', "----." }, - { '/', "-..-." }, - { '?', "..--.." }, - { ',', "--..--" }, { '.', ".-.-.-" }, - { '*', "...-.-" }, /* SK */ - { '+', ".-.-." }, /* AR */ + { ',', "--..--" }, + { '?', "..--.." }, + { '!', "-.-.--" }, + { '-', "-....-" }, + { '/', "-..-." }, + { '@', ".--.-." }, + { '(', "-.--." }, + { ')', "-.--.-" }, + { '\'', ".----." }, + { '"', ".-..-." }, + { ':', "---..." }, + { ';', "-.-.-." }, + { '_', "..--.-" }, + { '$', "...-..-" }, /* SK */ { '=', "-...-" }, /* BT */ - { '|', ".-..." }, /* AS */ + { '+', ".-.-." }, /* AR */ + { '|', "...-.-" }, /* SK */ + { '&', ".-..." }, /* AS */ { '\0', NULL }, }; @@ -566,18 +577,18 @@ else m = 1.0; - d = rintf(m * prec * sinf(t * 2 * M_PI * pars->sp_hz)); + d = m * prec * sinf(t * 2 * M_PI * pars->sp_hz); if (pars->sp_precision == 8) { for (j = 0; j < pars->sp_channels; j++) { int8_t *bp = (int8_t *)snd->buf; - bp[idx++] = d; + bp[idx++] = d + 127; } } else if (pars->sp_precision == 16) { for (j = 0; j < pars->sp_channels; j++) { int16_t *bp = (int16_t *)snd->buf; - bp[idx++] = d; + bp[idx++] = d + 32767; } } } @@ -590,7 +601,7 @@ snd->buf = x_malloc(snd->len); if (snd->buf == NULL) return (-1); - memset(snd->buf, '\0', snd->len); + memset(snd->buf, 127, snd->len); return (0); } @@ -721,7 +732,7 @@ int c; struct sio_par par; float cwpm = -1.0, owpm = -1.0, pitch = -1.0; - char *afname = NULL; + char *afname = SIO_DEVANY; while ((c = getopt(argc, argv, "c:d:f:w:D")) != EOF) { switch (c) { @@ -797,7 +808,7 @@ sio_initpar(&par); par.rate = 22050; par.sig = 0; - par.bits = 8; + par.bits = 16; par.pchan = 1; if (!sio_setpar(pars.hdl, &par)) errx(1, "sio_setpar failed");