public WavPlayer(IBufferAllocator <byte> bufferAllocator) { this.bufferAllocator = bufferAllocator; WaveOut = new WaveOut(); CurrentSegment = null; Position = 0; }
private void RemoveCurrentSegment() { if (CurrentSegment == null) { return; } bufferAllocator.ReturnBuffer(CurrentSegment.Data); CurrentSegment = CurrentSegment.NextSegment; }
public void AddAudioData(long startByte, byte[] data) { AudioSegment segment = new AudioSegment() { StartIndex = startByte, Data = data }; if (CurrentSegment == null) { if (startByte + data.Length > Position) { CurrentSegment = segment; } } else { CurrentSegment.Insert(segment); } }
public void Insert(AudioSegment newSegment) { if (NextSegment == null) { if (newSegment.StartIndex + newSegment.Data.Length > StartIndex + Data.Length) { NextSegment = newSegment; } } else { if (newSegment.StartIndex < NextSegment.StartIndex) { newSegment.NextSegment = NextSegment; NextSegment = newSegment; } else { NextSegment.Insert(newSegment); } } }