AudioSink Class
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
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)
The AudioSink type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | CaptureSource | Gets or sets a capture source that is associated with this AudioSink. |
| Name | Description | |
|---|---|---|
![]() | 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 AudioSink 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 Windows Phone, 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.
Important Note: |
|---|
|
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.



Important Note:
The 7x27a processor allows audio input on only one stereo bus at a time. This means applications cannot concurrently capture more than one audio source on these devices. If your application is using