aboutsummaryrefslogtreecommitdiffstats
path: root/gui/templates/2_convolve_overlap_save.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2022-04-30 08:41:56 -0400
committerClyne Sullivan <clyne@bitgloo.com>2022-04-30 08:42:45 -0400
commite164629b3839eee0fda0be0e0a9842e78cf02f2b (patch)
treeb72b58665b85a104e5b953af45f00579341b2802 /gui/templates/2_convolve_overlap_save.cpp
parent162dd6de8a0d883962b0b1475f47cbb08e0958d4 (diff)
parent3dd57491b1e81a9d93054eff19ca0e6c65c85b9b (diff)
merge in branch devel
Diffstat (limited to 'gui/templates/2_convolve_overlap_save.cpp')
-rw-r--r--gui/templates/2_convolve_overlap_save.cpp47
1 files changed, 0 insertions, 47 deletions
diff --git a/gui/templates/2_convolve_overlap_save.cpp b/gui/templates/2_convolve_overlap_save.cpp
deleted file mode 100644
index 1387d7f..0000000
--- a/gui/templates/2_convolve_overlap_save.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * 2_convolve_overlap_save.cpp
- * Written by Clyne Sullivan.
- *
- * This convolution examples takes an overlap-save approach, where samples from the previous run
- * are saved so that the overall operation is not interrupted (i.e. the observed output will
- * transition smoothly between processed "chunks").
- *
- * Note that there are still improvements that can be made to the code; for example, notice every
- * spot where an integer/float conversion is necessary. Operations like these may slow down the
- * computation.
- */
-
-adcsample_t *process_data(adcsample_t *samples, unsigned int size)
-{
- static adcsample_t buffer[SIZE];
-
- constexpr unsigned int filter_size = 3;
- float filter[filter_size] = {
- 0.3333, 0.3333, 0.3333
- };
-
- // Keep a buffer of extra samples for overlap-save
- static adcsample_t prev[filter_size];
-
- for (int n = 0; n < size; n++) {
- buffer[n] = 0;
-
- for (int k = 0; k < filter_size; k++) {
- int i = n - (filter_size - 1) + k;
-
- // If i is >= 0, access current sample buffer.
- // If i is < 0, provide the previous samples from the 'prev' buffer
- if (i >= 0)
- buffer[n] += samples[i] * filter[k];
- else
- buffer[n] += prev[filter_size - 1 + i] * filter[k];
- }
- }
-
- // Save samples for the next convolution run
- for (int i = 0; i < filter_size; i++)
- prev[i] = samples[size - filter_size + i];
-
- return buffer;
-}
-