Table of Contents

Class DynamicSoundSource

Namespace
Stride.Audio
Assembly
Stride.Audio.dll
public abstract class DynamicSoundSource : IDisposable
Inheritance
DynamicSoundSource
Implements
Derived
Extension Methods

Constructors

DynamicSoundSource(SoundInstance, int, int)

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

soundInstance SoundInstance

the sound instance associated.

numberOfBuffers int

the size of the streaming ring-buffer.

maxBufferSizeBytes int

the maximum size of each buffer.

Fields

Commands

The commands derived classes should execute.

protected readonly ConcurrentQueue<DynamicSoundSource.AsyncCommand> Commands

Field Value

ConcurrentQueue<DynamicSoundSource.AsyncCommand>

Logger

public static Logger Logger

Field Value

Logger

NewSources

protected static readonly ConcurrentBag<DynamicSoundSource> NewSources

Field Value

ConcurrentBag<DynamicSoundSource>

Sources

protected static readonly List<DynamicSoundSource> Sources

Field Value

List<DynamicSoundSource>

deviceBuffers

protected readonly List<AudioLayer.Buffer> deviceBuffers

Field Value

List<AudioLayer.Buffer>

freeBuffers

protected readonly Queue<AudioLayer.Buffer> freeBuffers

Field Value

Queue<AudioLayer.Buffer>

isDisposed

protected bool isDisposed

Field Value

bool

isInitialized

protected bool isInitialized

Field Value

bool

playingQueued

If we are waiting to play.

protected volatile bool playingQueued

Field Value

bool

soundInstance

The sound instance associated.

protected SoundInstance soundInstance

Field Value

SoundInstance

state

If we are in the paused state.

protected PlayState state

Field Value

PlayState

Properties

CanFill

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

protected virtual bool CanFill { get; }

Property Value

bool

Ended

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

public TaskCompletionSource<bool> Ended { get; }

Property Value

TaskCompletionSource<bool>

IsPausedOrPlaying

Gets if this instance is in the playing state.

public bool IsPausedOrPlaying { get; }

Property Value

bool

MaxNumberOfBuffers

Max number of buffers that are going to be queued.

public abstract int MaxNumberOfBuffers { get; }

Property Value

int

PlayRange

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

public virtual PlayRange PlayRange { get; set; }

Property Value

PlayRange

ReadyToPlay

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

public TaskCompletionSource<bool> ReadyToPlay { get; }

Property Value

TaskCompletionSource<bool>

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[], int, 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

pcm byte[]

The array containing PCM data

bufferSize int

The full size in bytes of PCM data

type AudioLayer.BufferType

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

FillBuffer(short[], int, 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

pcm short[]

The array containing PCM data

bufferSize int

The full size in bytes of PCM data

type AudioLayer.BufferType

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

FillBuffer(nint, int, BufferType)

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

protected void FillBuffer(nint pcm, int bufferSize, AudioLayer.BufferType type)

Parameters

pcm nint

The pointer to PCM data

bufferSize int

The full size in bytes of PCM data

type AudioLayer.BufferType

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(bool)

Sets if the stream should be played in loop.

public abstract void SetLooped(bool looped)

Parameters

looped bool

if looped or not

Stop()

Enqueues a Stop command, to Stop this instance.

public void Stop()

StopInternal(bool)

protected virtual void StopInternal(bool ignoreQueuedBuffer = true)

Parameters

ignoreQueuedBuffer bool

UpdateInternal()

Update the sound source

protected virtual void UpdateInternal()