Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
1 #pragma once
3 #include <Bela.h>
4 #include <vector>
12 class PulseIn {
13 private:
14  std::vector<int> _array;
15  int _pulseOnState;
16  int _digitalInput;
17  bool _pulseIsOn;
18  uint64_t _pulseStart;
19  uint64_t _lastContext;
20 public:
21  PulseIn(){
22  _digitalInput = -1;
23  };
34  PulseIn(BelaContext* context, unsigned int digitalInput, int direction=1){
35  setup(context, digitalInput, direction);
36  };
49  void setup(BelaContext* context, unsigned int digitalInput, int direction=1);
61  void check(BelaContext* context);
70  int hasPulsed(BelaContext* context, unsigned int frame){//let's leave this in PulseIn.h to allow the compiler to optimize out the call.
71  if(_lastContext != context->audioFramesElapsed){ // check for pulses in the whole context and cache the result
72  check(context);
73  }
74  return _array[frame];
75  }
76  void cleanup();
77  virtual ~PulseIn();
78 };
void setup(BelaContext *context, unsigned int digitalInput, int direction=1)
Definition: PulseIn.cpp:3
int hasPulsed(BelaContext *context, unsigned int frame)
Definition: PulseIn.h:70
Structure holding audio and sensor settings and pointers to I/O data buffers.
Definition: Bela.h:229
A class to measure the duration of a pulse on a digital pin.
Definition: PulseIn.h:12
void check(BelaContext *context)
Definition: PulseIn.cpp:12
const uint64_t audioFramesElapsed
Number of elapsed audio frames since the start of rendering.
Definition: Bela.h:377
Main Bela public API.
PulseIn(BelaContext *context, unsigned int digitalInput, int direction=1)
Definition: PulseIn.h:34