-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXDDSP.cpp
More file actions
143 lines (95 loc) · 2.97 KB
/
Copy pathXDDSP.cpp
File metadata and controls
143 lines (95 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//
// XDDSP.cpp
// XDDSPTestingHarness
//
// Created by Adam Jackson on 1/6/2022.
//
/*
This file will not compile. It simply contains useful code templates which can be copy-pasted into the library to extend it
*/
// Input types are specified as template arguments
// Input types go first, because they never have defaults
// Don't forget to copy the input type names into the Component template arguments
template <typename SignalIn>
class NewComponent : public Component<NewComponent<SignalIn>>
{
// Private data members here
public:
static constexpr int Count = SignalIn::Count;
// Specify your inputs as public members here
SignalIn signalIn;
// Specify your outputs like this
Output<Count> signalOut;
// Include a definition for each input in the constructor
NewComponent(Parameters &p, SignalIn _signalIn) :
signalIn(_signalIn),
signalOut(p)
{}
// This function is responsible for clearing the output buffers to a default state when
// the component is disabled.
void reset()
{
signalOut.reset();
}
// startProcess prepares the component for processing one block and returns the step
// size. By default, it returns the entire sampleCount as one big step.
// int startProcess(int startPoint, int sampleCount)
// { return std::min(sampleCount, StepSize); }
// stepProcess is called repeatedly with the start point incremented by step size
void stepProcess(int startPoint, int sampleCount)
{
for (int c = 0; c < Count; ++c)
{
for (int i = startPoint, s = sampleCount; s--; ++i)
{
// DSP work done here
}
}
}
// triggerProcess is called once if 'samplesToNextTrigger' reaches zero
// components can use 'setNextTrigger' to set a trigger point
// void triggerprocess(int triggerPoint)
// {}
// finishProcess is called after the block has been processed
// void finishProcess()
// {}
};
/*
Plugin DSP Component Template
Here is a neat little template for a component to encapsulate an entire DSP network
*/
class PluginDSP : public Component<PluginDSP>
{
// Private data members here
public:
static constexpr int Count = 2;
PluginInput<Count> signalIn;
Output<Count> signalOut;
PluginDSP(Parameters &p) :
signalOut(p)
{}
// This function is responsible for clearing the output buffers to a default state when
// the component is disabled.
void reset()
{
signalOut.reset();
}
// startProcess prepares the component for processing one block and returns the step
// size. By default, it returns the entire sampleCount as one big step.
// int startProcess(int startPoint, int sampleCount)
// { return std::min(sampleCount, StepSize); }
// stepProcess is called repeatedly with the start point incremented by step size
void stepProcess(int startPoint, int sampleCount)
{
for (int c = 0; c < Count; ++c)
{
for (int i = startPoint, s = sampleCount; s--; ++i)
{
// DSP work done here
}
}
}
// finishProcess is called after the block has been processed
// void finishProcess()
// {}
};