al_set_sample...channel_matrix(3alleg5)

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

✨ NAME ✨

al_set_sample_instance_channel_matrix β€” ok so this is the Allegro 5 API function that lets you hand-write the whole mixing matrix yourself instead of letting Allegro guess πŸ’… (and yes bestie, this page lives in section 3alleg5)


🌸 SYNOPSIS 🌸

#include <allegro5/allegro_audio.h>

bool al_set_sample_instance_channel_matrix(ALLEGRO_SAMPLE_INSTANCE *spl, const float *matrix)

πŸŽ€ DESCRIPTION πŸŽ€

So here's the tea, bestie πŸ«– β€” this function sets the matrix used to mix the channels coming from this instance into the mixer it's attached to.

Normally Allegro just derives those matrix values all by itself from the gain and pan settings, plus the channel configurations of this instance and the mixer it's attached to. Cute, right? But this function lets you override that default value. Main character energy: you take the wheel πŸš—βœ¨

⚠️ But listen β€” if you do set gain or pan of this instance, or of the mixer it's attached to, you'll need to call this function again. No cap. Your custom matrix does not survive that, so don't come crying to me 😭

Now, the layout, because this part actually matters πŸ‘‘

  • The matrix has mixer channel rows and sample channel columns, and it's row major.
  • So like, if you've got a stereo sample instance and you wanna mix it into a 5.1 mixer, you'd do this:
float matrix[] = {
    0.5, 0.0, /* Half left to front left */
    0.0, 0.5, /* Half right to front right */
    0.5, 0.0, /* Half left to rear left */
    0.0, 0.5, /* Half right to rear right */
    0.1, 0.1, /* Mix left and right for center */
    0.1, 0.1, /* Mix left and right for center */
};

al_set_sample_instance_channel_matrix(instance, matrix);

Iconic. Ate. πŸ’–

And the return value, since you were gonna ask:

  • Returns true on success πŸŽ‰
  • Returns false on failure β€” like, for example, if this is not attached to a mixer πŸ’€

πŸ¦‹ SINCE πŸ¦‹

5.2.3

🚨 [Unstable API]: New API. She's fresh, she's shiny, she's literally new β€” treat her accordingly πŸ™ˆ

That's the whole vibe, bestie β€” go mix something gorgeous πŸŒˆπŸ’œ

Source and version vibes: this one's straight outta the Allegro reference manual, page al_set_sample...channel_matrix(3alleg5). Mwah, bye πŸŽ€βœ¨

πŸ“¦ where this page comes from