MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ dynamic_reed_mouth_step()

MAYAFLUX_API std::tuple< double, double, double > MayaFlux::Kinesis::Acoustics::dynamic_reed_mouth_step ( const ReedChannel & reed,
double resonance,
double damping,
double reed_area,
double time_step,
std::array< double, 2 > & motion,
double end_pressure_gain,
double mouth_pressure,
double end_pressure,
double downstream_flow )
nodiscardnoexcept

Couple a reed with its own dynamics to the first cell of the bore.

Parameters
reedChannel. closing_pressure sets the static compliance, so the reed settles at H (1 - d / pM) under a steady difference d.
resonanceResonance of the reed in Hz, positive
dampingDamping of the reed in 1/s, not negative
reed_areaEffective area in square metres over which the reed moves air, not negative; zero leaves the reed's own flow out
time_stepTime step in seconds
motionDisplacement of the reed from rest, then the previous one, in metres, updated here; start both at zero
end_pressure_gainGain of the first pressure point from DuctGrid
mouth_pressureBlowing pressure at the half step
end_pressurePressure of the first point at the start of the sample
downstream_flowVolume velocity of the first half section, from the same sample
Returns
The first point's pressure after the sample, the flow into the bore at the half step, and the pressure difference across the reed

The reed is a damped oscillator, y'' + damping y' + w0^2 y = -w0^2 H d / pM, stepped by a centred scheme that is stable for any step. The opening during a sample is the one the previous sample left, which makes the coupling an exact closed form, s |s| + a s = target with s = sign(d) sqrt|d|, solved by its stable root. The solution is unique for every parameter, with no condition to check. The lag is half a sample, small beside the period of a reed resonance. A reed driven past the lay is held there without bouncing. With a reed_area the moving reed also pushes air, a flow of -reed_area times its velocity into the bore, which is added to the flow returned and enters the coupling like any other known flow (Avanzini and Rocchesso). An invalid channel or resonance acts as a wall.

Definition at line 111 of file Reed.cpp.

122{
123 const double gain = flow_coupling_gain(end_pressure_gain);
124 const double target = flow_coupling_target(mouth_pressure, end_pressure, gain, downstream_flow);
125
126 if (!channel_valid(reed) || !positive_finite(resonance) || !positive_finite(time_step)
127 || !std::isfinite(damping) || damping < 0.0 || !std::isfinite(reed_area) || reed_area < 0.0
128 || !std::isfinite(target) || !positive_finite(gain)) {
129 motion = { 0.0, 0.0 };
130 return { centred_end_pressure(mouth_pressure, target, end_pressure), 0.0, target };
131 }
132
133 const double pushed = -reed_area * (motion[0] - motion[1]) / time_step;
134 const double known = flow_coupling_target(mouth_pressure, end_pressure, gain, downstream_flow - pushed);
135
136 const double opening = std::max(0.0, reed.rest_opening + motion[0]);
137 const double coefficient = reed.width * opening * std::sqrt(2.0 / reed.air_density);
138 const double reach = gain * coefficient;
139 const double magnitude = std::abs(known);
140
141 const double root = magnitude > 0.0 ? 2.0 * magnitude / (reach + std::sqrt(reach * reach + 4.0 * magnitude)) : 0.0;
142 const double sign = known >= 0.0 ? 1.0 : -1.0;
143 const double difference = sign * root * root;
144 const double flow = sign * coefficient * root;
145
146 const double omega = 2.0 * std::numbers::pi * resonance;
147 const double stiffness = omega * omega;
148 const double inverse_square = 1.0 / (time_step * time_step);
149 const double half_damping = damping / (2.0 * time_step);
150 const double force = -stiffness * reed.rest_opening * difference / reed.closing_pressure;
151
152 const double next = (force + 2.0 * inverse_square * motion[0]
153 - (inverse_square - half_damping + 0.5 * stiffness) * motion[1])
154 / (inverse_square + half_damping + 0.5 * stiffness);
155
156 motion = { std::max(next, -reed.rest_opening), motion[0] };
157 return { centred_end_pressure(mouth_pressure, difference, end_pressure), flow + pushed, difference };
158}
constexpr double centred_end_pressure(double driving_pressure, double pressure_difference, double end_pressure) noexcept
Pressure of the end cell after the step, once the difference is solved.
constexpr double flow_coupling_target(double driving_pressure, double end_pressure, double gain, double downstream_flow) noexcept
Right side of the coupling equation.
constexpr double flow_coupling_gain(double end_pressure_gain) noexcept
Gain of a time centred coupling at an end cell.

References centred_end_pressure(), flow_coupling_gain(), and flow_coupling_target().

Here is the call graph for this function: