al_create_audio_recorder(3alleg5)

πŸ“¦
version 5.2.11.3 Β· 4 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ 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 πŸ“ž
  • 11025
  • 22050
  • 44100 β€” 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