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

◆ clocked_register()

MAYAFLUX_API bool MayaFlux::Kinesis::Discrete::clocked_register ( const std::vector< double > &  inputs,
std::span< double >  coefs 
)
noexcept

Shift register: slot 1 is sampled into it on every rise of slot 0.

coefs: [threshold, latched, length, tap, stages...]. The output is the chosen stage, so the data a while ago comes back out on the clock: a clocked delay line of bits, and with a random or feedback data signal a sequence generator.

Definition at line 349 of file Boolean.cpp.

350{
351 if (inputs.size() < 2 || coefs.size() < 4)
352 return false;
353
354 const size_t length = index_of(coefs[2]);
355 if (length == 0 || coefs.size() < 4 + length)
356 return false;
357
358 const auto stages = coefs.subspan(4, length);
359 if (rises(inputs[0] > coefs[0], coefs[1])) {
360 for (size_t i = length - 1; i > 0; --i)
361 stages[i] = stages[i - 1];
362 stages[0] = inputs[1] > coefs[0] ? 1.0 : 0.0;
363 }
364 return stages[std::min(index_of(coefs[3]), length - 1)] > 0.5;
365}
uint64_t length
Definition Composite.cpp:11

References length.