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

◆ integrated()

TimeMap MayaFlux::Kinesis::TimeMaps::integrated ( double  start,
std::shared_ptr< const double >  velocity 
)
inline

Position that integrates a velocity you can change while it plays.

Parameters
startPosition at time zero
velocityPosition units per second, read at every evaluation. Negative reverses and zero holds.

The position carries on from wherever it is when the velocity changes, so speeding up, slowing down, reversing or stopping never jumps. Unlike the other factories this map keeps a running position, so give each voice its own instance. Time going backwards restarts it from start.

Definition at line 113 of file TimeMap.hpp.

114{
115 struct State {
116 double position;
117 double last;
118 };
119
120 auto state = std::make_shared<State>(State { .position = start, .last = 0.0 });
121
122 return { .fn = [state, start, velocity = std::move(velocity)](const double& t) -> double {
123 if (t < state->last) {
124 state->position = start;
125 state->last = 0.0;
126 }
127
128 state->position += *velocity * (t - state->last);
129 state->last = t;
130 return state->position;
131 } };
132}
std::optional< glm::vec3 > position
Definition Decoder.cpp:93

References MayaFlux::Kinesis::Tendency< D, R >::fn, position, and MayaFlux::Kinesis::velocity().

Referenced by MayaFlux::Kriya::TapSetBuilder::start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: