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