Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
BelaContextSplitter.h
1 #pragma once
2 
3 #include <Bela.h>
4 #include <PRU.h> // InternalBelaContext
5 #include <vector>
7 public:
8  BelaContextSplitter(unsigned int in = 1, unsigned int out = 1, const BelaContext* context = nullptr)
9  {
10  setup(in, out, context);
11  }
12  ~BelaContextSplitter(){cleanup();}
30  int setup(unsigned int in, unsigned int out, const BelaContext* context);
37  int push(const BelaContext* inContext);
44  BelaContext* pop();
45  void cleanup();
52 
53  static bool contextEqual(const InternalBelaContext* ctx1, const InternalBelaContext* ctx2);
57  static void contextCopy(const InternalBelaContext* src, InternalBelaContext* dst);
63  static void contextCopyData(const InternalBelaContext* src, InternalBelaContext* dst);
64  static void contextAllocate(InternalBelaContext* ctx);
65  static bool test();
66 private:
67  static void resizeContext(InternalBelaContext& context, size_t in, size_t out);
68  static void stackFrames(bool interleaved, const float* source, float* dest, unsigned int channels, unsigned int sourceStartFrame, unsigned int destStartFrame, unsigned int sourceFrames, unsigned int destFrames);
69  std::vector<InternalBelaContext> outContexts;
70  unsigned int inCount;
71  unsigned int inLength;
72  unsigned int outCount;
73  unsigned int outLength;
74 
75  typedef enum {
76  kIn,
77  kOut,
78  } direction_t;
79  typedef enum {
80  kAudioIn,
81  kAudioOut,
82  kAnalogIn,
83  kAnalogOut,
84  kDigital,
85  kNumStreams,
86  } stream_t;
87  struct streamOffsets {
88  unsigned int frames;
89  unsigned int channels;
90  unsigned int data;
91  };
92  uint32_t getFramesForStream(const struct streamOffsets& o, const InternalBelaContext* context);
93  uint32_t getChannelsForStream(const struct streamOffsets& o, const InternalBelaContext* context);
94  float* getDataForStream(const struct streamOffsets& o, const InternalBelaContext* context);
95  struct streamOffsets offsets[kNumStreams];
96  direction_t direction;
97 };
98 
BelaContext * getContext()
Definition: PRU.h:16
static void contextCopyData(const InternalBelaContext *src, InternalBelaContext *dst)
static void contextCopy(const InternalBelaContext *src, InternalBelaContext *dst)
int push(const BelaContext *inContext)
Structure holding audio and sensor settings and pointers to I/O data buffers.
Definition: Bela.h:231
Definition: BelaContextSplitter.h:6
int setup(unsigned int in, unsigned int out, const BelaContext *context)
Main Bela public API.
BelaContext * pop()