audio_gain(3)
πΈ 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
- nixos 26.05: arcan 0.7.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms