Skip to main content

toggle_effect

Function toggle_effect 

Source
pub fn toggle_effect(
    audio_service: State<'_, Mutex<AudioService>>,
    persistence_service: State<'_, Mutex<AmpConfigPersistenceService>>,
    effect_id: u32,
) -> Result<bool, String>
Expand description

Toggles an effect’s active state on the current channel. Enables or disables audio processing for a specific effect. The change takes effect on the very next audio sample — no loopback restart needed.

This is a generic command that works with any effect type.

§Arguments

  • effect_id — Unique ID of the effect to toggle

§Returns

  • Ok(bool) — The new active state (true = processing, false = bypassed)
  • Err(String) — Error message if effect ID is invalid or channel not found

§Implementation Details

  • Updates the effect’s [Arc<AtomicBool>] active flag
  • Changes apply immediately to audio processing thread