namespace FluidSim.Interfaces
{
///
/// A Connection that also produces an audio sample from the pressure drop across it.
///
public class SoundConnection : Connection
{
/// Gain applied to the normalised pressure difference.
public float Gain { get; set; } = 1.0f;
/// Reference pressure used for normalisation (Pa). Default: 1 atm.
public double ReferencePressure { get; set; } = 101325.0;
public SoundConnection(Port a, Port b) : base(a, b) { }
///
/// Returns a normalised audio sample proportional to the pressure difference.
///
public float GetAudioSample()
{
double dp = PortA.Pressure - PortB.Pressure;
return (float)(dp / ReferencePressure) * Gain;
}
}
}