comparison include/PulseIn.h @ 311:493a07f6ec09 prerelease

Renamed BelaContext->audioSampleCount to BelaContext->audioFramesElapsed for consistency of terminology
author andrewm
date Fri, 27 May 2016 18:37:51 +0100
parents e4392164b458
children
comparison
equal deleted inserted replaced
310:02c4ca0e3718 311:493a07f6ec09
44 * The user does not need to call this method as long as they call hasPulsed() at least once per context. 44 * The user does not need to call this method as long as they call hasPulsed() at least once per context.
45 * The rationale why we check() for pulses in a different method 45 * The rationale why we check() for pulses in a different method
46 * than hasPulsed() is because user might not query for hasPulsed() every sample, 46 * than hasPulsed() is because user might not query for hasPulsed() every sample,
47 * so we are safe so long as they call hasPulsed() or check() at least once per buffer. 47 * so we are safe so long as they call hasPulsed() or check() at least once per buffer.
48 * Also, results are cached (i.e.: we do not check() for pulses twice for the same context. 48 * Also, results are cached (i.e.: we do not check() for pulses twice for the same context.
49 * context->audioSampleCount is used as an identifier. 49 * context->audioFramesElapsed is used as an identifier.
50 */ 50 */
51 void check(BelaContext* context); 51 void check(BelaContext* context);
52 52
53 /** 53 /**
54 * Looks for the end of a pulse. 54 * Looks for the end of a pulse.
56 * @param context the current BelaContext 56 * @param context the current BelaContext
57 * @param frame the frame at which to check if a pulse was detected. 57 * @param frame the frame at which to check if a pulse was detected.
58 * @return the length of the pulse if a pulse ending was detected at sample n, zero otherwise. 58 * @return the length of the pulse if a pulse ending was detected at sample n, zero otherwise.
59 */ 59 */
60 int hasPulsed(BelaContext* context, int frame){//let's leave this in PulseIn.h to allow the compiler to optimize out the call. 60 int hasPulsed(BelaContext* context, int frame){//let's leave this in PulseIn.h to allow the compiler to optimize out the call.
61 if(_lastContext != context->audioSampleCount){ // check for pulses in the whole context and cache the result 61 if(_lastContext != context->audioFramesElapsed){ // check for pulses in the whole context and cache the result
62 check(context); 62 check(context);
63 } 63 }
64 return _array[frame]; 64 return _array[frame];
65 } 65 }
66 virtual ~PulseIn(); 66 virtual ~PulseIn();