Popcorning Guinea Pig
Search Results for

    Show / Hide Table of Contents

    Class SoundPlayer

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

    Constructors

    | Edit this page View Source

    SoundPlayer(float)

    Declaration
    public SoundPlayer(float volume = 100)
    Parameters
    Type Name Description
    float volume
    | Edit this page View Source

    SoundPlayer(string, float)

    Declaration
    public SoundPlayer(string playlist, float volume = 100)
    Parameters
    Type Name Description
    string playlist
    float volume

    Fields

    | Edit this page View Source

    currentlyPlayingMusic

    Declaration
    protected FileSource? currentlyPlayingMusic
    Field Value
    Type Description
    FileSource
    | Edit this page View Source

    embeddedResourceAssembly

    Declaration
    protected Assembly? embeddedResourceAssembly
    Field Value
    Type Description
    Assembly
    | Edit this page View Source

    gameMusic

    Declaration
    protected List<string> gameMusic
    Field Value
    Type Description
    List<string>
    | Edit this page View Source

    gameMusicCancellationTokenSource

    Declaration
    protected CancellationTokenSource? gameMusicCancellationTokenSource
    Field Value
    Type Description
    CancellationTokenSource
    | Edit this page View Source

    musicTracks

    Declaration
    protected Dictionary<string, FileSource> musicTracks
    Field Value
    Type Description
    Dictionary<string, FileSource>
    | Edit this page View Source

    playlist

    Declaration
    protected string playlist
    Field Value
    Type Description
    string
    | Edit this page View Source

    sfxGain

    Declaration
    protected float sfxGain
    Field Value
    Type Description
    float
    | Edit this page View Source

    soundEffects

    Declaration
    protected Dictionary<string, IAudioSource> soundEffects
    Field Value
    Type Description
    Dictionary<string, IAudioSource>
    | Edit this page View Source

    volume

    Declaration
    protected float volume
    Field Value
    Type Description
    float

    Methods

    | Edit this page View Source

    ApplyMix(float, float, float)

    Master × music / master × sfx, each 0..1. Updates the playing music stream immediately. One-shots pick up the sfx gain on the next PlaySound.

    Declaration
    public virtual void ApplyMix(float master, float sound, float music)
    Parameters
    Type Name Description
    float master
    float sound
    float music
    | Edit this page View Source

    ClearEmbeddedResourceAssembly()

    Clears the embedded resource assembly so audio paths resolve via VFS/file system again.

    Declaration
    public void ClearEmbeddedResourceAssembly()
    | 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

    GetSoundSource(string)

    Gets the source for a loaded sound effect, or null if not loaded. Useful for controlling volume on a playing sound (e.g., fade-out).

    Declaration
    public IAudioSource? GetSoundSource(string soundPath)
    Parameters
    Type Name Description
    string soundPath
    Returns
    Type Description
    IAudioSource
    | Edit this page View Source

    LoadMusicIfNeeded(string)

    Declaration
    protected void LoadMusicIfNeeded(string musicPath)
    Parameters
    Type Name Description
    string musicPath
    | Edit this page View Source

    LoadPlaylists()

    Declaration
    protected virtual void LoadPlaylists()
    | Edit this page View Source

    LoadSoundIfNeeded(string)

    Declaration
    protected void LoadSoundIfNeeded(string soundPath)
    Parameters
    Type Name Description
    string soundPath
    | Edit this page View Source

    PlayGameBackgroundMusic(CancellationToken)

    Declaration
    protected Task PlayGameBackgroundMusic(CancellationToken cancellationToken)
    Parameters
    Type Name Description
    CancellationToken cancellationToken
    Returns
    Type Description
    Task
    | Edit this page View Source

    PlayMusic(string)

    Plays a music track and tracks it as current.

    Declaration
    protected void PlayMusic(string musicPath)
    Parameters
    Type Name Description
    string musicPath
    | Edit this page View Source

    PlaySound(string, float)

    Declaration
    public Task PlaySound(string soundPath, float volume = 1)
    Parameters
    Type Name Description
    string soundPath
    float volume
    Returns
    Type Description
    Task
    | Edit this page View Source

    ReleaseSound(string)

    Take one sound effect out of the mixer. The decoded clip stays cached, so the next play does not decode it again. Scenes call this when a looping bed ends.

    Declaration
    public void ReleaseSound(string soundPath)
    Parameters
    Type Name Description
    string soundPath
    | Edit this page View Source

    ResolveAudioPath(string)

    Resolves an audio path. If embedded resource assembly is set, extracts the resource to a temp file. Otherwise, returns the path as-is for file-based loading.

    Declaration
    protected string ResolveAudioPath(string audioPath)
    Parameters
    Type Name Description
    string audioPath
    Returns
    Type Description
    string
    | Edit this page View Source

    SetEmbeddedResourceAssembly(Assembly)

    Sets the assembly to use for loading embedded audio resources. When set, sound/music paths will be treated as embedded resource names and extracted to temp files.

    Declaration
    public void SetEmbeddedResourceAssembly(Assembly assembly)
    Parameters
    Type Name Description
    Assembly assembly

    The assembly containing embedded audio resources

    | Edit this page View Source

    StartGameBackgroundMusic()

    Declaration
    public Task StartGameBackgroundMusic()
    Returns
    Type Description
    Task
    | Edit this page View Source

    StopCurrentMusic()

    Stops the currently playing music.

    Declaration
    protected void StopCurrentMusic()
    | Edit this page View Source

    StopGameBackgroundMusic()

    Declaration
    public Task StopGameBackgroundMusic()
    Returns
    Type Description
    Task
    | Edit this page View Source

    Update()

    OwnAudioSharp manages its own audio thread — no frame-coupled updates needed. Method retained for ISoundPlayer interface compatibility.

    Declaration
    public virtual void Update()
    | Edit this page View Source

    UpdateSettings(string, float)

    Declaration
    public Task UpdateSettings(string playlist, float volume = 100)
    Parameters
    Type Name Description
    string playlist
    float volume
    Returns
    Type Description
    Task

    Implements

    ISoundPlayer
    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.