Bug found in SoundEffect.XAudio.cs file.
For SharpDX.AudioBuffer instance, PlayLength must be in samples not in bytes.
public void PlatformInitialize(byte[] buffer, int sampleRate, AudioChannels channels)
{
PlatformInitialize(buffer, 0, buffer.Length, sampleRate, channels, 0, buffer.Length);
}
private void PlatformInitialize(byte[] buffer, int offset, int count, int sampleRate, AudioChannels channels, int loopStart, int loopLength)
{
_format = new WaveFormat(sampleRate, (int)channels);
_dataStream = DataStream.Create<byte>(buffer, true, false);
// Use the loopStart and loopLength also as the range
// when playing this SoundEffect a single time / unlooped.
_buffer = new AudioBuffer()
{
Stream = _dataStream,
AudioBytes = count,
Flags = BufferFlags.EndOfStream,
PlayBegin = loopStart,
PlayLength = loopLength, //<Error must been converted in samples
Context = new IntPtr(42),
};