util/spkmodem_recv: Say frame in English
Source code should be written in English. Signed-off-by: Leah Rowe <leah@libreboot.org>fsdg20230625
parent
e286470432
commit
abc5cfd38c
|
@ -8,7 +8,7 @@
|
||||||
/* 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_FRAME 240
|
||||||
#define FREQ_SEP_MIN 5
|
#define FREQ_SEP_MIN 5
|
||||||
#define FREQ_SEP_MAX 15
|
#define FREQ_SEP_MAX 15
|
||||||
#define FREQ_DATA_MIN 15
|
#define FREQ_DATA_MIN 15
|
||||||
|
@ -19,8 +19,8 @@
|
||||||
#define DEBUG 0
|
#define DEBUG 0
|
||||||
#define FLUSH_TIMEOUT 1
|
#define FLUSH_TIMEOUT 1
|
||||||
|
|
||||||
static signed short trame[2 * SAMPLES_PER_TRAME];
|
static signed short frame[2 * SAMPLES_PER_FRAME];
|
||||||
static signed short pulse[2 * SAMPLES_PER_TRAME];
|
static signed short pulse[2 * SAMPLES_PER_FRAME];
|
||||||
static int ringpos = 0;
|
static int ringpos = 0;
|
||||||
static int pos, f1, f2;
|
static int pos, f1, f2;
|
||||||
static int amplitude = 0;
|
static int amplitude = 0;
|
||||||
|
@ -39,7 +39,7 @@ main (int argc, char *argv[])
|
||||||
(void)argc; (void)argv;
|
(void)argc; (void)argv;
|
||||||
|
|
||||||
while (!feof (stdin)) {
|
while (!feof (stdin)) {
|
||||||
if (lp > 3 * SAMPLES_PER_TRAME) {
|
if (lp > 3 * SAMPLES_PER_FRAME) {
|
||||||
bitn = 7;
|
bitn = 7;
|
||||||
c = 0;
|
c = 0;
|
||||||
lp = 0;
|
lp = 0;
|
||||||
|
@ -55,7 +55,7 @@ main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
#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 (frame));
|
||||||
#endif
|
#endif
|
||||||
if (f1 < FREQ_DATA_THRESHOLD)
|
if (f1 < FREQ_DATA_THRESHOLD)
|
||||||
c |= (1 << bitn);
|
c |= (1 << bitn);
|
||||||
|
@ -71,7 +71,7 @@ main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
lp = 0;
|
lp = 0;
|
||||||
llp = 0;
|
llp = 0;
|
||||||
for (i = 0; i < SAMPLES_PER_TRAME; i++)
|
for (i = 0; i < SAMPLES_PER_FRAME; i++)
|
||||||
read_sample ();
|
read_sample ();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -80,14 +80,14 @@ main (int argc, char *argv[])
|
||||||
static void
|
static void
|
||||||
read_sample (void)
|
read_sample (void)
|
||||||
{
|
{
|
||||||
amplitude -= abs (trame[ringpos]);
|
amplitude -= abs (frame[ringpos]);
|
||||||
f1 -= pulse[ringpos];
|
f1 -= pulse[ringpos];
|
||||||
f1 += pulse[(ringpos + SAMPLES_PER_TRAME) % (2 * SAMPLES_PER_TRAME)];
|
f1 += pulse[(ringpos + SAMPLES_PER_FRAME) % (2 * SAMPLES_PER_FRAME)];
|
||||||
f2 -= pulse[(ringpos + SAMPLES_PER_TRAME) % (2 * SAMPLES_PER_TRAME)];
|
f2 -= pulse[(ringpos + SAMPLES_PER_FRAME) % (2 * SAMPLES_PER_FRAME)];
|
||||||
fread (trame + ringpos, 1, sizeof (trame[0]), stdin);
|
fread (frame + ringpos, 1, sizeof (frame[0]), stdin);
|
||||||
amplitude += abs (trame[ringpos]);
|
amplitude += abs (frame[ringpos]);
|
||||||
|
|
||||||
if (abs(trame[ringpos]) > THRESHOLD) { /* rising/falling edge(pulse) */
|
if (abs(frame[ringpos]) > THRESHOLD) { /* rising/falling edge(pulse) */
|
||||||
pulse[ringpos] = 1;
|
pulse[ringpos] = 1;
|
||||||
pos = !pos;
|
pos = !pos;
|
||||||
f2++;
|
f2++;
|
||||||
|
@ -96,6 +96,6 @@ read_sample (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
ringpos++;
|
ringpos++;
|
||||||
ringpos %= 2 * SAMPLES_PER_TRAME;
|
ringpos %= 2 * SAMPLES_PER_FRAME;
|
||||||
lp++;
|
lp++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue