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

◆ pulse_response() [1/2]

MAYAFLUX_API double MayaFlux::Kinesis::Discrete::pulse_response ( double  t,
double  onset,
double  duration,
double  rise,
double  fall,
double  period = 0.0 
)
noexcept

Level at a time of a leaky response to a rectangular pulse.

Parameters
tTime
onsetTime the pulse begins
durationLength of the pulse, held to the period when one is given
riseTime constant while the pulse is on; zero or less jumps to one
fallTime constant after the pulse ends; zero or less falls to zero at once
periodRepeat interval; zero or less means a single pulse
Returns
Level in [0, 1]

During the pulse the level climbs toward one as 1 - exp(-s / rise), with s the time since the pulse began. After it ends the level decays from where it stood as exp(-s / fall). Before the onset it is zero. With a period, the pattern repeats from rest every period, so a tail still decaying when the next pulse begins is cut off there.

Definition at line 7 of file Dynamics.cpp.

9{
10 double local = t - onset;
11 if (local < 0.0)
12 return 0.0;
13
14 double pulse = std::max(duration, 0.0);
15 if (period > 0.0) {
16 local -= period * std::floor(local / period);
17 pulse = std::min(pulse, period);
18 }
19
20 const auto peak_at = [rise](double s) {
21 return rise > 0.0 ? 1.0 - std::exp(-s / rise) : 1.0;
22 };
23
24 if (local <= pulse)
25 return peak_at(local);
26
27 if (fall <= 0.0)
28 return 0.0;
29 return peak_at(pulse) * std::exp(-(local - pulse) / fall);
30}

Referenced by pulse_response().

+ Here is the caller graph for this function: