Bela
|
PulseIn Class Reference
Public Member Functions | |
PulseIn (BelaContext *context, unsigned int digitalInput, int direction=1) | |
void | init (BelaContext *context, unsigned int digitalInput, int direction=1) |
void | check (BelaContext *context) |
int | hasPulsed (BelaContext *context, int frame) |
Member Function Documentation
void PulseIn::init | ( | BelaContext * | context, |
unsigned int | digitalInput, | ||
int | direction = 1 |
||
) |
Initializes the PulseIn object. Also takes care of initializing the digital pin as input.
If the object has been created with the default constructor, the user will need to call init() before calling check() or hasPulsed().
- Parameters
-
digitalInput the digital input where to activate a pulse detector direction the direction of the pulse, can be 1 to detect positive pulses, e.g.:( 0 0 0 0 1 1 0 0 0 0 0) or -1 to detect negative pulses, e.g.: ( 1 1 1 1 0 0 1 1 1 1)
void PulseIn::check | ( | BelaContext * | context | ) |
Detects pulses.
The user does not need to call this method as long as they call hasPulsed() at least once per context. The rationale why we check() for pulses in a different method than hasPulsed() is because user might not query for hasPulsed() every sample, so we are safe so long as they call hasPulsed() or check() at least once per buffer. Also, results are cached (i.e.: we do not check() for pulses twice for the same context. context->audioFramesElapsed is used as an identifier.
|
inline |
Looks for the end of a pulse.
- Parameters
-
context the current BelaContext frame the frame at which to check if a pulse was detected.
- Returns
- the length of the pulse if a pulse ending was detected at sample n, zero otherwise.
The documentation for this class was generated from the following file:
Generated on Fri Nov 22 2024 06:27:57 for Bela by 1.8.11