Commit 745e491e authored by llea's avatar llea

Add gsm audio codec support.

Add notification incoming call.
parent 64e93d5b
SFLPhone (0.2) / 2005-01-18
SFLphone (0.3) / 2005-02-10
* ALSA driver support added (not yet operationnal)
* GSM audio codec support added
* Rings support (just ulaw format) added
* Notification incoming call added
* Apply skin feature added
* Volume control added
* Registration manually added
* Config-file in home directory changed to ".sflphone"
SFLphone (0.2) / 2005-01-18
* Lines management updated
* Blocking bug fixed
* Configuration tree, made from a config file, added for setup
......@@ -7,5 +17,5 @@ SFLPhone (0.2) / 2005-01-18
* Apply feature updated
* Non-network or request failure cases updated
SFLPhone (0.1a) / 2004-12-22
SFLphone (0.1a) / 2004-12-22
* First release
......@@ -4,6 +4,7 @@
# Author: Laurielle Lea (laurielle.lea@savoirfairelinux.com)
#
all:
cd gsm ; make
cd src; make
install:
......@@ -14,4 +15,5 @@ uninstall:
clean:
cd src; make clean
cd gsm ; make clean
Copyright 1992, 1993, 1994 by Jutta Degener and Carsten Bormann,
Technische Universitaet Berlin
Any use of this software is permitted provided that this notice is not
removed and that neither the authors nor the Technische Universitaet Berlin
are deemed to have made any representations as to the suitability of this
software for any purpose nor are held responsible for any defects of
this software. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
As a matter of courtesy, the authors request to be informed about uses
this software has found, about bugs in this software, and about any
improvements that may be of general interest.
Berlin, 28.11.1994
Jutta Degener
Carsten Bormann
Fri Jul 5 19:26:37 1996 Jutta Degener (jutta@cs.tu-berlin.de)
* Release 1.0 Patchlevel 10
src/toast_alaw.c: exchanged A-law tables for something
slightly more A-law.
Tue Jul 2 12:18:20 1996 Jutta Degener (jutta@cs.tu-berlin.de)
* Release 1.0 Patchlevel 9
src/long_term.c: in FLOAT_MUL mode, an array was accessed past its end
src/gsm_option.c: three options related to WAV #49 packing
src/gsm_encode.c: support WAV #49-style encoding.
src/gsm_decode.c: support WAV #49-style decoding.
tls/sour.c: generate the WAV bit shifting code, encode
tls/ginger.c: generate the WAV bit shifting code, decode
The WAV code goes back to an inofficial patch #8 that
Jeff Chilton sent us (hence the jump from 7 to 9).
src/toast.c: add _fsetmode() calls to set stdin/stdout to
binary (from an OS/2 port by Arnd Gronenberg.)
Tue Mar 7 01:55:10 1995 Jutta Degener (jutta@cs.tu-berlin.de)
* Release 1.0 Patchlevel 7
src/long_term.c: Yet another 16-bit overflow
src/toast.c: -C option to toast, cuts LPC time
src/gsm_option.c: corresponding LPC_CUT option to GSM library
Fri Dec 30 23:33:50 1994 Jutta Degener (jutta@cs.tu-berlin.de)
* Release 1.0 Patchlevel 6
src/lpc.c: fixed 16-bit addition overflow in Autocorrelation code
src/add.c: gsm_L_asl should fall back on gsm_L_asr, not gsm_asr
Mon Nov 28 20:49:57 1994 Jutta Degener (jutta@cs.tu-berlin.de)
* Release 1.0 Patchlevel 5
src/toast_audio.c: initialization should return -1 on error
src/gsm_destroy.c: #include configuration header file
src/add.c: gsm_sub should cast its parameters to longword
man/*: bug reports to {jutta,cabo}@cs.tu-berlin.de, not to toast@tub
inc/private.h: longword long by default, not int
inc/toast.h: read/write fopen modes "rb" and "wb", not just "r"
src/toast.c: better (or different, anyway) error handling in process()
Tue May 10 19:41:34 1994 Jutta Degener (jutta at kugelbus)
* Release 1.0 Patchlevel 4
inc/private.h: GSM_ADD should cast to ulongword, not to unsigned.
src/long_term.c: missing cast to longword.
add-test/add_test.c: Test macros too, not only functions,
thanks to Simao Ferraz de Campos Neto, simao@dragon.cpqd.ansp.br
General cleanup: remove unused variables, add function prototypes.
Tue Jan 25 22:53:40 1994 Jutta Degener (jutta at kugelbus)
* Release 1.0 Patchlevel 3
changed rpe.c's STEP macro to work with 16-bit integers,
thanks to Dr Alex Lee (alexlee@solomon.technet.sg);
removed non-fatal bugs from add-test.dta, private.h
and toast_audio.c, thanks to P. Emanuelsson.
Fri Jan 29 19:02:12 1993 Jutta Degener (jutta at kraftbus)
* Release 1.0 Patchlevel 2
fixed L_add(0,-1) in src/add.c and inc/private.h,
thanks to Raphael Trommer at AT&T Bell Laboratories;
various other ANSI C compatibility details
Fri Oct 30 17:58:54 1992 Jutta Degener (jutta at kraftbus)
* Release 1.0 Patchlevel 1
Switched uid/gid in toast's [f]chown calls.
Wed Oct 28 14:12:35 1992 Carsten Bormann (cabo at kubus)
* Release 1.0: released
Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
Universitaet Berlin. See the accompanying file "COPYRIGHT" for
details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
How to get started:
Edit the Makefile.
You should configure a few machine-dependencies and what
compiler you want to use.
The code works both with ANSI and K&R-C. Use
-DNeedFunctionPrototypes to compile with, or
-UNeedFunctionPrototypes to compile without, function
prototypes in the header files.
Make addtst
The "add" program that will be compiled and run checks whether
the basic math functions of the gsm library work with your
compiler. If it prints anything to stderr, complain (to us).
Edit inc/config.h.
Make
Local versions of the gsm library and the "compress"-like filters
toast, untoast and tcat will be generated.
If the compilation aborts because of a missing function,
declaration, or header file, see if there's something in
inc/config.h to work around it. If not, complain.
Try it
Grab an audio file from somewhere (raw u-law or Sun .au is fine,
linear 16-bit in host byte order will do), copy it, toast it,
untoast it, and listen to the result.
The GSM-encoded and -decoded audio should have the quality
of a good phone line. If the resulting audio is noisier than
your original, or if you hear compression artifacts, complain;
that's a bug in our software, not a bug in the GSM encoding
standard itself.
Installation
You can install the gsm library interface, or the toast binaries,
or both.
Edit the Makefile
Fill in the directories where you want to install the
library, header files, manual pages, and binaries.
Turn off the installation of one half of the distribution
(i.e., gsm library or toast binaries) by not setting the
corresponding directory root Makefile macro.
make install
will install the programs "toast" with two links named
"tcat" and "untoast", and the gsm library "libgsm.a" with
a "gsm.h" header file, and their respective manual pages.
Optimizing
This code was developed on a machine without an integer
multiplication instruction, where we obtained the fastest result by
replacing some of the integer multiplications with floating point
multiplications.
If your machine does multiply integers fast enough,
leave USE_FLOAT_MUL undefined. The results should be the
same in both cases.
On machines with fast floating point arithmetic, defining
both USE_FLOAT_MUL and FAST makes a run-time library
option available that will (in a few crucial places) use
``native'' floating point operations rather than the bit-by-bit
defined ones of the GSM standard. If you use this fast
option, the outcome will not be bitwise identical to the
results prescribed by the standard, but it is compatible with
the standard encoding, and a user is unlikely to notice a
difference.
Bug Reports
Please direct bug reports, questions, and comments to
jutta@cs.tu-berlin.de and cabo@informatik.uni-bremen.de.
Good luck,
Jutta Degener,
Carsten Bormann
--
Copyright 1992, 1993, 1994, by Jutta Degener and Carsten Bormann,
Technische Universitaet Berlin. See the accompanying file "COPYRIGHT"
for details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
The gsm library has been tested successfully on the following platforms:
- Various Sun4's running SunOS 4.1.2
- SPARC1 (SunOS 4.1.1)
- Integrated Solutions 68k Optimum running 4.3BSD UNIX with a Green Hills cc
- NeXTstation running NeXT-OS/Mach 3.0
- No-name AT/386 with Xenix 2.3.2 (using -DSTUPID_COMPILER)
- RS/6000-350 running AIX 3.2.0
- RS/6000-320 running AIX 3.1.5
- Alliant FX80 (Concentrix 5.7)
- SGI Indigo XS4000 (IRIX 4.0.5F)
gsm-1.0/COPYRIGHT
gsm-1.0/ChangeLog
gsm-1.0/INSTALL
gsm-1.0/MACHINES
gsm-1.0/MANIFEST
gsm-1.0/Makefile
gsm-1.0/README
gsm-1.0/add-test/add_test.c
gsm-1.0/add-test/add_test.dta
gsm-1.0/inc/gsm.h
gsm-1.0/inc/proto.h
gsm-1.0/inc/unproto.h
gsm-1.0/inc/config.h
gsm-1.0/inc/private.h
gsm-1.0/inc/toast.h
gsm-1.0/man/bitter.1
gsm-1.0/man/gsm.3
gsm-1.0/man/gsm_explode.3
gsm-1.0/man/gsm_print.3
gsm-1.0/man/gsm_option.3
gsm-1.0/man/toast.1
gsm-1.0/src/add.c
gsm-1.0/src/code.c
gsm-1.0/src/debug.c
gsm-1.0/src/decode.c
gsm-1.0/src/gsm_destroy.c
gsm-1.0/src/gsm_decode.c
gsm-1.0/src/gsm_encode.c
gsm-1.0/src/gsm_explode.c
gsm-1.0/src/gsm_implode.c
gsm-1.0/src/gsm_create.c
gsm-1.0/src/gsm_print.c
gsm-1.0/src/gsm_option.c
gsm-1.0/src/long_term.c
gsm-1.0/src/lpc.c
gsm-1.0/src/preprocess.c
gsm-1.0/src/rpe.c
gsm-1.0/src/short_term.c
gsm-1.0/src/table.c
gsm-1.0/src/toast.c
gsm-1.0/src/toast_alaw.c
gsm-1.0/src/toast_audio.c
gsm-1.0/src/toast_lin.c
gsm-1.0/src/toast_ulaw.c
gsm-1.0/tls/bitter.c
gsm-1.0/tls/bitter.dta
gsm-1.0/tls/taste.c
gsm-1.0/tls/taste.h
gsm-1.0/tls/sweet.c
gsm-1.0/tls/sour.c
gsm-1.0/tls/sour1.dta
gsm-1.0/tls/sour2.dta
gsm-1.0/tls/ginger.c
gsm-1.0/tst/cod2lin.c
gsm-1.0/tst/cod2txt.c
gsm-1.0/tst/gsm2cod.c
gsm-1.0/tst/lin2cod.c
gsm-1.0/tst/lin2txt.c
gsm-1.0/tst/run
CC=g++
CFLAGS=-Wall -g -O3 -I. -I.. -DHAVE_CONFIG_H
AR=ar
OBJS = add.o\
gsm_create.o\
gsm_explode.o\
long_term.o\
short_term.o\
code.o\
gsm_decode.o\
gsm_implode.o\
lpc.o\
table.o\
debug.o\
gsm_destroy.o\
gsm_option.o\
preprocess.o\
decode.o\
gsm_encode.o\
gsm_print.o\
rpe.o
all: libgsm.a
.c.o:
$(CC) $(CFLAGS) -c -o $@ $<
clean:
rm -f *.o *.a *~ *.moc.cpp *.bak
libgsm.a: $(OBJS)
$(AR) rcs $@ $(OBJS)
GSM 06.10 13 kbit/s RPE/LTP speech compression available
--------------------------------------------------------
The Communications and Operating Systems Research Group (KBS) at the
Technische Universitaet Berlin is currently working on a set of
UNIX-based tools for computer-mediated telecooperation that will be
made freely available.
As part of this effort we are publishing an implementation of the
European GSM 06.10 provisional standard for full-rate speech
transcoding, prI-ETS 300 036, which uses RPE/LTP (residual pulse
excitation/long term prediction) coding at 13 kbit/s.
GSM 06.10 compresses frames of 160 13-bit samples (8 kHz sampling
rate, i.e. a frame rate of 50 Hz) into 260 bits; for compatibility
with typical UNIX applications, our implementation turns frames of 160
16-bit linear samples into 33-byte frames (1650 Bytes/s).
The quality of the algorithm is good enough for reliable speaker
recognition; even music often survives transcoding in recognizable
form (given the bandwidth limitations of 8 kHz sampling rate).
The interfaces offered are a front end modelled after compress(1), and
a library API. Compression and decompression run faster than realtime
on most SPARCstations. The implementation has been verified against the
ETSI standard test patterns.
Jutta Degener (jutta@cs.tu-berlin.de)
Carsten Bormann (cabo@cs.tu-berlin.de)
Communications and Operating Systems Research Group, TU Berlin
Fax: +49.30.31425156, Phone: +49.30.31424315
--
Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
Universitaet Berlin. See the accompanying file "COPYRIGHT" for
details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
/*
* Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
* Universitaet Berlin. See the accompanying file "COPYRIGHT" for
* details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
*/
/* $Header$ */
/*
* See private.h for the more commonly used macro versions.
*/
#include <stdio.h>
#include <assert.h>
#include "private.h"
#include "gsm.h"
#include "proto.h"
#define saturate(x) \
((x) < MIN_WORD ? MIN_WORD : (x) > MAX_WORD ? MAX_WORD: (x))
word gsm_add P2((a,b), word a, word b)
{
longword sum = (longword)a + (longword)b;
return saturate(sum);
}
word gsm_sub P2((a,b), word a, word b)
{
longword diff = (longword)a - (longword)b;
return saturate(diff);
}
word gsm_mult P2((a,b), word a, word b)
{
if (a == MIN_WORD && b == MIN_WORD) return MAX_WORD;
else return SASR( (longword)a * (longword)b, 15 );
}
word gsm_mult_r P2((a,b), word a, word b)
{
if (b == MIN_WORD && a == MIN_WORD) return MAX_WORD;
else {
longword prod = (longword)a * (longword)b + 16384;
prod >>= 15;
return prod & 0xFFFF;
}
}
word gsm_abs P1((a), word a)
{
return a < 0 ? (a == MIN_WORD ? MAX_WORD : -a) : a;
}
longword gsm_L_mult P2((a,b),word a, word b)
{
assert( a != MIN_WORD || b != MIN_WORD );
return ((longword)a * (longword)b) << 1;
}
longword gsm_L_add P2((a,b), longword a, longword b)
{
if (a < 0) {
if (b >= 0) return a + b;
else {
ulongword A = (ulongword)-(a + 1) + (ulongword)-(b + 1);
return A >= MAX_LONGWORD ? MIN_LONGWORD :-(longword)A-2;
}
}
else if (b <= 0) return a + b;
else {
ulongword A = (ulongword)a + (ulongword)b;
return A > MAX_LONGWORD ? MAX_LONGWORD : A;
}
}
longword gsm_L_sub P2((a,b), longword a, longword b)
{
if (a >= 0) {
if (b >= 0) return a - b;
else {
/* a>=0, b<0 */
ulongword A = (ulongword)a + -(b + 1);
return A >= MAX_LONGWORD ? MAX_LONGWORD : (A + 1);
}
}
else if (b <= 0) return a - b;
else {
/* a<0, b>0 */
ulongword A = (ulongword)-(a + 1) + b;
return A >= MAX_LONGWORD ? MIN_LONGWORD : -(longword)A - 1;
}
}
static unsigned char const bitoff[ 256 ] = {
8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
word gsm_norm P1((a), longword a )
/*
* the number of left shifts needed to normalize the 32 bit
* variable L_var1 for positive values on the interval
*
* with minimum of
* minimum of 1073741824 (01000000000000000000000000000000) and
* maximum of 2147483647 (01111111111111111111111111111111)
*
*
* and for negative values on the interval with
* minimum of -2147483648 (-10000000000000000000000000000000) and
* maximum of -1073741824 ( -1000000000000000000000000000000).
*
* in order to normalize the result, the following
* operation must be done: L_norm_var1 = L_var1 << norm( L_var1 );
*
* (That's 'ffs', only from the left, not the right..)
*/
{
assert(a != 0);
if (a < 0) {
if (a <= -1073741824) return 0;
a = ~a;
}
return a & 0xffff0000
? ( a & 0xff000000
? -1 + bitoff[ 0xFF & (a >> 24) ]
: 7 + bitoff[ 0xFF & (a >> 16) ] )
: ( a & 0xff00
? 15 + bitoff[ 0xFF & (a >> 8) ]
: 23 + bitoff[ 0xFF & a ] );
}
longword gsm_L_asl P2((a,n), longword a, int n)
{
if (n >= 32) return 0;
if (n <= -32) return -(a < 0);
if (n < 0) return gsm_L_asr(a, -n);
return a << n;
}
word gsm_asl P2((a,n), word a, int n)
{
if (n >= 16) return 0;
if (n <= -16) return -(a < 0);
if (n < 0) return gsm_asr(a, -n);
return a << n;
}
longword gsm_L_asr P2((a,n), longword a, int n)
{
if (n >= 32) return -(a < 0);
if (n <= -32) return 0;
if (n < 0) return a << -n;
# ifdef SASR
return a >> n;
# else
if (a >= 0) return a >> n;
else return -(longword)( -(ulongword)a >> n );
# endif
}
word gsm_asr P2((a,n), word a, int n)
{
if (n >= 16) return -(a < 0);
if (n <= -16) return 0;
if (n < 0) return a << -n;
# ifdef SASR
return a >> n;
# else
if (a >= 0) return a >> n;
else return -(word)( -(uword)a >> n );
# endif
}
/*
* (From p. 46, end of section 4.2.5)
*
* NOTE: The following lines gives [sic] one correct implementation
* of the div(num, denum) arithmetic operation. Compute div
* which is the integer division of num by denum: with denum
* >= num > 0
*/
word gsm_div P2((num,denum), word num, word denum)
{
longword L_num = num;
longword L_denum = denum;
word div = 0;
int k = 15;
/* The parameter num sometimes becomes zero.
* Although this is explicitly guarded against in 4.2.5,
* we assume that the result should then be zero as well.
*/
/* assert(num != 0); */
assert(num >= 0 && denum >= num);
if (num == 0)
return 0;
while (k--) {
div <<= 1;
L_num <<= 1;
if (L_num >= L_denum) {
L_num -= L_denum;
div++;
}
}
return div;
}
/*
* Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
* Universitaet Berlin. See the accompanying file "COPYRIGHT" for