Passes each incoming trigger with a stated probability, deterministically. More...
#include <probability_gate.hpp>
Public Member Functions | |
| ProbGateT () | |
| void | prepare (double) |
| void | set_probability (double p) |
| double | probability () const |
| void | set_seed (std::uint32_t seed) |
| void | apply_reset_edge () |
| Verb 2: clears the edge-detector latch only. The RNG stream is untouched. | |
| void | reset () |
| Verb 1: clears the latch and rewinds the stream to the seed. | |
| std::uint32_t | draw_count () const |
| Number of draws consumed since the last reset() — the stream position, exposed so a test can assert it advances once per trigger whatever p is. | |
| bool | process_edge (bool trigger_edge) |
| Decides one already-detected trigger edge. | |
| bool | process (SampleType trigger) |
| Detects the edge from a trigger signal and decides it, so this block can sit directly on a clock output without a separate detector. | |
Static Public Member Functions | |
| static constexpr int | latency_samples () |
Static Public Attributes | |
| static constexpr double | kDefaultProbability = 0.5 |
| Pass probability. | |
| static constexpr std::uint32_t | kProbSeed = 0x1234567u |
| [design parameter] default 0x1234567, range 0 .. 2^31 − 1. | |
Passes each incoming trigger with a stated probability, deterministically.
The draw is a seeded Xorshift32 (series law 2), so a probabilistic groove can be auditioned, bounced and reloaded and give the same performance every time. Changing the seed is how you roll again; the seed is a config value and never an automation lane.
A draw is consumed on every trigger regardless of p. p gates the result, never whether we draw. If a p of 1 skipped the draw, automating p during a take would shift the stream position and every later decision with it — the same pattern would render differently depending on the automation that preceded it, which is exactly the reproducibility law 2 exists to protect.
A transport reset edge clears the edge-detector latch but does not rewind the stream: a live reset jack that rewound randomness would make every reset sound identical.
USE. Generative drums — on a hi-hat clock for humanized density; automate p for a build-up that is still bit-reproducible. Trigger thinning — drop hits from a BurstGenT (kit) ratchet for un-mechanical rolls. Sometimes-accent — GateLogicT(and) of a probability gate with a downbeat clock.
RT contract: as the header. One generator call per trigger.
|
inline |
|
inline |
Verb 2: clears the edge-detector latch only. The RNG stream is untouched.
|
inline |
Number of draws consumed since the last reset() — the stream position, exposed so a test can assert it advances once per trigger whatever p is.
|
inlinestaticconstexpr |
|
inline |
|
inline |
|
inline |
Detects the edge from a trigger signal and decides it, so this block can sit directly on a clock output without a separate detector.
|
inline |
Decides one already-detected trigger edge.
|
inline |
Verb 1: clears the latch and rewinds the stream to the seed.
|
inline |
|
inline |
|
staticconstexpr |
Pass probability.
[design parameter] default 0.5, range 0 .. 1.
|
staticconstexpr |
[design parameter] default 0x1234567, range 0 .. 2^31 − 1.