Search Results for

    Show / Hide Table of Contents

    Class AudioSource

    The audio source class.

    Inheritance
    object
    AudioSource
    ALAudioSource
    XAudioSource
    Implements
    IDisposable
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Evergine.Common.Audio
    Assembly: Evergine.Common.dll
    Syntax
    public abstract class AudioSource : IDisposable

    Constructors

    AudioSource(WaveFormat)

    Initializes a new instance of the AudioSource class.

    Declaration
    public AudioSource(WaveFormat format)
    Parameters
    Type Name Description
    WaveFormat format

    The format of the audio data.

    Properties

    CurrentBuffer

    Gets the buffer at the beginning of the pending queue.

    Declaration
    public AudioBuffer CurrentBuffer { get; }
    Property Value
    Type Description
    AudioBuffer

    Format

    Gets the format of the audio data.

    Declaration
    public WaveFormat Format { get; }
    Property Value
    Type Description
    WaveFormat

    IsLooped

    Gets or sets a value indicating whether the sound should loop from beginning when it reaches the end. Default value is false.

    Declaration
    public bool IsLooped { get; set; }
    Property Value
    Type Description
    bool

    Pan

    Gets or sets the sound balance between left and right speaker. Default value is 0.0f.

    Declaration
    public float Pan { get; set; }
    Property Value
    Type Description
    float
    Remarks

    Panning is ranging from -1.0f (full left) to 1.0f (full right). 0.0f is centered. Values beyond this range are clamped.

    PendingBuffers

    Gets a enumerable that contains the buffers that are pending to be processed by this audio source including CurrentBuffer.

    Declaration
    public IEnumerable<AudioBuffer> PendingBuffers { get; }
    Property Value
    Type Description
    IEnumerable<AudioBuffer>

    PendingBuffersCount

    Gets the number of buffers that are pending to be processed by this audio source including CurrentBuffer.

    Declaration
    public int PendingBuffersCount { get; }
    Property Value
    Type Description
    int

    Pitch

    Gets or sets the pitch of the sound, might conflict with spatialized sound spatialization. Default value is 1.0f.

    Declaration
    public float Pitch { get; set; }
    Property Value
    Type Description
    float
    Remarks

    Pitch is ranging from Epsilon to MaxValue. Values beyond this range are clamped. Each reduction by 50 percent equals a pitch shift of -12 semitones(one octave reduction). Each doubling equals a pitch shift of 12 semitones(one octave increase).

    PlayPosition

    Gets the playback position. If IsLooped is active, the value will loop back to zero on every loop.

    Declaration
    public TimeSpan PlayPosition { get; }
    Property Value
    Type Description
    TimeSpan

    QueueDuration

    Gets the total duration of the buffers that are currently queued in this audio source.

    Declaration
    public TimeSpan QueueDuration { get; }
    Property Value
    Type Description
    TimeSpan

    QueuePlayPosition

    Gets or sets the playback position relative to the beginning of the PendingBuffers queue.

    Declaration
    public TimeSpan QueuePlayPosition { get; set; }
    Property Value
    Type Description
    TimeSpan
    Remarks

    QueuePosition is ranging from Zero to QueueDuration. Values beyond this range are clamped. When the audio source is in Stopped state and the value is higher than Zero the state will change to Paused. The position is relative to the beginning of all the queued buffers for the source, and any queued buffers traversed by a set value will raise the event BufferEnded.

    State

    Gets the state (playing, paused, or stopped) of the sound.

    Declaration
    public PlayState State { get; }
    Property Value
    Type Description
    PlayState

    Volume

    Gets or sets the global volume at which the sound is played. Default value is 1.0f.

    Declaration
    public float Volume { get; set; }
    Property Value
    Type Description
    float
    Remarks

    Volume is ranging from 0.0f (silence) to 1.0f (full volume). Values beyond those limits are clamped.

    Methods

    Apply3D(AudioEmitter)

    Sets the ·D properties of the Audio Source according to an audio emitter.

    Declaration
    public abstract void Apply3D(AudioEmitter emitter)
    Parameters
    Type Name Description
    AudioEmitter emitter

    The audio emitter.

    Dispose()

    Declaration
    public abstract void Dispose()

    EnqueueBuffer(AudioBuffer)

    Enqueues an audio buffer.

    Declaration
    public void EnqueueBuffer(AudioBuffer buffer)
    Parameters
    Type Name Description
    AudioBuffer buffer

    The audio buffer.

    FlushBuffers()

    Flush all the audio buffers.

    Declaration
    public abstract void FlushBuffers()

    GetPlayPosition()

    Gets the play TimeSpan position of the audio.

    Declaration
    protected abstract TimeSpan GetPlayPosition()
    Returns
    Type Description
    TimeSpan

    A TimeSpan with the current play position.

    GetQueuePlayPosition()

    Gets the Queue Play TimeSpan Position.

    Declaration
    protected abstract TimeSpan GetQueuePlayPosition()
    Returns
    Type Description
    TimeSpan

    A TimeSpan with the Queue Play Position.

    InternalEnqueueBuffer(AudioBuffer, out int?)

    Enqueues an audio buffer into the source.

    Declaration
    protected abstract void InternalEnqueueBuffer(AudioBuffer buffer, out int? index)
    Parameters
    Type Name Description
    AudioBuffer buffer

    The buffer to be enqueued.

    int? index

    Output variable containing the buffer index.

    InternalPause()

    Pauses the audio source.

    Declaration
    protected abstract void InternalPause()

    InternalPlay()

    Plays the audio source.

    Declaration
    protected abstract void InternalPlay()

    InternalStop()

    Stops the audio source.

    Declaration
    protected abstract void InternalStop()

    IsPaused()

    Checks if this audio source is paused.

    Declaration
    protected abstract bool IsPaused()
    Returns
    Type Description
    bool

    True if this audio source is pause. False otherwise.

    IsPlaying()

    Checks if the source is playing.

    Declaration
    protected abstract bool IsPlaying()
    Returns
    Type Description
    bool

    True if the audio source is playing. False otherwise.

    OnBufferProccessed(bool)

    Method called when an audio buffer has being processed.

    Declaration
    protected void OnBufferProccessed(bool isReused)
    Parameters
    Type Name Description
    bool isReused

    If the buffer must be reused.

    OnBufferStart()

    Method called when an audio buffer starts playing.

    Declaration
    protected void OnBufferStart()

    Pause()

    Pauses the audio source.

    Declaration
    public void Pause()

    Play()

    Plays the audio source.

    Declaration
    public void Play()

    SetLoop(bool)

    Sets a new value to indicate if the source is looped.

    Declaration
    protected abstract void SetLoop(bool isLooped)
    Parameters
    Type Name Description
    bool isLooped

    If the source must loop the sound.

    SetPan(float)

    Sets the pan of this audio source.

    Declaration
    protected abstract void SetPan(float pan)
    Parameters
    Type Name Description
    float pan

    The new pan.

    SetPitch(float)

    Sets the new pitch of this source.

    Declaration
    protected abstract void SetPitch(float pitch)
    Parameters
    Type Name Description
    float pitch

    The new pitch.

    SetQueuePlayPosition(TimeSpan)

    Sets the queue play TimeSpan position.

    Declaration
    protected abstract void SetQueuePlayPosition(TimeSpan position)
    Parameters
    Type Name Description
    TimeSpan position

    The new TimeSpan position.

    SetVolume(float)

    Sets the volume of this source.

    Declaration
    protected abstract void SetVolume(float volume)
    Parameters
    Type Name Description
    float volume

    The new volume.

    Stop()

    Stops the audio source.

    Declaration
    public void Stop()

    Events

    BufferEnded

    Occurs when this audio source finishes processing an enqueued AudioBuffer.

    Declaration
    public event EventHandler<AudioBufferEventArgs> BufferEnded
    Event Type
    Type Description
    EventHandler<AudioBufferEventArgs>

    BufferStarted

    Occurs when this audio source is about to start processing an enqueued AudioBuffer.

    Declaration
    public event EventHandler<AudioBufferEventArgs> BufferStarted
    Event Type
    Type Description
    EventHandler<AudioBufferEventArgs>

    Implements

    IDisposable

    Extension Methods

    ReflectionHelper.GetMemberAssembly(object)
    ReflectionHelper.GetTypeName(object)
    In This Article
    Back to top
    Generated by DocFX