# HG changeset patch # User Mychaela Falconia # Date 1712474423 0 # Node ID e81a8c274fa6c635722770d139872cd2db1bb2e4 # Parent b55451463161cb3c2471f114af38307ae1d9d626 dmw: generate G.711 digital mW and convert both versions to robe diff -r b55451463161 -r e81a8c274fa6 .hgignore --- a/.hgignore Wed Apr 03 20:15:37 2024 +0000 +++ b/.hgignore Sun Apr 07 07:20:23 2024 +0000 @@ -5,3 +5,6 @@ ^amrdiff/amrdiff$ ^amrdiff/readone-amr$ ^amrdiff/readone-efr$ + +^dmw/gen-dmw-bin$ +^dmw/dmw-[au]law\. diff -r b55451463161 -r e81a8c274fa6 dmw/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dmw/Makefile Sun Apr 07 07:20:23 2024 +0000 @@ -0,0 +1,24 @@ +CC= gcc +CFLAGS= -O2 +PROG= gen-dmw-bin +FILES= dmw-alaw.bin dmw-alaw.robe dmw-ulaw.bin dmw-ulaw.robe + +all: ${PROG} ${FILES} + +${PROG}: ${PROG}.c + ${CC} ${CFLAGS} -o $@ $@.c + +dmw-alaw.bin: ${PROG} + ./${PROG} $@ alaw 20 + +dmw-alaw.robe: dmw-alaw.bin + pcm8-to-pcm16 alaw dmw-alaw.bin $@ + +dmw-ulaw.bin: ${PROG} + ./${PROG} $@ ulaw 20 + +dmw-ulaw.robe: dmw-ulaw.bin + pcm8-to-pcm16 ulaw dmw-ulaw.bin $@ + +clean: + rm -f *.o ${PROG} *.bin *.robe diff -r b55451463161 -r e81a8c274fa6 dmw/gen-dmw-bin.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dmw/gen-dmw-bin.c Sun Apr 07 07:20:23 2024 +0000 @@ -0,0 +1,44 @@ +/* + * This program generates a binary G.711 file containing the standard + * DMW (digital milliwatt) sequence repeated for the specified number + * of times; the number of repetitions will be the total duration + * of the output in milliseconds. + */ + +#include +#include +#include +#include +#include + +static uint8_t dmw_alaw[8] = {0x34, 0x21, 0x21, 0x34, 0xB4, 0xA1, 0xA1, 0xB4}; +static uint8_t dmw_ulaw[8] = {0x1E, 0x0B, 0x0B, 0x1E, 0x9E, 0x8B, 0x8B, 0x9E}; + +main(argc, argv) + char **argv; +{ + FILE *outf; + unsigned total_ms, n; + uint8_t *seq; + + if (argc != 4) { +usage: fprintf(stderr, "usage: outfile alaw|ulaw number-of-ms\n", + argv[0]); + exit(1); + } + outf = fopen(argv[1], "w"); + if (!outf) { + perror(argv[1]); + exit(1); + } + if (!strcmp(argv[2], "alaw")) + seq = dmw_alaw; + else if (!strcmp(argv[2], "ulaw")) + seq = dmw_ulaw; + else + goto usage; + total_ms = atoi(argv[3]); + for (n = 0; n < total_ms; n++) + fwrite(seq, 1, 8, outf); + exit(0); +}