al_create_audio_recorder(3alleg5)
β¨ al_create_audio_recorder β Allegro 5 API β¨
okay bestie, buckle up, we're building an audio recorder π this page lives in the Allegro 5 manual and it's literally all about catching sound from your mic, so let's go π
πΈ SYNOPSIS πΈ
#include <allegro5/allegro_audio.h>
ALLEGRO_AUDIO_RECORDER *al_create_audio_recorder(size_t fragment_count,
unsigned int samples, unsigned int frequency,
ALLEGRO_AUDIO_DEPTH depth, ALLEGRO_CHANNEL_CONF chan_conf)
π¦ DESCRIPTION π¦
So basically, this function creates an audio recorder using the system's default recording device. π
Heads up though: if the device it hands you back does not work, the move is to go update the system's default recording device. no cap.
Allegro will internally buffer several seconds of captured audio with minimal latency. (XXX: These settings need to be exposed via config or API calls. π yeah, they know.) Audio will be copied out of that private buffer into a fragment buffer of the size specified by the samples parameter. Whenever a new fragment is ready, an event will be generated. π
The total size of the fragment buffer is fragment_count * samples * bytes_per_sample. It is treated as a circular, never ending buffer. Which means β and this is the part where you need to pay attention bestie β if you do not process the information fast enough, it will be overrun. π Because of that, even if you only ever need to process one small fragment at a time, you should still use a large enough value for fragment_count to hold a few seconds of audio. protect your buffer, protect your peace π«Ά
frequency is the number of samples per second to record. Common values are:
8000β telephone quality speech π110252205044100β CD quality music (if 16-bit, stereo) πΆ
For maximum compatibility, use a depth of ALLEGRO_AUDIO_DEPTH_UINT8 or ALLEGRO_AUDIO_DEPTH_INT16, and a single (mono) channel. simple, iconic, works everywhere β¨
Also, the recorder will not record until you start it with al_start_audio_recorder(3alleg5). so don't be out here wondering why it's silent, she's just waiting for her cue π
On failure, returns NULL. π
β SINCE β
5.1.1
[Unstable API]: The API may need a slight redesign. π yeah, she's a work in progress and that's valid, just know it going in.
and that's the whole page, bestie!! mwah π
this has been the Allegro reference manual β page al_create_audio_recorder(3alleg5) β signing off. stay hydrated, keep your fragment_count chunky, and go record something iconic ππ
π¦ where this page comes from
- debian trixie: allegro5-doc 2:5.2.10.1+dfsg-1 Β· Zlib
- ubuntu questing: allegro5-doc 2:5.2.10.1+dfsg-1build1
- ubuntu resolute: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- ubuntu stonking: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms