19#ifndef SBL_DSP_PM_BOW_HPP_
20#define SBL_DSP_PM_BOW_HPP_
35 static_assert(is_friction_law_v<Law>,
"a Bow runs a friction law (physical-modeling.md §4.5)");
55 Law&
law() {
return law_; }
56 const Law&
law()
const {
return law_; }
71 pressure_ = pressure_port_.
advance(n);
73 law_.set_force_su(pressure_);
78 if (pressure_ <= 0.0f)
return last_force_ = 0.0f;
85 float energy()
const {
return 0.0f; }
94 law_.set_force_su(pressure_);
102 bool sticking()
const {
return pressure_ > 0.0f && law_.sticking(); }
104 float limit()
const {
return law_.limit(); }
106 float force()
const {
return last_force_; }
117 static constexpr float TWO = 2.0f;
124 float last_force_ = 0.0f;
Clamping (Cross-cutting — Math)
void add_edge(uint8_t from, uint8_t to, Wave wave)
uint8_t add_node(Kind kind, const char *name, uint8_t group, float value=0.0f, float value2=0.0f)
float energy() const
A bow stores nothing: it only does work on the string.
static constexpr float DEFAULT_PRESSURE_SU
static constexpr float DEFAULT_VELOCITY_SU
static constexpr float SMOOTH_MS
diagram::Ports describe(diagram::Graph &g, uint8_t group, const char *name="bow") const
The velocity source into the friction junction. Never called from audio code.
void set_pressure_su(float su)
How hard it presses: which force slice the law reads. Zero is no contact. Smoothed.
static constexpr float MIN_PRESSURE_SU
float excite(const JunctionState &j)
One sample: the force on the string for the junction's state.
void advance(uint16_t n)
A block's worth of port movement.
float force() const
The force injected on the last sample, in wave units.
static constexpr float MAX_VELOCITY
wave units at full speed
bool sticking() const
True while the bow holds the string (with weight on it).
Law & law()
The law, for its own parameters (a table, a rosin).
float limit() const
The static limit the bow holds the string with right now, in wave units.
void set_velocity_su(float su)
How fast the bow travels across the string. Smoothed.
void set(float target)
The port's setter stores here; nothing moves until advance().
float advance(uint16_t n)
Advance by a block: the smoothed value to apply for this block.
static float limit(float x)
The rational sigmoid, available for composition use.
What a load, an exciter, a termination and a friction law provide (Physical modeling — cross-cutting)
Fixed-point constants and audio sample types.
A model's wiring, as data (AP-037)
@ Source
a driving signal (bow velocity, pluck)
constexpr float clamp01(float x)
x held to [0, 1]; NaN → 0.
Physical modeling: laws, bows, junctions, loads, resonators, strings (docs/conventions/physical-model...
A port's target, its smoother and its last value.
The ports a component exposes after describing itself, so an owner can wire them.
uint8_t in
where a wave enters (the junction, the load)
What the guide reports at an excitation point, each sample.
float impedance
the guide's wave impedance Z
float velocity
the velocity arriving at the point, before this sample's injection