Events (1) Methods (12) Properties (8)
Namespace: CSCore.SoundOut

Syntax

public class WasapiOut : ISoundOut

Implements

Summary

Provides audioplayback through Wasapi. Minimum supported OS: Windows Vista (see IsSupportedOnCurrentPlatform property).

Uses

Events

Stopped

Occurs when the playback stops.

public Stopped

Methods

WasapiOut()

Initializes an new instance of WasapiOut class. EventSyncContext = SynchronizationContext.Current. PlaybackThreadPriority = AboveNormal. Latency = 100ms. EventSync = False. ShareMode = Shared.

public void WasapiOut()

WasapiOut(Boolean eventSync, AudioClientShareMode shareMode, Int32 latency)

Initializes an new instance of WasapiOut class. EventSyncContext = SynchronizationContext.Current. PlaybackThreadPriority = AboveNormal.

public void WasapiOut(Boolean eventSync, AudioClientShareMode shareMode, Int32 latency)

Parameters

eventSync

Boolean

True, to use eventsynchronization instead of a simple loop and sleep behavior.

shareMode

AudioClientShareMode

Specifies how to open the audio device. Note that if exclusive mode is used, only one single playback for the specified device is possible at once.

latency

Int32

Latency of the playback specified in milliseconds.

WasapiOut(Boolean eventSync, AudioClientShareMode shareMode, Int32 latency, ThreadPriority playbackThreadPriority)

Initializes an new instance of WasapiOut class. EventSyncContext = SynchronizationContext.Current.

public void WasapiOut(Boolean eventSync, AudioClientShareMode shareMode, Int32 latency, ThreadPriority playbackThreadPriority)

Parameters

eventSync

Boolean

True, to use eventsynchronization instead of a simple loop and sleep behavior.

shareMode

AudioClientShareMode

Specifies how to open the audio device. Note that if exclusive mode is used, only one single playback for the specified device is possible at once.

latency

Int32

Latency of the playback specified in milliseconds.

playbackThreadPriority

ThreadPriority

ThreadPriority of the playbackthread which runs in background and feeds the device with data.

public void WasapiOut(Boolean eventSync, AudioClientShareMode shareMode, Int32 latency, ThreadPriority playbackThreadPriority, SynchronizationContext eventSyncContext)

Parameters

eventSync

Boolean

True, to use eventsynchronization instead of a simple loop and sleep behavior.

shareMode

AudioClientShareMode

Specifies how to open the audio device. Note that if exclusive mode is used, only one single playback for the specified device is possible at once.

latency

Int32

Latency of the playback specified in milliseconds.

playbackThreadPriority

ThreadPriority

ThreadPriority of the playbackthread which runs in background and feeds the device with data.

eventSyncContext

SynchronizationContext

The SynchronizationContext which is used to raise any events like the Stopped-event. If the passed value is not null, the events will be called async through the Post method.

Dispose()

Stops the playback (if playing) and cleans up all used resources.

public void Dispose()

Dispose(Boolean disposing)

Disposes and stops the WasapiOut instance.

protected virtual void Dispose(Boolean disposing)

Parameters

disposing

Boolean

True to release both managed and unmanaged resources; false to release only unmanaged resources.

Finalize()

Finalizes an instance of the WasapiOut class.

protected void Finalize()

Initialize(IWaveSource source)

Initializes WasapiOut instance and prepares all resources for playback. Note that properties like Device, Latency,... won't affect WasapiOut after calling Initialize.

public void Initialize(IWaveSource source)

Parameters

source

IWaveSource

The source to prepare for playback.

save

reset

Drag to pan - Use Mousewheel + Ctrl to zoom

Pause()

Pauses the playback.

public void Pause()

Play()

Starts the playback. Note: Initialize has to get called before calling Play. If PlaybackState is Paused, Resume will be called automatically.

public void Play()

Resume()

Resumes the paused playback.

public void Resume()

Stop()

Stops the playback and frees most of allocated resources.

public void Stop()

Properties

DebuggingId

Gets a random ID based on internal audioclients memory address for debugging purposes.

public Int64 DebuggingId { get; }

Device

Gets or sets the Device which should be used for playback. The Device property has to be set before initializing. The systems default playback device is used as default value of the Device property.

public MMDevice Device { get; set; }

Remarks

Make sure to set only activated render devices.

IsSupportedOnCurrentPlatform

Gets a value which indicates whether Wasapi is supported on the current Platform. True means that the current platform supports WasapiOut; False means that the current platform does not support WasapiOut.

public Boolean IsSupportedOnCurrentPlatform { get; }

Latency

Gets or sets the latency of the playback specified in milliseconds. The Latency property has to be set before initializing.

public Int32 Latency { get; set; }

PlaybackState

Gets the current PlaybackState of the playback.

public PlaybackState PlaybackState { get; }

UseChannelMixingMatrices

Gets or sets a value indicating whether WasapiOut should try to use all available channels.

public Boolean UseChannelMixingMatrices { get; set; }

Volume

Gets or sets the volume of the playback. Valid values are in the range from 0.0 (0%) to 1.0 (100%).

public Single Volume { get; set; }

WaveSource

The currently initialized source. To change the WaveSource property, call Initialize.

public IWaveSource WaveSource { get; }

Remarks

The value of the WaveSource might not be the value which was passed to the Initialize method, because WasapiOut (depending on the waveformat of the source) has to use a DmoResampler.