annotate sw/mcsi-rxtx/record.c @ 13:315428573a25

fc-mcsi-rxtx: implement record function
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 28 Oct 2024 07:24:53 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * Here we implement the functionality of recording MCSI Rx streams
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * into robe files.
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdlib.h>
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 extern u_short rx_pcm_samples[160];
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 static FILE *record_file;
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 void
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 record_process()
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 {
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 unsigned n, samp;
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 if (!record_file)
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 return;
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 for (n = 0; n < 160; n++) {
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 samp = rx_pcm_samples[n];
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 putc(samp >> 8, record_file);
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 putc(samp, record_file);
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 }
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 }
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 void
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 record_auto_stop()
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 {
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 if (!record_file)
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 return;
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 fclose(record_file);
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 record_file = 0;
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 }
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 void
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 cmd_record(argc, argv)
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 char **argv;
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 {
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 if (record_file) {
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 printf("error: recording already in progress\n");
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 return;
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 }
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 record_file = fopen(argv[1], "w");
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 if (!record_file)
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 perror(argv[1]);
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 }
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 void
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 cmd_record_stop()
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 {
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 if (!record_file) {
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 printf("error: no recording in progress\n");
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 return;
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 }
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 fclose(record_file);
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 record_file = 0;
315428573a25 fc-mcsi-rxtx: implement record function
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 }