Skip to content

Audio & Sidechain Ducking (ducking)

The ducking package allows you to automatically attenuate background music or sound effects whenever dialogue or voiceover is present.

Quick Example

go
import "github.com/farshidrezaei/vidonex/ducking"

options := ducking.Options{
    ThresholdDB: -25.0, // Trigger ducking when voice reaches -25dB
    Ratio:       4.0,   // Compression ratio
    AttackMS:    20.0,  // Fast attack to instantly dip music
    ReleaseMS:   400.0, // Smooth recovery fade back
}

// Connect background audio pad and speech lead pad
err := ducking.ApplySidechainDucking(graph, musicPad, voicePad, options)

Options Reference

ParameterTypeDefaultDescription
ThresholdDBfloat64-20.0Decibel volume at which ducking activates
Ratiofloat644.0Compression factor applied to background audio
AttackMSfloat6420.0Time in ms to lower volume once voice begins
ReleaseMSfloat64300.0Time in ms to restore volume once voice stops
MakeupGainfloat641.0Post-compression gain multiplier

Released under the MIT License.