GSM(3)
π GSM(3) β the GSM 06.10 lossy sound compression page, but make it make sense π
okay bestie, welcome to GSM(3), from the Library Functions Manual. This is the girlies' guide to gsm_create, gsm_destroy, gsm_encode and gsm_decode β aka GSM 06.10 lossy sound compression. Grab a strawberry π, we're doing speech transcoding.
β¨ NAME β¨
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;
yes she's old-school K&R style and yes she still ate π
π DESCRIPTION π
gsm is an implementation of the final draft GSM 06.10 standard for full-rate speech transcoding. It's giving vintage, it's giving telecom royalty, it's giving exactly what it says on the tin. π
gsm_create() initializes a gsm pass and returns a 'gsm' object. That object is your handle β you pass it into all the subsequent calls to gsm_decode(), gsm_encode() or gsm_destroy(). She's the main character, everyone else is a supporting role. β¨
gsm_encode() encodes an array of 160 13-bit samples (given as gsm_signal's β signed integral values of at least 16 bits, no cap) into a gsm_frame of 33 bytes. For the record, gsm_frame is a type defined as an array of 33 gsm_bytes in gsm.h. So 160 in, 33 out. Compression girlies, we love a glow-down that's actually a glow-up. π₯
gsm_decode() decodes a gsm_frame back 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. it's giving "same vibe, slightly diff outfit" π¦
gsm_destroy() finishes a gsm pass and frees all storage associated with it. Clean up after yourself, bestie. No memory leaks on this account. π§Ήπ
π 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. not her being like "the bottom three are staying home today" π
β RETURN VALUE β
gsm_create()β returns an opaque handle object of typegsm, or0on error. If you get a0, that's not a vibe, that's a problem. πgsm_decode()β returns-1if the passed frame is invalid, else0.
fr fr check your return values. gsm_decode() will straight up tell you the frame is invalid and you better listen the first time. π
π EXAMPLE π
here's the whole thing, verbatim, because she's iconic and I refuse to paraphrase her:
#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);
}
notice how play() and record() both create a handle, loop, error-check like a responsible queen, and then gsm_destroy() on the way out. that's the whole personality of this library and honestly? slay. π
β¨
π BUGS π
Please direct bug reports to jutta@pobox.com and cabo@tzi.org. they're literally asking for your emails, don't be shy π«Ά
π SEE ALSO π
and that's the GSM(3) page!! π This one lives in the Library Functions Manual, the page itself is titled GSM(3) and the footer just says GSM(3) again β no version, no date, she simply doesn't date-stamp herself, lowkey mysterious of her. anyway bestie go compress some speech, you got this ππ¦πΈπ
π¦ where this page comes from
- debian bookworm: libgsm1-dev 1.0.22-1 Β· TU-Berlin-2.0
- debian trixie: libgsm1-dev 1.0.22-1+b2 Β· TU-Berlin-2.0
- ubuntu jammy: libgsm1-dev 1.0.19-1 Β· TU-Berlin-2.0
- ubuntu noble: libgsm1-dev 1.0.22-1build1 Β· TU-Berlin-2.0
- ubuntu questing: libgsm1-dev 1.0.22-1build1
- ubuntu resolute: libgsm1-dev 1.0.23-2 Β· TU-Berlin-2.0
- ubuntu stonking: libgsm1-dev 1.0.24-1 Β· TU-Berlin-2.0
- Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms