Periodic trigger.
Version: 1.0.1
Requires:
This algorithm is deprecated, thus we are not offering new licensese for it.
The current version is bwp_trig_v2.
Module type: Utility
typedef struct bwp_trig bwp_trig;
Trigger object.
static inline void bwp_trig_init(
bwp_trig * BW_RESTRICT trig);
Initializes option values in trig.
Call this on trig before other functions in this API.
static inline void bwp_trig_set_sample_rate(
bwp_trig * BW_RESTRICT trig,
float sample_rate);
Sets the sample_rate (Hz) value in trig.
This function must be called at least once before calling bwp_trig_reset().
static inline void bwp_trig_reset(
bwp_trig * BW_RESTRICT trig);
Resets trig to its initial state.
This function must be called at least once after each call to bwp_trig_set_sample_rate() and at least once before the first call bwp_trig_process() after a call to bwp_trig_set_sample_rate().
static inline void bwp_trig_process(
bwp_trig * BW_RESTRICT trig,
size_t n_samples);
Lets trig advance by n_samples samples.
This function must not be called before calling bwp_trig_reset().
static inline void bwp_trig_set_frequency(
bwp_trig * BW_RESTRICT trig,
float value);
Sets the triggering frequency value (Hz) in trig.
Valid range: [0.f, half the sample_rate that is/will be passed to bwp_trig_set_sample_rate()].
Default value: 0.f.
static inline size_t bwp_trig_get_samples_to_next(
bwp_trig * BW_RESTRICT trig);
Returns the number of samples before the next trigger event from trig, given its current settings. If the current triggering frequency in very small, it returns a value equivalent to SIZE_MAX.
static inline char bwp_trig_is_valid(
bwp_trig * BW_RESTRICT trig);
Tries to determine whether trig is valid and returns non-0 if it seems to be the case and 0 if it is certainly not. False positives are possible, false negatives are not.
trig must at least point to a readable memory block of size greater than or equal to that of bwp_trig.
class Trig {
public:
Trig();
void setSampleRate(
float sampleRate);
void reset();
void process(
size_t nSamples);
void setFrequency(
float value);
size_t getSamplesToNext();
...
}
bwp_trig_is_valid().bwp_trig_get_samples_to_next().