GSM(3)
πΈ GSM(3) β the library functions manual, but make it cute πΈ
okay bestie, sit down, hydrate, and let me tell you about GSM(3) β a whole manual page living in the Library Functions Manual section. it's giving "vintage codec lore" and honestly? we're obsessed. π
β¨ NAME β¨
gsm_create, gsm_destroy, gsm_encode, gsm_decode β GSM 06.10 lossy sound compression. that's the whole vibe. compression, but make it speech. π£οΈπ
β¨ 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;
look at these little K&R-style signatures, they're so retro. no cap. π¦
β¨ DESCRIPTION β¨
okay so Gsm is a whole implementation of the final draft GSM 06.10 standard for full-rate speech transcoding. yes, that's a real sentence. yes, it's iconic. β¨
gsm_create()β initializes a gsm pass and hands you back a'gsm'object. that object is your β¨handleβ¨, and you'll be passing it togsm_decode(),gsm_encode()orgsm_destroy()later. main character object, fr fr.gsm_encode()β takes an array of 160 13-bit samples (given asgsm_signal's, which are signed integral values of at least 16 bits) and squishes them down into agsm_frameof 33 bytes. and btw,gsm_frameis a type defined ingsm.has an array of 33gsm_bytes. πgsm_decode()β the reverse bestie. decodes agsm_frameback into an array of 160 13-bit samples (given asgsm_signals). and honestly? they sound rather like what you handed togsm_encode()on the other side of the wire. π lowkey magic.gsm_destroy()β finishes a gsm pass and frees all storage associated with it. say goodbye, clean up your mess, we love a responsible queen. π«Ά
π Sample format π
here's the scaling that's assumed for input to the algorithm:
0 1 11 12
S..v..v..v..v..v..v..v..v..v..v..v..v..*..*..*
so the tea is: only the top 13 bits get used as a signed input value. β
and the output of gsm_decode() has the three lower bits set to zero. noted. not negotiable. π
β¨ RETURN VALUE β¨
gsm_create()returns an opaque handle object of typegsm, or0on error. so like, check it. please. πgsm_decode()returns-1if the frame you passed is invalid, else0. simple as that. π
β¨ EXAMPLE β¨
here's the whole thing in action, bestie β read it slow, it's actually so satisfying:
#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);
}
play() and record() are literally the duo of the century. one reads compressed data from standard input and writes to soundfd, the other reads from soundfd and writes compressed to standard output. symmetrical queens. ππ
π BUGS π
found a bug? don't be shy. please direct bug reports to jutta@pobox.com and cabo@tzi.org. they're waiting. be nice. π
β¨ SEE ALSO β¨
go read those too, iykyk. π§
and that's the whole page!! this little GSM(3) manual page is filed under the Library Functions Manual section, and it's signed off at the bottom with GSM(3) β that's the manual, that's the version, that's the whole era. periodt. πβ¨
π¦ where this page comes from
- alpine 3.22: gsm-doc 1.0.22-r3 Β· TU-Berlin-2.0
- alpine 3.23: gsm-doc 1.0.23-r0 Β· TU-Berlin-2.0
- alpine 3.24: gsm-doc 1.0.23-r0 Β· TU-Berlin-2.0
- arch rolling: gsm 1.0.24-1 Β· custom
- centos-stream 10: gsm-devel 1.0.22-8.el10 Β· tu-berlin-2.0
- centos-stream 9: gsm-devel 1.0.19-6.el9 Β· MIT
- centos-stream 9: gsm-devel 1.0.19-6.el9 Β· MIT
- fedora 43: gsm-devel 1.0.23-1.fc43 Β· tu-berlin-2.0
- fedora 43: gsm-devel 1.0.23-1.fc43 Β· tu-berlin-2.0
- fedora 44: gsm-devel 1.0.24-2.fc44 Β· tu-berlin-2.0
- fedora 44: gsm-devel 1.0.24-2.fc44 Β· tu-berlin-2.0
- nixos 26.05: gsm 1.0.24
- nixpkgs unstable: gsm 1.0.24
- opensuse-leap 16.0: libgsm-devel 1.0.22-160000.3.2 Β· ISC
- opensuse-leap 16.0: libgsm-devel 1.0.22-160000.3.2 Β· ISC
- opensuse-leap 16.0: libgsm-devel 1.0.22-160000.3.2 Β· ISC
- opensuse-leap 16.0: libgsm-devel 1.0.22-160000.3.2 Β· ISC
- 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