I'm implementing a very simple band-pass filter, and it's input arguments are a vector containing the signal, the dwell time, and the cutoff frequencies for the high-pass and low-pass filters:
typedef std::vector<double> vec;
vec bandPass(const vec& signal, double dwellTime, double lowCutoff, double highCutoff);
The obvious problem with my interface is that the function caller has to know in advance what units of time and frequency are expected, and may have to go through the annoyance of converting them appropriately, if necessary.
I figured I could maybe use std::chrono
to solve my problem, but I haven't seen it being used to measure frequencies. I'd want to have:
vec bandPass(const vec& signal, milliseconds dwellTime, kHertz lowCutoff, kHertz highCutoff);
and have my function convert all units to seconds and Hertz for the computation. Ideally, multiplying milliseconds and kHz would give me the same results as multiplying seconds and Hz.
Has anyone ever come accross a similar issue? Is it legal C++ to write anything like 1/10s
to refer to Hertz?
I don't have much experience with std::chrono (and with C++, for that matter) and hoped I could gather some words of wisdom here before defining my interface. Any other suggestions are also welcome.
std::chrono::duration
specifically for representing a time interval. – AndyG