Exposes the capture graph for audio devices. Derive from this class to receive audio information and to obtain the capture graph through AudioSink.CaptureSource.
Assembly: System.Windows (in System.Windows.dll)
Thetype exposes the following members.
|Equals(Object)||Determines whether the specified Object is equal to the current Object. (Inherited from Object.)|
|Finalize||Frees the resources that are used by the class. (Overrides Object.Finalize.)|
|GetHashCode||Serves as a hash function for a particular type. (Inherited from Object.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|MemberwiseClone||Creates a shallow copy of the current Object. (Inherited from Object.)|
|OnCaptureStarted||When overridden in a derived class, is invoked when an audio device starts capturing audio data.|
|OnCaptureStopped||When overridden in a derived class, is invoked when an audio device stops capturing audio data.|
|OnFormatChange||When overridden in a derived class, is invoked when an audio device reports an audio format change.|
|OnSamples||When overridden in a derived class, is invoked when an audio device captures a complete audio sample.|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
To obtain audio information from an audio input device in Silverlight, you derive your custom audio sink from .
exposes several virtual callbacks:
You must provide overrides for the callbacks in order to compile when you derive from . However, you can implement a basic but functional 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.
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.