comparison dmw/gen-dmw-bin.c @ 7:e81a8c274fa6

dmw: generate G.711 digital mW and convert both versions to robe
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 07 Apr 2024 07:20:23 +0000
parents
children
comparison
equal deleted inserted replaced
6:b55451463161 7:e81a8c274fa6
1 /*
2 * This program generates a binary G.711 file containing the standard
3 * DMW (digital milliwatt) sequence repeated for the specified number
4 * of times; the number of repetitions will be the total duration
5 * of the output in milliseconds.
6 */
7
8 #include <stdio.h>
9 #include <stdint.h>
10 #include <stdlib.h>
11 #include <string.h>
12 #include <strings.h>
13
14 static uint8_t dmw_alaw[8] = {0x34, 0x21, 0x21, 0x34, 0xB4, 0xA1, 0xA1, 0xB4};
15 static uint8_t dmw_ulaw[8] = {0x1E, 0x0B, 0x0B, 0x1E, 0x9E, 0x8B, 0x8B, 0x9E};
16
17 main(argc, argv)
18 char **argv;
19 {
20 FILE *outf;
21 unsigned total_ms, n;
22 uint8_t *seq;
23
24 if (argc != 4) {
25 usage: fprintf(stderr, "usage: outfile alaw|ulaw number-of-ms\n",
26 argv[0]);
27 exit(1);
28 }
29 outf = fopen(argv[1], "w");
30 if (!outf) {
31 perror(argv[1]);
32 exit(1);
33 }
34 if (!strcmp(argv[2], "alaw"))
35 seq = dmw_alaw;
36 else if (!strcmp(argv[2], "ulaw"))
37 seq = dmw_ulaw;
38 else
39 goto usage;
40 total_ms = atoi(argv[3]);
41 for (n = 0; n < total_ms; n++)
42 fwrite(seq, 1, 8, outf);
43 exit(0);
44 }