engine almost working, backup before adding gas types.
This commit is contained in:
45
Audio/SoundEngine.cs
Normal file
45
Audio/SoundEngine.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user