Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

AudioSink Class

Exposes the capture graph for audio devices. Derive from this class to receive audio information and to obtain the capture graph through AudioSink.CaptureSource.

System.Object
  System.Windows.Media.AudioSink

Namespace:  System.Windows.Media
Assembly:  System.Windows (in System.Windows.dll)
public abstract class AudioSink

The AudioSink type exposes the following members.

  NameDescription
Public methodSupported by Silverlight for Windows PhoneAudioSinkInitializes a new instance of the AudioSink class.
Top
  NameDescription
Public propertySupported by Silverlight for Windows PhoneCaptureSourceGets or sets a capture source that is associated with this AudioSink.
Top
  NameDescription
Public methodSupported by Silverlight for Windows PhoneEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneFinalizeFrees the resources that are used by the AudioSink class. (Overrides Object.Finalize().)
Public methodSupported by Silverlight for Windows PhoneGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneOnCaptureStartedWhen overridden in a derived class, is invoked when an audio device starts capturing audio data.
Protected methodSupported by Silverlight for Windows PhoneOnCaptureStoppedWhen overridden in a derived class, is invoked when an audio device stops capturing audio data.
Protected methodSupported by Silverlight for Windows PhoneOnFormatChangeWhen overridden in a derived class, is invoked when an audio device reports an audio format change.
Protected methodSupported by Silverlight for Windows PhoneOnSamplesWhen overridden in a derived class, is invoked when an audio device captures a complete audio sample.
Public methodSupported by Silverlight for Windows PhoneToStringReturns a string that represents the current object. (Inherited from Object.)
Top

To obtain audio information from an audio input device in Silverlight, you derive your custom audio sink from AudioSink.

AudioSink exposes several virtual callbacks:

You must provide overrides for the callbacks in order to compile when you derive from AudioSink. However, you can implement a basic but functional AudioSink that can have empty callback overrides and that uses only the methods of the CaptureSource from AudioSink.CaptureSource. For more information, see CaptureSource.

Implementing AudioSink Overrides

In order to work with raw audio from a capture graph, you must override OnSamples and provide an implementation in your audio sink that converts the sampleData to your destination format. You can then use the numbers that you obtained from BitsPerSample, Channels, and SamplesPerSecond to convert a bit stream to a PCM audio format. Your conversion logic could use a series of nested loops and appropriate data types (such as Byte for 8-bit and Int32 for 32-bit) to obtain discrete samples.

If you provide a meaningful override of OnSamples, you should also provide a meaningful OnFormatChange override. The AudioFormat information for this sink can change between the time that the device was first connected and the actual time of capture. Handling OnFormatChange is the only way to know the true format information at run time.

You can use OnCaptureStarted and OnCaptureStopped as UI change notifications to indicate to the user that the audio is currently being captured or that capture has stopped. You can also use the notifications as sentinels to block certain other actions in your application while the capture is ongoing.

Silverlight

Supported in: 5, 4

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft. All rights reserved.