-
Notifications
You must be signed in to change notification settings - Fork 0
/
mixernode.h
106 lines (82 loc) · 2.14 KB
/
mixernode.h
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
#pragma once
#include "nodegroup.h"
namespace En
{
class MixerNode: public Node
{
Q_OBJECT
QList<Node*> m_inputs;
//QVector<QVector<float> > m_outputChannelBuffers;
public:
class Factory: public Node::Factory
{
public:
virtual Node* create(Host*)
{
return new MixerNode;
}
};
MixerNode()
{
m_outputChannelData << ChannelData("Mix L", blockSize());
m_outputChannelData << ChannelData("Mix R", blockSize());
}
void addInput(Node* node)
{
m_inputs << node;
inputsChanged();
}
void removeInput(int i)
{
m_inputs.removeAt(i);
inputsChanged();
}
void removeInput(Node* node)
{
// definite bug if we allow more than one connection from the same node!
m_inputs.removeOne(node);
inputsChanged();
}
QList<Node*> inputs() const
{
return m_inputs;
}
void inputsChanged() {
m_inputChannelData.clear();
for (unsigned i = 0; i < numInputs(); ++i) {
for (int c = 0; c < 2; ++c) {
m_inputChannelData << ChannelData(QString("In %1 %2").arg(QString::number(i), QString(c == 0 ? "L" : "R")), blockSize());
}
}
nodeGroup()->emitNodeInputsChanged(this);
}
unsigned numInputs() const {
return m_inputs.size();
}
Node* input(int i) const {
return m_inputs[i];
}
virtual void accept(Visitor& visitor) {
visitor.visit(this);
}
virtual QString displayLabel() const {
return tr("Mixer");
}
virtual void processAudio() {
// zero the result
for (int c = 0; c < 2; ++c) {
for (int s = 0; s < blockSize(); ++s) {
outputChannelBuffer(c)[s] = 0;
}
}
// accumulate
for (unsigned i = 0; i < numInputs(); ++i) {
for (int c = 0; c < 2; ++c) {
for (int s = 0; s < blockSize(); ++s) {
outputChannelBuffer(c)[s] += input(i)->outputChannelBufferConst(c)[s];
}
}
}
}
};
} // namespace En