audio_gain(3)

πŸ“¦
version 0.7.1 Β· 2 versions
, in nixos 26.05

🌸 NAME 🌸

okay bestie, welcome to audio_gain(3) from the Arcan Lua API πŸ’– this one is all about retrieving and/or updating the audio gain for a specific audio object. that’s the whole vibe: get it, set it, live ur truth ✨

πŸ¦‹ SYNOPSIS πŸ¦‹

the synopsis is literally this, no edits:

aid_gain
audio_gain( aid, gain, time )

πŸŽ€ DESCRIPTION πŸŽ€

so every audio object has its own separate gain property, clamped to the 0..1 range, and it’s set to 1.0 by default when an object is loaded or created πŸ‘‘.

the optional gain argument will update that for a specific audio source. the optional time argument applies a fade from the old gain to the new one β€” the interpolation function used is implementation defined, so don’t come for me about the curve, okay? 😌

πŸ“ NOTES πŸ“

  • 1 β€” β€œAny value outside the particular range will be clamped.” that’s the rule, bestie 🫢
  • 2 β€” β€œAID 0 is reserved for changing the default gain for new sources.”
  • 3 β€” the page says: β€œFor the cases where the engine is responsible for pushing the audio” β€” and that’s literally where the note ends, bestie 😭 keeping it real.
  • 4 β€” β€œThe gain value returned is the target gain, with a pending transformation, this state may not have been reached yet.” then it goes on with this exact bit:
β€œto the target device, even a gain of 0.0 will generate data due to some buffering restrictions with underlying API s.”

yes, API s with a space, i did not invent that πŸ’€

  • 5 β€” β€œThere's a logarithmic distribution applied internally to better mimic the linear appearance used in other sound interfaces.”

✨ EXAMPLE ✨

here’s the example, looking cute and doing normal gain things:

       function audio_gain0()
             local asrc = load_asample("sample.wav");
             audio_gain(asrc, 0.0, 100);
             play_audio(asrc);
       end

πŸ’€ MISUSE πŸ’€

and here’s the misuse example β€” do not be this girlie, okay? note 1 is right there reminding us that out-of-range values get clamped, but still, read the room πŸ™ˆ:

       function audio_gain0()
             local asrc = load_asample("sample.wav");
             audio_gain(asrc, -1.0, -1);
             play_audio(asrc);
       end

xoxo, source/version audio, dated October 2026 β€” audio_gain(3) signing off πŸŽ€πŸ’…

πŸ“¦ where this page comes from