Handle stateful audio effects when a bus channel becomes inactive

Aperta
#1,584 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@GeneralProtectionFault ci sta già lavorando.

Dal 5/11/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

Summary

Investigate how the audio server handles stateful effects when a bus channel becomes inactive. Effect state can stop advancing during inactivity, so pending audio or stale state can affect later playback. This is a shared audio-server concern, not limited to the new noise gate.

Context

In servers/audio/audio_server.cpp, an unused channel becomes inactive after its output stays below the disable threshold for the configured time. The default audio/buses/channel_disable_time is 2 seconds. When a channel is inactive, the server skips an effect unless its instance returns true from process_silence().

AudioEffectInstance::process_silence() defaults to false. Inactive channel buffers are not cleared by the active-but-unused clearing path. Also, the send path skips inactive channels. Therefore, overriding process_silence() alone does not guarantee that an effect receives silence or that its output is delivered.

Existing-effect example: AudioEffectDelay

AudioEffectDelayInstance in servers/audio/effects/audio_effect_delay.cpp and .h does not override process_silence(). It advances its ring-buffer position and feedback state only when process() runs. If a channel becomes inactive before a delayed tap is due, its pending samples can remain in the delay buffer until later audio reactivates the channel.

Suggested reproduction to validate (derived from source inspection; not yet runtime-tested):

  1. Set audio/buses/channel_disable_time to 0.05 seconds and restart if needed.
  2. Add AudioEffectDelay to a bus. Set dry to 1, enable tap 1 with a 1000 ms delay and 0 dB level, disable tap 2 and feedback.
  3. Play a brief, distinct sound through that bus, then stop all input and wait several seconds.
  4. Play a different continuous sound through the same bus for at least two seconds.

The first sound's pending echo may not occur at the expected time and may instead appear during the second sound, because the delay buffer stopped advancing during inactivity.

Required work and acceptance criteria

  • Define and implement safe inactive-channel behavior for stateful effects and their output. Consider effect tails, reactivation, and real-time audio constraints.
  • Ensure effects that process silence receive actual silence rather than stale channel-buffer contents. Do not rely on process_silence() alone.
  • Add regression coverage for a delay tap longer than the channel-disable time. Check both the idle period and subsequent reactivation.
  • Cover stateful envelope/gain behavior on reactivation and check that existing silence-processing effects, such as capture and record, continue to work as intended.

Reported during review of PR https://github.com/Redot-Engine/redot-engine/pull/1582, comment https://github.com/Redot-Engine/redot-engine/pull/1582#discussion_r4484552108. Requested by @GeneralProtectionFault.

Lingua principale
C++
Stelle
6.1k
Fork
337
Merge medio
5g 8h
PR unite (30g)
13

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Redot-Engine/redot-engine

Tutte le issue di Redot-Engine/redot-engine

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.