util/spkmodem_recv: Use tabs for indentation

The GNU indentation style is hard to read.

Signed-off-by: Leah Rowe <leah@libreboot.org>
fsdg20230625
Leah Rowe 2023-05-16 07:53:23 +01:00
parent 9152d0f939
commit 22633e0dc0
1 changed files with 54 additions and 57 deletions

View File

@ -5,7 +5,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
/* Compilation: gcc -o spkmodem-recv spkmodem-recv */ /* Compilation: gcc -o spkmodem-recv spkmodem-recv */
/* Usage: parec --channels=1 --rate=48000 --format=s16le | ./spkmodem-recv */ /* Usage: parec --channels=1 --rate=48000 --format=s16le | ./spkmodem-recv */
#define SAMPLES_PER_TRAME 240 #define SAMPLES_PER_TRAME 240
@ -29,72 +29,69 @@ static int lp = 0;
static void static void
read_sample (void) read_sample (void)
{ {
amplitude -= abs (trame[ringpos]); amplitude -= abs (trame[ringpos]);
f1 -= pulse[ringpos]; f1 -= pulse[ringpos];
f1 += pulse[(ringpos + SAMPLES_PER_TRAME) % (2 * SAMPLES_PER_TRAME)]; f1 += pulse[(ringpos + SAMPLES_PER_TRAME) % (2 * SAMPLES_PER_TRAME)];
f2 -= pulse[(ringpos + SAMPLES_PER_TRAME) % (2 * SAMPLES_PER_TRAME)]; f2 -= pulse[(ringpos + SAMPLES_PER_TRAME) % (2 * SAMPLES_PER_TRAME)];
fread (trame + ringpos, 1, sizeof (trame[0]), stdin); fread (trame + ringpos, 1, sizeof (trame[0]), stdin);
amplitude += abs (trame[ringpos]); amplitude += abs (trame[ringpos]);
if (pos ? (trame[ringpos] < -THRESHOLD) if (pos ? (trame[ringpos] < -THRESHOLD)
: (trame[ringpos] > +THRESHOLD)) : (trame[ringpos] > +THRESHOLD)) {
{ pulse[ringpos] = 1;
pulse[ringpos] = 1; pos = !pos;
pos = !pos; f2++;
f2++; } else {
} pulse[ringpos] = 0;
else }
pulse[ringpos] = 0;
ringpos++; ringpos++;
ringpos %= 2 * SAMPLES_PER_TRAME; ringpos %= 2 * SAMPLES_PER_TRAME;
lp++; lp++;
} }
int int
main () main ()
{ {
int bitn = 7; int bitn = 7;
char c = 0; char c = 0;
int i; int i;
int llp = 0; int llp = 0;
while (!feof (stdin)) while (!feof (stdin)) {
{ if (lp > 3 * SAMPLES_PER_TRAME) {
if (lp > 3 * SAMPLES_PER_TRAME) bitn = 7;
{ c = 0;
bitn = 7; lp = 0;
c = 0; llp++;
lp = 0; }
llp++; if (llp == FLUSH_TIMEOUT)
} fflush (stdout);
if (llp == FLUSH_TIMEOUT)
fflush (stdout); if (f2 > FREQ_SEP_MIN && f2 < FREQ_SEP_MAX
if (f2 > FREQ_SEP_MIN && f2 < FREQ_SEP_MAX && f1 > FREQ_DATA_MIN && f1 < FREQ_DATA_MAX) {
&& f1 > FREQ_DATA_MIN && f1 < FREQ_DATA_MAX)
{
#if DEBUG #if DEBUG
printf ("%d %d %d @%d\n", f1, f2, FREQ_DATA_THRESHOLD, printf ("%d %d %d @%d\n", f1, f2, FREQ_DATA_THRESHOLD,
ftell (stdin) - sizeof (trame)); ftell (stdin) - sizeof (trame));
#endif #endif
if (f1 < FREQ_DATA_THRESHOLD) if (f1 < FREQ_DATA_THRESHOLD)
c |= (1 << bitn); c |= (1 << bitn);
bitn--; bitn--;
if (bitn < 0) if (bitn < 0) {
{
#if DEBUG #if DEBUG
printf ("<%c, %x>", c, c); printf ("<%c, %x>", c, c);
#else #else
printf ("%c", c); printf ("%c", c);
#endif #endif
bitn = 7; bitn = 7;
c = 0; c = 0;
} }
lp = 0; lp = 0;
llp = 0; llp = 0;
for (i = 0; i < SAMPLES_PER_TRAME; i++) for (i = 0; i < SAMPLES_PER_TRAME; i++)
read_sample (); read_sample ();
continue; continue;
}
read_sample ();
} }
read_sample (); return 0;
}
return 0;
} }