Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

gsm(3) [centos man page]

GSM(3)							     Library Functions Manual							    GSM(3)

gsm_create, gsm_destroy, gsm_encode, gsm_decode -- GSM 06.10 lossy sound compression SYNOPSIS
#include "gsm.h" gsm gsm_create(); void gsm_encode(handle, src, dst) gsm handle; gsm_signal src[160]; gsm_frame dst; int gsm_decode(handle, src, dst) gsm handle; gsm_frame src; gsm_signal dst[160]; void gsm_destroy(handle) gsm handle; DESCRIPTION
Gsm is an implementation of the final draft GSM 06.10 standard for full-rate speech transcoding. gsm_create() initializes a gsm pass and returns a 'gsm' object which can be used as a handle in subsequent calls to gsm_decode(), gsm_encode() or gsm_destroy(). gsm_encode() encodes an array of 160 13-bit samples (given as gsm_signal's, signed integral values of at least 16 bits) into a gsm_frame of 33 bytes. (gsm_frame is a type defined as an array of 33 gsm_bytes in gsm.h.) gsm_decode() decodes a gsm_frame into an array of 160 13-bit samples (given as gsm_signals), which sound rather like what you handed to gsm_encode() on the other side of the wire. gsm_destroy() finishes a gsm pass and frees all storage associated with it. Sample format The following scaling is assumed for input to the algorithm: 0 1 11 12 S..v..v..v..v..v..v..v..v..v..v..v..v..*..*..* Only the top 13 bits are used as a signed input value. The output of gsm_decode() has the three lower bits set to zero. RETURN VALUE
gsm_create() returns an opaque handle object of type gsm, or 0 on error. gsm_decode() returns -1 if the passed frame is invalid, else 0. EXAMPLE
#include "gsm.h" gsm handle; gsm_frame buf; gsm_signal sample[160]; int cc, soundfd; play() { /* read compressed data from standard input, write to soundfd */ if (!(handle = gsm_create())) error... while (cc = read(0, (char *)buf, sizeof buf)) { if (cc != sizeof buf) error... if (gsm_decode(handle, buf, sample) < 0) error... if (write(soundfd, sample, sizeof sample) != sizeof sample) error... } gsm_destroy(handle); } record() { /* read from soundfd, write compressed to standard output */ if (!(handle = gsm_create())) error... while (cc = read(soundfd, sample, sizeof sample)) { if (cc != sizeof sample) error... gsm_encode(handle, sample, buf); if (write(1, (char *)buf, sizeof buf) != sizeof sample) error... } gsm_destroy(handle); } BUGS
Please direct bug reports to and SEE ALSO
toast(1), gsm_print(3), gsm_explode(3), gsm_option(3) GSM(3)

Check Out this Related Man Page

TOAST(1)						      General Commands Manual							  TOAST(1)

toast -- GSM 06.10 lossy sound compression SYNOPSIS
toast [ -cdfpvhualsFC ] [ filename... ] untoast [ -cfpvhuaslF ] [ filename... ] tcat [ -vhuaslF ] [ filename... ] DESCRIPTION
Toast compresses the sound files given on its command line. Each file is replaced by a file with the extension .gsm . If no files are specified, the compression is applied to the standard input, and its result is written to standard output. Toasted files can be restored to something not quite unlike their original form by running toast -d , or untoast , on the .gsm-files or standard input. The program tcat (the same as running untoast -c ) uncompresses its input on standard output, but leaves the compressed .gsm-files alone. When files are compressed or uncompressed into other files, the ownership (if run by root), modes, accessed and modified times are main- tained between both versions. OPTIONS
-c (cat) Write to the standard output; no files are changed. -d (decode) Decode, rather than encode, the files. -f (force) Force replacement of output files if they exist. If -f is omitted and toast (or untoast) is run interactively from a termi- nal, the user is prompted as to whether the file should be replaced. -p (precious) Do not delete the source files. Source files are implicitly left alone whenever -c is specified or tcat is run. -C (LTP cut-off) Ignore most sample values when calculating the GSM long-term correlation lag during encoding. (The multiplications that do this are a bottleneck of the algorithm.) The resulting encoding process will not produce exactly the same results as GSM 06.10 would, but remains close enough to be compatible. The -C option applies only to the encoder and is silently ignored by the decoder. -F (fast) On systems with a floating point processor, but without a multiplication instruction, -F sacrifices standard conformance to performance and nearly doubles the speed of the algorithm. The resulting encoding and decoding process will not produce exactly the same results as GSM 06.10 would, but remains close enough to be compatible. The default is standard-conforming operation. -v (version) outputs the version of toast (or untoast or tcat) to stdout and exits. -h (help) prints a short overview of the options. Toast, untoast and tcat try to guess the appropriate audio data format from the file suffix. Command line options can also specify a for- mat to be used for all files. The following formats are supported: -u (uU-law) 8 kHz, 8 bit uU-law encoding (file suffix .u) -a (A-law) 8 kHz, 8 bit A-law encoding (file suffix .A) -s (Sun audio) 8 kHz, 8 bit uU-law encoding with audio header (file suffix .au) -l (linear) 8 kHz, 16 bit signed linear encoding in host byte order with 13 significant bits (file suffix .l) In absence of options or suffixes to specify a format, uU-law encoding as forced by -u is assumed. PECULIARITIES
A four bit magic number is prefixed to each 32 1/2-byte GSM frame, mainly because 32 1/2-bytes are rather clumsy to handle. WARNING
The compression algorithm used is a lossy compression algorithm devised especially for speech; on no account should it be used for text, pictures or any other non-speech-data you consider valuable. BUGS
Please direct bug reports to SEE ALSO
gsm(3) local TOAST(1)
Man Page