Voss Connection Detection  1
Detect a connector click using realtime code on Bela hardware
buffer.cpp
Go to the documentation of this file.
1 #include "buffer.h"
2 #include "config.h"
3 #include "filter.h"
4 #include <iostream>
5 #include <math.h>
6 
7 FilteredDataBuffer::FilteredDataBuffer(const float &fs, bool half_offset) {
8  if (half_offset) {
9  timeStamp = 1;
10  write_ptr = BLOCKSIZE / 2;
11  } else {
12  timeStamp++;
13  }
14 
15  /* Set all raw data buffers to 0, not really necessary */
16  for (us i = 0; i < NUMBER_FILTERED_CHANNELS; i++) {
17  data[i].fill(0.0f);
18  }
19 }
20 
22 
24  for (us i = 0; i < samples.size(); i++) {
25  data[i][write_ptr] = samples[i];
26  }
27  write_ptr++;
28 }
29 bool FilteredDataBuffer::full() const { return (write_ptr == BLOCKSIZE); }
31  write_ptr = 0;
32 }
filter.h
FilteredDataBuffer::addFilteredFrame
void addFilteredFrame(const FilteredFrame &)
Addd a new set of samples to the buffers.
Definition: buffer.cpp:23
FilteredDataBuffer::~FilteredDataBuffer
~FilteredDataBuffer()
Definition: buffer.cpp:21
FilteredDataBuffer::FilteredDataBuffer
FilteredDataBuffer(const float &fs, bool half_offset=false)
Initialize a RawDataBuffer, which is filled by the main loop.
Definition: buffer.cpp:7
FilteredDataBuffer::clear
void clear()
Clear the buffer, i.e. set the write pointer back to 0.
Definition: buffer.cpp:30
NUMBER_FILTERED_CHANNELS
const us NUMBER_FILTERED_CHANNELS
Definition: filter.h:95
FilteredFrame
array< float, NUMBER_FILTERED_CHANNELS > FilteredFrame
An array containing data with length corresponding to a single processed frame. Its length correspond...
Definition: filter.h:102
buffer.h
FilteredDataBuffer::data
FilteredData data
Raw sample buffers containing the data.
Definition: buffer.h:62
FilteredDataBuffer::full
bool full() const
Check if buffer is full. A full buffer should be clear() - ed afterwards (prior to extracting the sta...
Definition: buffer.cpp:29
BLOCKSIZE
const us BLOCKSIZE
The size of a buffer in a block. Should be an integer number of samples, and preferrably a integer po...
Definition: config.h:105
us
unsigned int us
Used to much to not abbreviate.
Definition: config.h:38
config.h
Configuration parameters for connection detection.
FilteredDataBuffer::timeStamp
us timeStamp
Storage for statistics data.
Definition: buffer.h:48