logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnitySoundMixerService

    Unity-specific implementation of the sound mixer service interface.
    Manages Unity AudioMixer operations including parameter control, volume mapping, and event-driven updates.
    Provides abstraction layer between domain logic and Unity's audio mixing system.

    Inheritance
    object
    UnitySoundMixerService
    Implements
    ISoundMixerService
    IService
    IFoundationSettings
    Namespace: Serenity.SoundMixer.Infrastructure.Services
    Assembly: Serenity.UnitySoundMixer.Infrastructure.dll
    Syntax
    public class UnitySoundMixerService : MonoBehaviour, ISoundMixerService, IService, IFoundationSettings

    Constructors

    UnitySoundMixerService()

    Declaration
    public UnitySoundMixerService()

    Properties

    Guid

    Gets or sets the global unique identifier for this service instance.

    Declaration
    public string Guid { get; set; }
    Property Value
    Type Description
    string

    The global unique identifier string.

    Id

    Gets or sets the unique identifier for this service instance.

    Declaration
    public string Id { get; set; }
    Property Value
    Type Description
    string

    The unique identifier string.

    LogService

    Declaration
    public ILogService LogService { get; set; }
    Property Value
    Type Description
    ILogService

    Methods

    ApplyEffectLoop(SoundMixerApplyEffectLoopInput)

    Applies a registered effect loop to a source group/channel using the actual AudioMixer routing elements (no invented wet/dry parameters):

    • the source group's Attenuation = dry/original path, driven by normalized Dry (via Serenity.SoundMixer.Infrastructure.Services.UnitySoundMixerService.MapVolume(System.Int32));
    • the source group's Send = wet/effect path; at full wet it tracks the source group's CURRENT level (so the processed path matches the source's loudness, not the mixer's max), attenuating below that for lower wet;
    • the loop's output Attenuation (from the definition) = unity (0 dB) pass-through, since the Send already sets the wet level.

    Dry uses the existing Serenity.SoundMixer.Infrastructure.Services.UnitySoundMixerService.MapVolume(System.Int32) conversion; the Send offset for wet < 1 also uses it. Captures previous values (when readable) for restore on clear, and fails gracefully with a clear log if the mixer is unusable or the loop id is unknown.

    Declaration
    public void ApplyEffectLoop(SoundMixerApplyEffectLoopInput input)
    Parameters
    Type Name Description
    SoundMixerApplyEffectLoopInput input

    The apply request.

    ClearEffectLoop(SoundMixerClearEffectLoopInput)

    Clears a previously applied effect loop from a source group/channel, restoring captured previous values when requested. Fails gracefully if there is no active loop for the given id/source.

    Declaration
    public void ClearEffectLoop(SoundMixerClearEffectLoopInput input)
    Parameters
    Type Name Description
    SoundMixerClearEffectLoopInput input

    The clear request.

    GetAudioMixer()

    Gets the Unity AudioMixer instance managed by this service.
    Provides direct access to the underlying Unity audio mixer for advanced operations.

    Declaration
    public AudioMixer GetAudioMixer()
    Returns
    Type Description
    AudioMixer

    The Unity AudioMixer instance

    GetSoundMixerParameters()

    Gets the currently configured sound mixer parameters.
    Returns the list of mixer parameters that this service can control.

    Declaration
    public List<ConfigurationEntry> GetSoundMixerParameters()
    Returns
    Type Description
    List<ConfigurationEntry>

    List of key-value pairs representing available mixer parameters

    GetVolume(SoundMixerGetVolumeInput)

    Gets the current volume for a specific audio mixer parameter.
    Retrieves the raw volume value from the Unity AudioMixer.

    Declaration
    public float GetVolume(SoundMixerGetVolumeInput input)
    Parameters
    Type Name Description
    SoundMixerGetVolumeInput input

    DTO containing the parameter ID to query

    Returns
    Type Description
    float

    The current volume value from the audio mixer

    InitializeEventDispatcher(IEventDispatcherService)

    Initializes the event dispatcher service and subscribes to relevant events.
    Establishes the connection to the event system for handling audio mixer updates.

    Declaration
    public void InitializeEventDispatcher(IEventDispatcherService eventDispatcherService)
    Parameters
    Type Name Description
    IEventDispatcherService eventDispatcherService

    The event dispatcher service to use for event handling

    InitializeService(ISoundMixerSettings)

    Initializes the service with sound mixer settings configuration.
    Configures the audio mixer, volume ranges, and exposed parameters based on the provided settings.

    Declaration
    public void InitializeService(ISoundMixerSettings soundMixerSettings)
    Parameters
    Type Name Description
    ISoundMixerSettings soundMixerSettings

    The sound mixer settings containing configuration data

    SetEventDispatcherService(IEventDispatcherService)

    Sets the event dispatcher service for this mixer service.
    Configures the event dispatcher that will handle audio mixer related events.

    Declaration
    public void SetEventDispatcherService(IEventDispatcherService eventDispatcherService)
    Parameters
    Type Name Description
    IEventDispatcherService eventDispatcherService

    The event dispatcher service to use

    SetSoundMixerParameters(List<ConfigurationEntry>)

    Sets the sound mixer parameters for this service instance.
    Configures the available audio mixer parameters that can be controlled by this service.

    Declaration
    public void SetSoundMixerParameters(List<ConfigurationEntry> soundMixerIds)
    Parameters
    Type Name Description
    List<ConfigurationEntry> soundMixerIds

    List of key-value pairs representing mixer parameter names and their associated identifiers

    SetVolume(SoundMixerSetVolumeInput)

    Sets the volume for a specific audio mixer parameter.
    Applies volume mapping and updates the Unity AudioMixer with the calculated value.

    Declaration
    public void SetVolume(SoundMixerSetVolumeInput input)
    Parameters
    Type Name Description
    SoundMixerSetVolumeInput input

    DTO containing the parameter ID and desired volume level

    SubscribeToEventDispatcherEvents()

    Subscribes to relevant event dispatcher events for handling game settings updates.
    Registers this service to receive notifications when game settings values are updated.

    Declaration
    public void SubscribeToEventDispatcherEvents()

    Implements

    ISoundMixerService
    IService
    IFoundationSettings
    In this article
    © 2026 Serenity. All Rights Reserved