namespace FluidSim.Audio { public class SoundEngine : IDisposable { private readonly AudioOutputStream _stream; private bool _isPlaying; public SoundEngine(SimulationRingBuffer sourceBuffer, int bufferCapacity = 16384) { _stream = new AudioOutputStream(sourceBuffer); } public void Start() { if (_isPlaying) return; _stream.Play(); _isPlaying = true; } public void Stop() { if (!_isPlaying) return; _stream.Stop(); _isPlaying = false; } public double Speed { get => _stream.Speed; set => _stream.Speed = value; } public float Volume { get => _stream.Volume; set => _stream.Volume = value; } public void Dispose() { Stop(); _stream.Dispose(); } } }