Defines an audio fader with fade-in/out operations, for use during playback, including a muted and soloed state. Soloing only works in a multitrack context. This fader supports two concepts:

  • a master volume, that emulates a an overall audio level
  • independent fading, mute and solo operations, which internally control the actually set audio level on the media player.

Remarks

The goal is to free the actual player from fading handling. Using this promise-based approach especially frees the using code from using timers for calling delayed stop or pause operations after a fade operation. Newly attempted fade operations are prevented during already ongoing fade operations. The ongoing fade operation is however cancelled (and subsequently fades to min). Fading is only actually executed for non-zero fading durations. For zero fading durations, the call immediately returns with a resolved promise, without any call to a fade operation. This can be used as a convenient way to skip fadings. NOTE: Visual fading indication like progress bars or brightness changes must be implemented elsewhere, but can use the provided onFadingChanged event.

interface IAudioFader {
    onFadingChanged: SubEventImmediate<FadingMode>;
    onMutedChanged: SubEventImmediate<boolean>;
    onSoloedChanged: SubEventImmediate<boolean>;
    onVolumeChanged: SubEventImmediate<number>;
    get addFadeInPreRoll(): boolean;
    anySoloed: boolean;
    get fadeInDuration(): number;
    get fadeOutDuration(): number;
    get fading(): boolean;
    isFadingEnabled: boolean;
    muted: boolean;
    soloed: boolean;
    cancel(): void;
    destroy(): void;
    fadeIn(immediate?): Promise<void>;
    fadeOut(immediate?): Promise<void>;
    reset(): void;
    setVolume(volume): number;
    updateSettings(fadeInDuration, fadeOutDuration, addFadeInPreRoll): void;
    volumeDown(): number;
    volumeUp(): number;
}

Implemented by

Properties

onFadingChanged: SubEventImmediate<FadingMode>

Emits a changed fading state.

Param: fading

kind of fading operation that is currently ongoing

onMutedChanged: SubEventImmediate<boolean>

Emits a changed muted state.

Param: muted

the changed muted state

onSoloedChanged: SubEventImmediate<boolean>

Emits a changed soloed state.

Param: soloed

the changed soloed state

onVolumeChanged: SubEventImmediate<number>

Emits a changed master volume state.

Param: volume

the changed master volume

Accessors

  • get addFadeInPreRoll(): boolean
  • Whether to apply an additional seek offset before fade-in operations, to compensate the fading duration.

    Returns boolean

  • get anySoloed(): boolean
  • Gets the overall solo state in a multitrack context.

    Returns boolean

    Remarks

    When any is soloed, but not this track, this is effectively muted.

  • set anySoloed(value): void
  • Sets the overall solo state in a multitrack context.

    Parameters

    • value: boolean

    Returns void

    Remarks

    When any is soloed, but not this track, this is effectively muted.

  • get isFadingEnabled(): boolean
  • Gets whether fading is currently enabled.

    Returns boolean

    Remarks

    Fading is expected to be enabled by default.

  • set isFadingEnabled(enabled): void
  • Sets whether fading is currently enabled.

    Parameters

    • enabled: boolean

    Returns void

    Remarks

    Fading is generally enabled by default, but may get disabled generally or on some events

Methods

  • Returns a fade-in promise for the currently playing track

    Parameters

    • Optional immediate: boolean

      When set to true, the fade operation is done with duration zero.

    Returns Promise<void>

    Remarks

    The sound is faded to the master volume audio level. A pre-fade offset is applied, when configured An actual fade operation is only started when

    • the set duration is non-zero and
    • no previous fade operation is ongoing
    • the immediate parameter is not set to true otherwise
    • a fade with duration zero is started and the promise is immediately resolved.
  • Returns a fade-out promise for the currently playing track

    Parameters

    • Optional immediate: boolean

      When set to true, the fade operation is done with duration zero.

    Returns Promise<void>

    Remarks

    The sound is faded to the minimum audio level. An actual fade operation is only started when

    • the set duration is non-zero and
    • no previous fade operation is ongoing
    • the immediate parameter is not set to true otherwise
    • a fade with duration zero is started and the promise is immediately resolved.
  • Sets the master audio volume.

    Parameters

    • volume: number

      A value between 0 (zero, will get limited to the minimum level) and 1 (representing full scale)

    Returns number

    The new, possibly limited, master audio volume

    Remarks

    The new value is only applied if it actually changes, after limitation. The 'onMasterVolumeChange' is also only emitted on actual changes.

    • A changed value is applied immediately, without any fading, with the possible muted state observed
    • Limits the minimum level at -90dB Full Scale
  • Updates the current settings.

    Parameters

    • fadeInDuration: number

      The fade-in duration. Default is 1000 (1 second)

    • fadeOutDuration: number

      The fade-out duration. Default is 500 (500 milliseconds)

    • addFadeInPreRoll: boolean

      Whether to apply an additional seek offset before fade-in operations, to compensate the fading duration. (Default: true)

    Returns void

    Remarks

    The settings will be used for the next fade. However, when the new duration is zero (no fade), the cancel operation is immediately called, resetting the volume to the initial value for this case.

  • Decreases the master audio volume level by rougly 3dB

    Returns number

    The new, possibly limited, master audio volume

    Remarks

    Applies some limitation on the upper and lower end of the range

  • Increases the master audio volume level by rougly 3dB

    Returns number

    The new, possibly limited, master audio volume

    Remarks

    Applies some limitation on the upper and lower end of the range