audio-fade-separate-gain-line
Installation
SKILL.md
A fade needs its own gain line
A sleep timer that ends on a bare pause() chops the music off. Ramping to silence first
is a two-line change with three ways to get it wrong. The rule that avoids all three: the
fade gets its own gain line, multiplied with the user's volume at the point the value
reaches the audio path.
interface MediaPlayerInterface {
var volume: Float // the user's level — reported back to the UI
var sleepFadeFactor: Float // 0f..1f, the fade's own line
}
- Android (Media3): a small
AudioProcessorin the chain, one instance per player, all reading the same@Volatilefield:arrayOf(crossfadeFilter, sleepFade). - Desktop: engines commonly expose two levels — a device-mixer level and a software level. Put the fade on one and the crossfade ramp on the other; they then multiply and neither has to know the other exists.