MCPcopy Create free account
hub / github.com/LabSound/LabSound / process

Method process

src/extended/SpectralMonitorNode.cpp:123–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121}
122
123void SpectralMonitorNode::process(ContextRenderLock &r, int bufferSize)
124{
125 // deal with the output in case the power monitor node is embedded in a signal chain for some reason.
126 // It's merely a pass through though.
127
128 AudioBus * outputBus = output(0)->bus(r);
129
130 if (!isInitialized() || !input(0)->isConnected())
131 {
132 if (outputBus)
133 outputBus->zero();
134 return;
135 }
136
137 AudioBus * bus = input(0)->bus(r);
138 bool isBusGood = bus && bus->numberOfChannels() > 0 && bus->channel(0)->length() >= bufferSize;
139 if (!isBusGood)
140 {
141 outputBus->zero();
142 return;
143 }
144
145 // specific to this node
146 {
147 std::vector<const float *> channels;
148 int numberOfChannels = bus->numberOfChannels();
149 for (int c = 0; c < numberOfChannels; ++c)
150 channels.push_back(bus->channel(c)->data());
151
152 int sz = internalNode->windowSize->valueUint32();
153
154 // if the fft is smaller than the quantum, just grab a chunk
155 if (sz < bufferSize)
156 {
157 internalNode->cursor = 0;
158 bufferSize = internalNode->windowSize->valueUint32();
159 }
160
161 // if the quantum overlaps the end of the window, just fill up the buffer
162 if (internalNode->cursor + bufferSize > sz)
163 bufferSize = sz - internalNode->cursor;
164
165 {
166 std::lock_guard<std::recursive_mutex> lock(internalNode->magMutex);
167
168 internalNode->buffer.resize(sz);
169
170 for (int i = 0; i < bufferSize; ++i)
171 {
172 internalNode->buffer[i + internalNode->cursor] = 0;
173 }
174
175 for (int c = 0; c < numberOfChannels; ++c)
176 {
177 for (int i = 0; i < bufferSize; ++i)
178 {
179 float p = channels[c][i];
180 internalNode->buffer[i + internalNode->cursor] += p;

Callers

nothing calls this directly

Calls 10

channelMethod · 0.80
valueUint32Method · 0.80
resizeMethod · 0.80
busMethod · 0.45
isConnectedMethod · 0.45
zeroMethod · 0.45
numberOfChannelsMethod · 0.45
lengthMethod · 0.45
dataMethod · 0.45
copyFromMethod · 0.45

Tested by

no test coverage detected