aboutsummaryrefslogtreecommitdiffstats
path: root/templates/5_fir_differentiator.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2022-01-09 12:28:19 -0500
committerClyne Sullivan <clyne@bitgloo.com>2022-01-09 12:28:19 -0500
commit1b176cf6cd75c8031a140961655cdd3c16589a68 (patch)
tree8415664e40a9a768d8c3a35fd81252bfdefb72f9 /templates/5_fir_differentiator.cpp
parentfde531e7c44ea917f745a9f800178fbe83fa19b5 (diff)
small changes; sig gen square(), triangle(), pulse()
Diffstat (limited to 'templates/5_fir_differentiator.cpp')
-rw-r--r--templates/5_fir_differentiator.cpp30
1 files changed, 0 insertions, 30 deletions
diff --git a/templates/5_fir_differentiator.cpp b/templates/5_fir_differentiator.cpp
deleted file mode 100644
index 72415c6..0000000
--- a/templates/5_fir_differentiator.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * 5_fir_differentiator.cpp
- * Written by Clyne Sullivan.
- *
- * Does an FIR differentiation on the incoming signal, so that the output is representative of the
- * rate of change of the input.
- * A scaling factor is applied so that the output's form is more clearly visible.
- */
-
-Sample *process_data(Samples samples)
-{
- constexpr int scaling_factor = 4;
- static Sample output[samples.size()];
- static Sample prev = 2048;
-
- // Compute the first output value using the saved sample.
- output[0] = 2048 + ((samples[0] - prev) * scaling_factor);
-
- for (unsigned int i = 1; i < samples.size(); i++) {
- // Take the rate of change and scale it.
- // 2048 is added as the output should be centered in the voltage range.
- output[i] = 2048 + ((samples[i] - samples[i - 1]) * scaling_factor);
- }
-
- // Save the last sample for the next iteration.
- prev = samples[samples.size() - 1];
-
- return output;
-}
-