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

Method process

src/extended/ClipNode.cpp:59–124  ·  view source on GitHub ↗

Processes the source to destination bus.

Source from the content-addressed store, hash-verified

57
58 // Processes the source to destination bus.
59 virtual void process(ContextRenderLock & r,
60 const lab::AudioBus * sourceBus, lab::AudioBus * destinationBus,
61 int framesToProcess) override
62 {
63 int srcChannels = (int) sourceBus->numberOfChannels();
64 int dstChannels = (int) destinationBus->numberOfChannels();
65 if (dstChannels != srcChannels)
66 {
67 _owner->output(0)->setNumberOfChannels(r, srcChannels);
68 destinationBus = _owner->output(0)->bus(r);
69 /// @todo no need to pass in the destination bus since owner is retained.
70 /// @todo perhaps flatten out AudioProcessor as well, as it's not adding anything particularly
71 }
72
73 if (!srcChannels)
74 {
75 destinationBus->zero();
76 return;
77 }
78
79 ClipNode::Mode clipMode = static_cast<ClipNode::Mode>(mode->valueUint32());
80
81 if (clipMode == ClipNode::TANH)
82 {
83 /// @fixme these values should be per sample, not per quantum
84 /// -or- they should be settings if they don't vary per sample
85 float outputGain = aVal->value();
86 float inputGain = bVal->value();
87
88 for (int channelIndex = 0; channelIndex < dstChannels; ++channelIndex)
89 {
90 int srcIndex = srcChannels < channelIndex ? srcChannels : channelIndex;
91 float const * source = sourceBus->channel(srcIndex)->data();
92 float * destination = destinationBus->channel(channelIndex)->mutableData();
93 for (int i = 0; i < framesToProcess; ++i)
94 {
95 *destination++ = outputGain * tanhf(inputGain * source[i]);
96 }
97 }
98 }
99 else
100 {
101 /// @fixme these values should be per sample, not per quantum
102 /// -or- they should be settings if they don't vary per sample
103 float minf = aVal->value();
104 float maxf = bVal->value();
105
106 for (int channelIndex = 0; channelIndex < dstChannels; ++channelIndex)
107 {
108 int srcIndex = srcChannels < channelIndex ? srcChannels : channelIndex;
109 float const * source = sourceBus->channel(srcIndex)->data();
110 float * destination = destinationBus->channel(channelIndex)->mutableData();
111 for (int i = 0; i < framesToProcess; ++i)
112 {
113 float d = source[i];
114
115 if (d < minf)
116 d = minf;

Callers

nothing calls this directly

Calls 10

outputMethod · 0.80
valueUint32Method · 0.80
channelMethod · 0.80
mutableDataMethod · 0.80
numberOfChannelsMethod · 0.45
setNumberOfChannelsMethod · 0.45
busMethod · 0.45
zeroMethod · 0.45
valueMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected