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. */ /** 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() { void reset() {
time = 0.f; time = 0.f;
} }


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


typedef TTimer<> Timer;



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


Loading…
Cancel
Save