annotate ringtools/imy/main.c @ 924:d452188587b4

rvinterf: begin change to backslash escape output format Right now throughout the rvinterf suite, any time we emit output that is expected to be ASCII, but may contain non-printable garbage, we use 'cat -v' form of garbage character representation. Unfortunately, this transformation is lossy (can't be reversed 100% reliably in the user's wetware), hence we would like to migrate to C-style backslash escapes, including doubling of any already-present backslashes - this escape mechanism is lossless. Begin this change by converting the output of RV and L1 traces in rvinterf and rvtdump.
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 23 May 2023 03:10:50 +0000
parents fd4c9bc7835d
children a96cb97b66a2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
882
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This file contains the top-level code for fc-imy2pwt.
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <stdio.h>
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdlib.h>
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include "sizelimits.h"
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 char *imy_filename;
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 char melody_str_buf[MELODY_BUF_SIZE];
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 unsigned beats_per_min = 120;
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 unsigned tdma_durations[6][4];
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 FILE *outF;
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 main(argc, argv)
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 char **argv;
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 {
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 if (argc < 2 || argc > 3) {
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 fprintf(stderr, "usage: %s imy-file [outfile]\n", argv[0]);
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 exit(1);
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 }
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 imy_filename = argv[1];
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 read_imy_firstpass();
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 compute_note_durations();
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 if (argc > 2) {
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 outF = fopen(argv[2], "w");
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 if (!outF) {
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 perror(argv[2]);
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 exit(1);
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 }
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 } else
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 outF = stdout;
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 melody_convert_pass();
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 exit(0);
fd4c9bc7835d fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 }