private void Initialize(WaveFormat format, byte[] buffer, int offset, int count, int loopStart, int loopLength)
{
_format = format;
_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,
Context = new IntPtr(42),
};
_loopedBuffer = new AudioBuffer()
{
Stream = _dataStream,
AudioBytes = count,
Flags = BufferFlags.EndOfStream,
LoopBegin = loopStart,
LoopLength = loopLength,
LoopCount = AudioBuffer.LoopInfinite,
Context = new IntPtr(42),
};
}