DuckOptions
Added in 6.5.0
DuckOptions is the object you pass as the second argument to duck. Only when is required.
export interface DuckOptions {
/** The sound, group or stream whose playing turns the target down. One name or several. */
when: string | string[];
/** The level the target drops to, from 0 (silent) to 1 (no change). Default: 0.3. */
amount?: number;
/** Seconds to go down once a trigger starts. Default: 0.05. */
attack?: number;
/** Seconds to come back up after the last trigger stops. Default: 0.5. */
release?: number;
}
| Property | Type | Default | Description |
|---|---|---|---|
when | string | string[] | required | The triggers. Each name can be a sound id, the id of a sound with overlapping instances, a sprite's sound, a group, a stream or a variation name. An empty list throws. |
amount | number | 0.3 | The level the target drops to. 0 silences it, 1 leaves it as it is. Clamped to that range. |
attack | number | 0.05 | Seconds for the ramp down. 0 jumps. |
release | number | 0.5 | Seconds for the ramp back up after the last trigger stops. 0 jumps. |
DuckOptions is exported from soundhub as a type.
Example
import { SoundHub, type DuckOptions } from 'soundhub';
const underVoice: DuckOptions = {
when: ['voice', 'dialogue'],
amount: 0.2,
attack: 0.1,
release: 1.2,
};
soundHub.duck('music', underVoice);
Picking the times
- A short
attack, 30 to 100 ms, gets the music out of the way before the first word. - A longer
release, half a second or more, keeps the music from jumping back between two lines that follow each other. - An
amountof 0.2 to 0.4 keeps the music audible under speech. Use0to cut it out completely.