Popcorning Guinea Pig
Search Results for

    Show / Hide Table of Contents

    Class AudioEngine

    Singleton that owns the OwnAudioSharp lifecycle and the single AudioMixer. All audio playback goes through this one instance.

    Inheritance
    object
    AudioEngine
    Implements
    IDisposable
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: PopcorningGuineaPig.Engine.Services
    Assembly: PopcorningGuineaPig.Engine.dll
    Syntax
    public sealed class AudioEngine : IDisposable

    Fields

    | Edit this page View Source

    BufferFrames

    Frames per mixer quantum. Matches CreateDefaultConfig().BufferSize.

    Declaration
    public const int BufferFrames = 512
    Field Value
    Type Description
    int
    | Edit this page View Source

    Channels

    Declaration
    public const int Channels = 2
    Field Value
    Type Description
    int
    | Edit this page View Source

    DefaultDeviceLabel

    UI label for the system-default output row.

    Declaration
    public const string DefaultDeviceLabel = "Default"
    Field Value
    Type Description
    string
    | Edit this page View Source

    SampleRate

    Mixer format. Matches OwnaudioNet.CreateDefaultConfig().

    Declaration
    public const int SampleRate = 48000
    Field Value
    Type Description
    int

    Properties

    | Edit this page View Source

    Instance

    Declaration
    public static AudioEngine Instance { get; }
    Property Value
    Type Description
    AudioEngine
    | Edit this page View Source

    IsInitialized

    Declaration
    public bool IsInitialized { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    Mixer

    Declaration
    public AudioMixer? Mixer { get; }
    Property Value
    Type Description
    AudioMixer

    Methods

    | Edit this page View Source

    Dispose()

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

    Declaration
    public void Dispose()
    | Edit this page View Source

    ListOutputDeviceNames()

    Friendly names only — prefer ListOutputDevices() for settings UI.

    Declaration
    public static IReadOnlyList<string> ListOutputDeviceNames()
    Returns
    Type Description
    IReadOnlyList<string>
    | Edit this page View Source

    ListOutputDevices()

    Active output devices for a settings dropdown. Does not include the synthetic DefaultDeviceLabel row — callers prepend that themselves. OwnAudioSharp.Basic 4.0.8 lists these from the running engine (OwnaudioNet.GetOutputDevices), so this is empty until Instance has started. Names are full endpoint strings.

    Declaration
    public static IReadOnlyList<AudioOutputDeviceOption> ListOutputDevices()
    Returns
    Type Description
    IReadOnlyList<AudioOutputDeviceOption>
    | Edit this page View Source

    LoadSoundEffect(string)

    Loads a short clip as a fully in-memory OwnaudioNET.Sources.SampleSource.

    OwnaudioNET.Sources.FileSource streams, and its Play() spins a fixed ~500-iteration sleep loop filling the decode pre-buffer before the first sample reaches the mixer. That costs ~800 ms at 1 ms timer resolution and ~7.8 s at Windows' default 15.6 ms tick — measured, not estimated — and no constructor argument tunes it away. Fine for music, which starts once and off-screen; fatal for a click or a piece landing. SampleSource has no pre-buffer: Play() returns immediately and audio lands within one mixer buffer (~10 ms).

    Clips longer than PopcorningGuineaPig.Engine.Services.AudioEngine.MaxSfxDuration, and files whose duration the decoder cannot report, fall back to a streaming FileSource — late audio beats no audio.
    Declaration
    public static IAudioSource LoadSoundEffect(string path)
    Parameters
    Type Name Description
    string path
    Returns
    Type Description
    IAudioSource
    | Edit this page View Source

    SetOutputDevice(string?)

    Opens (or re-opens) the mixer on deviceKey. Accepts DefaultDeviceLabel, blank, a DeviceId, or a friendly Name (legacy settings). Unknown keys fall back to the system default.

    Declaration
    public void SetOutputDevice(string? deviceKey)
    Parameters
    Type Name Description
    string deviceKey

    Events

    | Edit this page View Source

    Reset

    Fired after a new mixer is running on the selected device.

    Declaration
    public static event Action? Reset
    Event Type
    Type Description
    Action
    | Edit this page View Source

    Resetting

    Fired before the native engine is torn down to switch output devices.

    Declaration
    public static event Action? Resetting
    Event Type
    Type Description
    Action

    Implements

    IDisposable
    • Edit this page
    • View Source
    In this article
    Back to top © 2024 Popcorning Guinea Pig Game Engine. A custom C# game engine for indie developers.