aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/i4b/dtmfdecode
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/i4b/dtmfdecode')
-rw-r--r--usr.sbin/i4b/dtmfdecode/Makefile15
-rw-r--r--usr.sbin/i4b/dtmfdecode/dtmfdecode.164
-rw-r--r--usr.sbin/i4b/dtmfdecode/dtmfdecode.c150
3 files changed, 0 insertions, 229 deletions
diff --git a/usr.sbin/i4b/dtmfdecode/Makefile b/usr.sbin/i4b/dtmfdecode/Makefile
deleted file mode 100644
index 792b2ef39301..000000000000
--- a/usr.sbin/i4b/dtmfdecode/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-#---------------------------------------------------------------------------
-#
-# $FreeBSD$
-#
-# last edit-date: [Thu May 20 12:04:05 1999]
-#
-#---------------------------------------------------------------------------
-
-PROG = dtmfdecode
-SRC = dtmfdecode.c
-#LDADD += -lm
-CFLAGS += -Wall -g -DDEBUG
-MAN1 = dtmfdecode.1
-
-.include <bsd.prog.mk>
diff --git a/usr.sbin/i4b/dtmfdecode/dtmfdecode.1 b/usr.sbin/i4b/dtmfdecode/dtmfdecode.1
deleted file mode 100644
index 42cd5beb7419..000000000000
--- a/usr.sbin/i4b/dtmfdecode/dtmfdecode.1
+++ /dev/null
@@ -1,64 +0,0 @@
-.\"
-.\" Copyright (c) 1999 Hellmuth Michaelis. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $FreeBSD$
-.\"
-.\" last edit-date: [Mon Apr 26 13:42:15 1999]
-.\"
-.\"
-.Dd February, 15 1999
-.Dt DTMFDECODE 1
-.Os
-.Sh NAME
-.Nm dtmfdecode
-.Nd decodes DTMF tones from A-law audio data
-.Sh SYNOPSIS
-.Nm
-.Sh DESCRIPTION
-.Nm dtmfdecode
-is part of the isdn4bsd package and is used to detect DTMF tones in the
-audio stream.
-.Pp
-It reads audio G.711 A-Law coded data from stdin and outputs the detected
-numbers values as ASCII charcters to stdout.
-.Pp
-The detector is implemented as 8 narrow band-pass filters realized with
-an integer double-cross recursive algorithm. Various ad-hoc methods are
-employed to provide hysteresis and anti-bounce for the detected signals.
-.Sh EXAMPLES
-The command:
-.Bd -literal -offset indent
-dtmfdecode < beep.al
-.Ed
-.Pp
-will print a "1" to stdout.
-.Sh STANDARDS
-ITU Recommendations G.711
-.Sh AUTHORS
-The
-.Nm
-utility was written by
-.An Poul-Henning Kamp Aq phk@FreeBSD.org .
-This man page was written by
-.An Hellmuth Michaelis Aq hm@FreeBSD.org .
diff --git a/usr.sbin/i4b/dtmfdecode/dtmfdecode.c b/usr.sbin/i4b/dtmfdecode/dtmfdecode.c
deleted file mode 100644
index f96bacd42b10..000000000000
--- a/usr.sbin/i4b/dtmfdecode/dtmfdecode.c
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * ----------------------------------------------------------------------------
- * "THE BEER-WARE LICENSE" (Revision 42):
- * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
- * can do whatever you want with this stuff. If we meet some day, and you think
- * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
- * ----------------------------------------------------------------------------
- *
- * $FreeBSD$
- *
- * Extract DTMF signalling from ISDN4BSD A-law coded audio data
- *
- * A-Law to linear conversion from the sox package.
- *
- */
-
-#include <stdio.h>
-#include <math.h>
-
-/* Integer math scaling factor */
-#define FSC (1<<12)
-
-/* Alaw parameters */
-#define SIGN_BIT (0x80) /* Sign bit for a A-law byte. */
-#define QUANT_MASK (0xf) /* Quantization field mask. */
-#define SEG_SHIFT (4) /* Left shift for segment number. */
-#define SEG_MASK (0x70) /* Segment field mask. */
-
-static int
-alaw2linear(a_val)
- unsigned char a_val;
-{
- int t;
- int seg;
-
- a_val ^= 0x55;
-
- t = (a_val & QUANT_MASK) << 4;
- seg = ((unsigned)a_val & SEG_MASK) >> SEG_SHIFT;
- switch (seg) {
- case 0:
- t += 8;
- break;
- case 1:
- t += 0x108;
- break;
- default:
- t += 0x108;
- t <<= seg - 1;
- }
- return ((a_val & SIGN_BIT) ? t : -t);
-}
-
-#ifdef USE_COS
-/* The frequencies we're trying to detect */
-static int dtmf[8] = {697, 770, 852, 941, 1209, 1336, 1477, 1633};
-#else
-/* precalculated: p1[kk] = (-cos(2 * 3.141592 * dtmf[kk] / 8000.0) * FSC) */
-static int p1[8] = {-3497, -3369, -3212, -3027, -2384, -2040, -1635, -1164};
-#endif
-
-/* This is the Q of the filter (pole radius) */
-#define POLRAD .99
-
-#define P2 ((int)(POLRAD*POLRAD*FSC))
-
-int
-main(int argc, char **argv)
-{
- int i, kk, t, nn, s, so, ia;
- int x, c, d, f, h[8], k[8], n, y[8];
-#ifdef USE_COS
- int p1[8];
-#endif
- int alaw[256];
- char key[256];
-
- for (kk = 0; kk < 8; kk++) {
- y[kk] = h[kk] = k[kk] = 0;
-#ifdef USE_COS
- p1[kk] = (-cos(2 * 3.141592 * dtmf[kk] / 8000.0) * FSC);
-#endif
- }
-
- for (i = 0; i < 256; i++) {
- key[i] = '?';
- alaw[i] = alaw2linear(i) / (32768/FSC);
- }
-
- /* We encode the tones in 8 bits, translate those to symbol */
- key[0x00] = '\0';
-
- key[0x11] = '1'; key[0x12] = '4'; key[0x14] = '7'; key[0x18] = '*';
- key[0x21] = '2'; key[0x22] = '5'; key[0x24] = '8'; key[0x28] = '0';
- key[0x41] = '3'; key[0x42] = '6'; key[0x44] = '9'; key[0x48] = '#';
- key[0x81] = 'A'; key[0x82] = 'B'; key[0x84] = 'C'; key[0x88] = 'D';
-
- nn = 0;
- ia = 0;
- so = 0;
- t = 0;
- while ((i = getchar()) != EOF)
- {
- t++;
-
- /* Convert to our format */
- x = alaw[i];
-
- /* Input amplitude */
- if (x > 0)
- ia += (x - ia) / 128;
- else
- ia += (-x - ia) / 128;
-
- /* For each tone */
- s = 0;
- for(kk = 0; kk < 8; kk++) {
-
- /* Turn the crank */
- c = (P2 * (x - k[kk])) / FSC;
- d = x + c;
- f = (p1[kk] * (d - h[kk])) / FSC;
- n = x - k[kk] - c;
- k[kk] = h[kk] + f;
- h[kk] = f + d;
-
- /* Detect and Average */
- if (n > 0)
- y[kk] += (n - y[kk]) / 64;
- else
- y[kk] += (-n - y[kk]) / 64;
-
- /* Threshold */
- if (y[kk] > FSC/10 && y[kk] > ia)
- s |= 1 << kk;
- }
-
- /* Hysteresis and noise supressor */
- if (s != so) {
-/* printf("x %d %x -> %x\n",t,so, s); */
- nn = 0;
- so = s;
- } else if (nn++ == 520 && key[s]) {
- putchar(key[s]);
-/* printf(" %d %x\n",t,s); */
- }
- }
- putchar('\n');
- return (0);
-}