bwp_trig

Periodic trigger.

Examples

We can privately hand you one or more example plugins if you are interested.

Contact us

API

Module type: Utility

bwp_trig

typedef struct bwp_trig bwp_trig;

Trigger object.

bwp_trig_init()

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.

bwp_trig_set_sample_rate()

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().

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().

bwp_trig_process()

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().

bwp_trig_set_frequency()

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.

bwp_trig_get_samples_to_next()

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, given the current settings. If the current triggering frequency in very small, it returns UINT64_MAX.

bwp_trig_is_valid()

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_note_track_is_valid.

C++ wrapper

BrickworksPro::Trig
class Trig {
public:
	Trig();

	void setSampleRate(
		float sampleRate);

	void reset();

	void process(
		size_t nSamples);

	void setFrequency(
		float value);

	size_t getSamplesToNext();
...
}

Changelog

  • Version 1.0.0:
    • First release.