GSM6.10 for Kylix (Wrapper herewith)


2004-10-18 05:51:22 PM
kylix1
I had to build this for a VoIP application. It's quite straightforward, but
a useful codec (1350 kb/sec).
Hope it proves useful to someone else also, and thanks to Robert for
pointing me in the right direction......
I've removed the references to the explode/print etc functions, as only
needed the simple decode and encode functions.
Dean
////////////////////////////////////////////////////////////////////////////
////
//
// Wrapper for libgsm.1.0.10 GSM/PCM codec conversion
//
// Library wrapped for Kylix/Pascal by Dean Elwood & Robert Marquardt
//
// Useage:-
//
// Call gsm_create to initiate a pass and gsm_destroy when done
//
// To encode frame(s):-
//
// var
// GSMFrame : gsm_frame; //-- a 33 byte GSM frame array
// PCMFrame : pcm_frame; //-- a 160 byte PCM array (8khz 16 bit
little-endian)
// GSMPtr : gsm;
// begin
// GSMPtr := gsm_create;
// ..loop..
// gsm_encode(GSMPtr, GSMFrame, PCMFrame);
// ..loop..
// gsm_destroy(GSMPtr);
// end;
//
// To decode frame(s):-
//
// var
// GSMFrame : gsm_frame; //-- a 33 byte GSM frame array
// PCMFrame : pcm_frame; //-- a 160 byte PCM array (8khz 16 bit
little-endian)
// GSMPtr : gsm;
// begin
// GSMPtr := gsm_create;
// ..loop..
// gsm_decode(GSMPtr, GSMFrame, PCMFrame);
// ..loop..
// gsm_destroy(GSMPtr);
// end;
//
//
// This wrapper requires libgsm.1.0.10
//
// For more info on GSM6.10 please see
kbs.cs.tu-berlin.de/~jutta/toast.html
//
////////////////////////////////////////////////////////////////////////////
////
{*
* 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.
*}
unit gsmwrapper;
interface
type
gsm = Pointer;
gsm_signal = Smallint; // signed 16 bit
gsm_byte = Byte;
gsm_frame = array [0..32] of gsm_byte; // 33 * 8 bits
pcm_frame = array [0..159] of gsm_signal;
const
GSM_MAGIC = $D; // 13 kbit/s RPE-LTP
GSM_PATCHLEVEL = 10;
GSM_MINOR = 0;
GSM_MAJOR = 1;
GSM_OPT_VERBOSE = 1;
GSM_OPT_FAST = 2;
GSM_OPT_LTP_CUT = 3;
GSM_OPT_WAV49 = 4;
GSM_OPT_FRAME_INDEX = 5;
GSM_OPT_FRAME_CHAIN = 6;
function gsm_create: gsm; stdcall;
procedure gsm_destroy(gsmhandle: gsm); stdcall;
procedure gsm_encode(gsmhandle: gsm; Param2: gsm_frame; Param3:
pcm_frame); stdcall;
function gsm_decode(gsmhandle: gsm; Param2: gsm_frame; Param3:
pcm_frame): Integer; stdcall;
implementation
const
GSMModuleName = 'libgsm.so.1.0.10';
function gsm_create; external GSMModuleName name 'gsm_create';
procedure gsm_destroy; external GSMModuleName name 'gsm_destroy';
procedure gsm_encode; external GSMModuleName name 'gsm_encode';
function gsm_decode; external GSMModuleName name 'gsm_decode';
end.