SoundEffect.GetSampleDuration Method

Returns the sample duration based on the specified sample size and sample rate.

Namespace:  Microsoft.Xna.Framework.Audio
Assembly:  Microsoft.Xna.Framework (in Microsoft.Xna.Framework.dll)


Public Shared Function GetSampleDuration ( _
    sizeInBytes As Integer, _
    sampleRate As Integer, _
    channels As AudioChannels _
) As TimeSpan
public static TimeSpan GetSampleDuration(
    int sizeInBytes,
    int sampleRate,
    AudioChannels channels


  • sizeInBytes
    Type: System.Int32
    Size, in bytes, of audio data.
  • sampleRate
    Type: System.Int32
    Sample rate, in Hertz (Hz), of audio content. The sampleRate must be between 8000 Hz and 48000 Hz.

Return Value

Type: System.TimeSpan
The calculated sample duration.

Version Information


Supported in: 5


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