SAMPLE(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

πŸ’– NAME πŸ’–

SAMPLE β€” it stores sound data, bestie. Part of the Allegro game programming library, and it's giving literal audio icon. 🎧✨


✨ SYNOPSIS ✨

#include <allegro.h>

typedef struct SAMPLE

πŸŽ€ DESCRIPTION πŸŽ€

Okay so here's the whole vibe, every field, no skips, no cap:

int bits;                   - 8 or 16
int stereo;                 - sample type flag
int freq;                   - sample frequency
int priority;               - 0-255
unsigned long len;          - length (in samples)
unsigned long loop_start;   - loop start position
unsigned long loop_end;     - loop finish position
void *data;                 - raw sample data

So SAMPLE is a struct β€” a sample structure β€” and it holds sound data, and the digital sample routines are obsessed with it. 🫢

Not me telling you this: you can treat all of these fields as read only... except priority, loop_start and loop_end. Those three? Go off, queen. You can change them β€” for example right after you load a sample from disk. πŸ’…

The priority is a value from 0 to 255 (by default it's set to 128) and it controls how the hardware voices on the sound card get allocated when you try to play more sounds than the driver can actually handle. It's the main character energy of voice management: it makes sure the less important sounds get cut off while the important ones are preserved. πŸŽ€πŸ‘‘

The variables loop_start and loop_end specify the loop position in sample units, and by default they're set to the start and the end of the sample. Periodt. 🌸

And if you're out here creating your own samples on the fly, you might also wanna modify the raw data of the sample that the data field points to. Heads up though β€” the sample data is always in unsigned format. So if you're loading a PCM encoded sound file with signed 16-bit samples, you'd have to XOR every two bytes (i.e. every sample value) with 0x8000 to flip the signedness. Yes literally, every single one. 😭


πŸ¦‹ SEE ALSO πŸ¦‹


Allegro β€” version 4.4.3 🧚

That's the whole page, bestie! Go make some noise, you absolute legend. πŸŒˆπŸ‘‘πŸ’–

πŸ“¦ where this page comes from