Browse Source

Add PulseGenerator::isHigh() method.

tags/v2.6.0
Andrew Belt 11 months ago
parent
commit
58b69fad16
1 changed files with 5 additions and 1 deletions
  1. +5
    -1
      include/dsp/digital.hpp

+ 5
- 1
include/dsp/digital.hpp View File

@@ -172,7 +172,7 @@ struct PulseGenerator {
remaining = 0.f; remaining = 0.f;
} }


/** Advances the state by `deltaTime`. Returns whether the pulse is in the HIGH state. */
/** Advances the state by `deltaTime`. Returns whether the pulse was in the HIGH state before stepping. */
bool process(float deltaTime) { bool process(float deltaTime) {
if (remaining > 0.f) { if (remaining > 0.f) {
remaining -= deltaTime; remaining -= deltaTime;
@@ -181,6 +181,10 @@ struct PulseGenerator {
return false; return false;
} }


bool isHigh() {
return (remaining > 0.f);
}

/** Begins a trigger with the given `duration`. */ /** Begins a trigger with the given `duration`. */
void trigger(float duration = 1e-3f) { void trigger(float duration = 1e-3f) {
// Keep the previous pulse if the existing pulse will be held longer than the currently requested one. // Keep the previous pulse if the existing pulse will be held longer than the currently requested one.


Loading…
Cancel
Save