Stride

OPEN / CLOSE
  • Features
  • Blog
  • Documentation
  • Community
(icon) Download

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

OPEN / CLOSE
  • English
  • 日本語
    Show / Hide Table of Contents

    DynamicSoundSource Class

    Namespace: Stride.Audio
    Assembly: Stride.Audio.dll
    System.Object → DynamicSoundSource
    Derived from DynamicSoundSource: StreamedBufferSoundSource

    public abstract class DynamicSoundSource : IDisposable
    Name Description
    Constructors
    DynamicSoundSource(SoundInstance, Int32, Int32)

    Initializes a new instance of the DynamicSoundSource class. Sub classes can implement their own streaming sources.

    Fields
    Commands

    The commands derived classes should execute.

    deviceBuffers
    freeBuffers
    isDisposed
    isInitialized
    Logger
    NewSources
    playingQueued

    If we are waiting to play.

    soundInstance

    The sound instance associated.

    Sources
    state

    If we are in the paused state.

    Properties
    CanFill

    Checks if a buffer can be filled, before calling FillBuffer this should be checked.

    Ended

    Gets a task that will be fired once there will be no more queueud data.

    IsPausedOrPlaying

    Gets if this instance is in the playing state.

    MaxNumberOfBuffers

    Max number of buffers that are going to be queued.

    PlayRange

    Gets or sets the region of time to play from the audio clip.

    ReadyToPlay

    Gets a task that will be fired once the source is ready to play.

    Methods
    Dispose()

    Enqueues a dispose command, to dispose this instance.

    DisposeInternal()

    Destroys the instance.

    ExtractAndFillData()
    FillBuffer(Byte[], Int32, AudioLayer.BufferType)

    If CanFillis true with this method you can fill the next free buffer

    FillBuffer(Int16[], Int32, AudioLayer.BufferType)

    If CanFillis true with this method you can fill the next free buffer

    FillBuffer(IntPtr, Int32, AudioLayer.BufferType)

    If CanFillis true with this method you can fill the next free buffer

    InitializeInternal()
    Pause()

    Enqueues a Pause command, to Pause this instance.

    PauseInternal()
    Play()

    Enqueues a Play command, to Play this instance.

    PlayInternal()
    PrepareInternal()

    Prepare the source for playback

    RestartInternal()

    Restarts streaming from the beginning.

    SeekInternal()
    SetLooped(Boolean)

    Sets if the stream should be played in loop.

    Stop()

    Enqueues a Stop command, to Stop this instance.

    StopInternal(Boolean)
    UpdateInternal()

    Update the sound source

    | Improve this Doc View Source

    Constructors


    DynamicSoundSource(SoundInstance, Int32, Int32)

    Initializes a new instance of the DynamicSoundSource class. Sub classes can implement their own streaming sources.

    protected DynamicSoundSource(SoundInstance soundInstance, int numberOfBuffers, int maxBufferSizeBytes)
    Parameters
    Type Name Description
    SoundInstance soundInstance

    the sound instance associated.

    System.Int32 numberOfBuffers

    the size of the streaming ring-buffer.

    System.Int32 maxBufferSizeBytes

    the maximum size of each buffer.

    | Improve this Doc View Source

    Fields


    Commands

    The commands derived classes should execute.

    protected readonly ConcurrentQueue<DynamicSoundSource.AsyncCommand> Commands
    Field Value
    Type Description
    System.Collections.Concurrent.ConcurrentQueue<DynamicSoundSource.AsyncCommand>

    deviceBuffers

    protected readonly List<AudioLayer.Buffer> deviceBuffers
    Field Value
    Type Description
    System.Collections.Generic.List<AudioLayer.Buffer>

    freeBuffers

    protected readonly Queue<AudioLayer.Buffer> freeBuffers
    Field Value
    Type Description
    System.Collections.Generic.Queue<AudioLayer.Buffer>

    isDisposed

    protected bool isDisposed
    Field Value
    Type Description
    System.Boolean

    isInitialized

    protected bool isInitialized
    Field Value
    Type Description
    System.Boolean

    Logger

    public static Logger Logger
    Field Value
    Type Description
    Logger

    NewSources

    protected static readonly ConcurrentBag<DynamicSoundSource> NewSources
    Field Value
    Type Description
    System.Collections.Concurrent.ConcurrentBag<DynamicSoundSource>

    playingQueued

    If we are waiting to play.

    protected volatile bool playingQueued
    Field Value
    Type Description
    System.Boolean

    soundInstance

    The sound instance associated.

    protected SoundInstance soundInstance
    Field Value
    Type Description
    SoundInstance

    Sources

    protected static readonly List<DynamicSoundSource> Sources
    Field Value
    Type Description
    System.Collections.Generic.List<DynamicSoundSource>

    state

    If we are in the paused state.

    protected PlayState state
    Field Value
    Type Description
    PlayState
    | Improve this Doc View Source

    Properties


    CanFill

    Checks if a buffer can be filled, before calling FillBuffer this should be checked.

    protected virtual bool CanFill { get; }
    Property Value
    Type Description
    System.Boolean

    Ended

    Gets a task that will be fired once there will be no more queueud data.

    public TaskCompletionSource<bool> Ended { get; }
    Property Value
    Type Description
    System.Threading.Tasks.TaskCompletionSource<System.Boolean>

    IsPausedOrPlaying

    Gets if this instance is in the playing state.

    public bool IsPausedOrPlaying { get; }
    Property Value
    Type Description
    System.Boolean

    MaxNumberOfBuffers

    Max number of buffers that are going to be queued.

    public abstract int MaxNumberOfBuffers { get; }
    Property Value
    Type Description
    System.Int32

    PlayRange

    Gets or sets the region of time to play from the audio clip.

    public virtual PlayRange PlayRange { get; set; }
    Property Value
    Type Description
    PlayRange

    ReadyToPlay

    Gets a task that will be fired once the source is ready to play.

    public TaskCompletionSource<bool> ReadyToPlay { get; }
    Property Value
    Type Description
    System.Threading.Tasks.TaskCompletionSource<System.Boolean>
    | Improve this Doc View Source

    Methods


    Dispose()

    Enqueues a dispose command, to dispose this instance.

    public virtual void Dispose()

    DisposeInternal()

    Destroys the instance.

    protected virtual void DisposeInternal()

    ExtractAndFillData()

    protected abstract void ExtractAndFillData()

    FillBuffer(Byte[], Int32, AudioLayer.BufferType)

    If CanFillis true with this method you can fill the next free buffer

    protected void FillBuffer(byte[] pcm, int bufferSize, AudioLayer.BufferType type)
    Parameters
    Type Name Description
    System.Byte[] pcm

    The array containing PCM data

    System.Int32 bufferSize

    The full size in bytes of PCM data

    AudioLayer.BufferType type

    If this buffer is the last buffer of the stream set to true, if not false


    FillBuffer(Int16[], Int32, AudioLayer.BufferType)

    If CanFillis true with this method you can fill the next free buffer

    protected void FillBuffer(short[] pcm, int bufferSize, AudioLayer.BufferType type)
    Parameters
    Type Name Description
    System.Int16[] pcm

    The array containing PCM data

    System.Int32 bufferSize

    The full size in bytes of PCM data

    AudioLayer.BufferType type

    If this buffer is the last buffer of the stream set to true, if not false


    FillBuffer(IntPtr, Int32, AudioLayer.BufferType)

    If CanFillis true with this method you can fill the next free buffer

    protected void FillBuffer(IntPtr pcm, int bufferSize, AudioLayer.BufferType type)
    Parameters
    Type Name Description
    System.IntPtr pcm

    The pointer to PCM data

    System.Int32 bufferSize

    The full size in bytes of PCM data

    AudioLayer.BufferType type

    If this buffer is the last buffer of the stream set to true, if not false


    InitializeInternal()

    protected virtual void InitializeInternal()

    Pause()

    Enqueues a Pause command, to Pause this instance.

    public void Pause()

    PauseInternal()

    protected virtual void PauseInternal()

    Play()

    Enqueues a Play command, to Play this instance.

    public void Play()

    PlayInternal()

    protected virtual void PlayInternal()

    PrepareInternal()

    Prepare the source for playback

    protected virtual void PrepareInternal()

    RestartInternal()

    Restarts streaming from the beginning.

    protected virtual void RestartInternal()

    SeekInternal()

    protected virtual void SeekInternal()

    SetLooped(Boolean)

    Sets if the stream should be played in loop.

    public abstract void SetLooped(bool looped)
    Parameters
    Type Name Description
    System.Boolean looped

    if looped or not


    Stop()

    Enqueues a Stop command, to Stop this instance.

    public void Stop()

    StopInternal(Boolean)

    protected virtual void StopInternal(bool ignoreQueuedBuffer = true)
    Parameters
    Type Name Description
    System.Boolean ignoreQueuedBuffer

    UpdateInternal()

    Update the sound source

    protected virtual void UpdateInternal()

    Extension Methods

    ComponentBaseExtensions.DisposeBy<T>(T, ICollectorHolder)
    ComponentBaseExtensions.RemoveDisposeBy<T>(T, ICollectorHolder)
    • Improve this Doc
    • View Source
    In This Article

    Back to top

    Copyright © 2019-2021 .NET Foundation and Contributors
    Supported by the .NET Foundation