Added boundary states for correct resonances
This commit is contained in:
15
Interfaces/Connection.cs
Normal file
15
Interfaces/Connection.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace FluidSim.Interfaces
|
||||
{
|
||||
/// <summary>Pure data link between two ports, with orifice parameters.</summary>
|
||||
public class Connection
|
||||
{
|
||||
public Port PortA { get; }
|
||||
public Port PortB { get; }
|
||||
|
||||
public double Area { get; set; } = 1e-5; // effective orifice area (m²)
|
||||
public double DischargeCoefficient { get; set; } = 0.62;
|
||||
public double Gamma { get; set; } = 1.4;
|
||||
|
||||
public Connection(Port a, Port b) => (PortA, PortB) = (a, b);
|
||||
}
|
||||
}
|
||||
25
Interfaces/SoundConnection.cs
Normal file
25
Interfaces/SoundConnection.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
namespace FluidSim.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// A Connection that also produces an audio sample from the pressure drop across it.
|
||||
/// </summary>
|
||||
public class SoundConnection : Connection
|
||||
{
|
||||
/// <summary>Gain applied to the normalised pressure difference.</summary>
|
||||
public float Gain { get; set; } = 1.0f;
|
||||
|
||||
/// <summary>Reference pressure used for normalisation (Pa). Default: 1 atm.</summary>
|
||||
public double ReferencePressure { get; set; } = 101325.0;
|
||||
|
||||
public SoundConnection(Port a, Port b) : base(a, b) { }
|
||||
|
||||
/// <summary>
|
||||
/// Returns a normalised audio sample proportional to the pressure difference.
|
||||
/// </summary>
|
||||
public float GetAudioSample()
|
||||
{
|
||||
double dp = PortA.Pressure - PortB.Pressure;
|
||||
return (float)(dp / ReferencePressure) * Gain;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user