changeset 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 b55451463161
children d5bcfb378049
files .hgignore dmw/Makefile dmw/gen-dmw-bin.c
diffstat 3 files changed, 71 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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\.
--- /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
--- /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 <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+
+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);
+}