Browse Source

Make dsp::Timer a template.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
23428d171f
1 changed files with 6 additions and 3 deletions
  1. +6
    -3
      include/dsp/digital.hpp

+ 6
- 3
include/dsp/digital.hpp View File

@@ -112,20 +112,23 @@ struct PulseGenerator {


/** Accumulates a timer when process() is called. */
struct Timer {
float time = 0.f;
template <typename T = float>
struct TTimer {
T time = 0.f;

void reset() {
time = 0.f;
}

/** Returns the time since last reset or initialization. */
float process(float deltaTime) {
T process(T deltaTime) {
time += deltaTime;
return time;
}
};

typedef TTimer<> Timer;


/** Counts calls to process(), returning true every `division` calls.
Example:


Loading…
Cancel
Save