VCV Rack API v2
Loading...
Searching...
No Matches
minblep.hpp
Go to the documentation of this file.
1#pragma once
2#include <dsp/common.hpp>
3
4
5namespace rack {
6namespace dsp {
7
8
15void minBlepImpulse(int z, int o, float* output);
16
17
18template <int Z, int O, typename T = float>
20 T buf[2 * Z] = {};
21 int pos = 0;
22 float impulse[2 * Z * O + 1];
23
26 impulse[2 * Z * O] = 1.f;
27 }
28
30 void insertDiscontinuity(float p, T x) {
31 if (!(-1 < p && p <= 0))
32 return;
33 for (int j = 0; j < 2 * Z; j++) {
34 float minBlepIndex = ((float)j - p) * O;
35 int index = (pos + j) % (2 * Z);
36 buf[index] += x * (-1.f + math::interpolateLinear(impulse, minBlepIndex));
37 }
38 }
39
40 T process() {
41 T v = buf[pos];
42 buf[pos] = T(0);
43 pos = (pos + 1) % (2 * Z);
44 return v;
45 }
46};
47
48
49} // namespace dsp
50} // namespace rack
void minBlepImpulse(int z, int o, float *output)
Computes the minimum-phase bandlimited step (MinBLEP) z: number of zero-crossings o: oversample facto...
float interpolateLinear(const float *p, float x)
Linearly interpolates an array p with index x.
Definition math.hpp:164
Root namespace for the Rack API.
Definition AudioDisplay.hpp:9
Definition minblep.hpp:19
T buf[2 *Z]
Definition minblep.hpp:20
MinBlepGenerator()
Definition minblep.hpp:24
T process()
Definition minblep.hpp:40
float impulse[2 *Z *O+1]
Definition minblep.hpp:22
int pos
Definition minblep.hpp:21
void insertDiscontinuity(float p, T x)
Places a discontinuity with magnitude x at -1 < p <= 0 relative to the current frame.
Definition minblep.hpp:30