read_sound_input(3)

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

πŸ’– read_sound_input β€” the "gimme the tape" function πŸ’–

okay so this is a page from the Allegro manual, aka the Allegro game programming library β€” and bestie, this one's all about grabbing the audio you just recorded. πŸŽ™οΈβœ¨


✨ SYNOPSIS ✨

#include <allegro.h>

int read_sound_input(void *buffer);

πŸŽ€ DESCRIPTION πŸŽ€

So here's the tea: read_sound_input() retrieves the most recently recorded audio buffer and drops it into the location you point at with buffer. That's it, that's the job. πŸ’…

Wanna know how big that buffer actually is? Check the return value from start_sound_input() β€” it tells you. iykyk. 🫢

Now the part that lowkey matters most: you MUST call this function at regular intervals while you're recording. Like, typically around 100 times a second. If you don't? Some data will be lost. fr fr, it just evaporates. 😭

And if your mainline code literally cannot keep up with that pace (no shame, it happens), the move is to use the digi_recorder() callback instead β€” that lets you stash the waveform into a bigger buffer of your very own. main character problem-solving energy. πŸ‘‘

⚠️ Note, bestie: many cards produce a click or popping sound when switching between record and playback modes. So it's often a good idea to discard the first buffer after you start a recording. Toss it. Don't even look at it. πŸ—‘οΈβœ¨

Oh and also β€” the waveform is always stored in unsigned format, with stereo data consisting of alternate left/right samples. So like, L, R, L, R, L, R… you get it. πŸ¦‹


⭐ RETURN VALUE ⭐

  • non-zero β†’ a buffer has been copied, slay, you got data πŸ’–
  • zero β†’ no new data is available yet β€” you were too fast checking the input, bestie, chill for a sec 😭

🌈 SEE ALSO 🌈

  • start_sound_input(3) β€” the one that kicks the whole recording thing off in the first place πŸŽ€

and that's the whole page, no cap. this icon of a manpage is from Allegro, version 4.4.3 β€” mwah, obsessed, periodt. πŸ’œπŸ¦‹βœ¨

πŸ“¦ where this page comes from