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

Method process

src/internal/src/DynamicsCompressor.cpp:106–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106void DynamicsCompressor::process(ContextRenderLock & r, const AudioBus * sourceBus, AudioBus * destinationBus, int bufferSize, int offset, int count)
107{
108 int numberOfDestChannels = destinationBus->numberOfChannels();
109 int numberOfSourceChannels = sourceBus->numberOfChannels();
110
111 if (!numberOfSourceChannels)
112 {
113 destinationBus->zero();
114 return;
115 }
116
117 if (numberOfDestChannels != m_numberOfChannels)
118 {
119 setNumberOfChannels(numberOfSourceChannels);
120 numberOfDestChannels = numberOfSourceChannels;
121 for (int i = 0; i < numberOfDestChannels; ++i)
122 {
123 m_sourceChannels[i] = sourceBus->channel(i)->data();
124 m_destinationChannels[i] = destinationBus->channel(i)->mutableData();
125 }
126 }
127
128 for (int i = 0; i < numberOfDestChannels; ++i)
129 {
130 m_sourceChannels[i] = sourceBus->channel(i)->data();
131 m_destinationChannels[i] = destinationBus->channel(i)->mutableData();
132 }
133
134 float filterStageGain = parameterValue(ParamFilterStageGain);
135 float filterStageRatio = parameterValue(ParamFilterStageRatio);
136 float anchor = parameterValue(ParamFilterAnchor);
137
138 if (filterStageGain != m_lastFilterStageGain || filterStageRatio != m_lastFilterStageRatio || anchor != m_lastAnchor)
139 {
140 m_lastFilterStageGain = filterStageGain;
141 m_lastFilterStageRatio = filterStageRatio;
142 m_lastAnchor = anchor;
143
144 setEmphasisParameters(filterStageGain, anchor, filterStageRatio);
145 }
146
147 // Apply pre-emphasis filter.
148 // Note that the final three stages are computed in-place in the destination buffer.
149 for (int i = 0; i < numberOfDestChannels; ++i)
150 {
151 const float * sourceData = m_sourceChannels[i];
152 float * destinationData = m_destinationChannels[i];
153 ZeroPole * preFilters = m_preFilterPacks[i]->filters;
154
155 preFilters[0].process(sourceData, destinationData, bufferSize, offset, count);
156 preFilters[1].process(destinationData, destinationData, bufferSize, offset, count);
157 preFilters[2].process(destinationData, destinationData, bufferSize, offset, count);
158 preFilters[3].process(destinationData, destinationData, bufferSize, offset, count);
159 }
160
161 float dbThreshold = parameterValue(ParamThreshold);
162 float dbKnee = parameterValue(ParamKnee);
163 float ratio = parameterValue(ParamRatio);

Callers

nothing calls this directly

Calls 7

channelMethod · 0.80
mutableDataMethod · 0.80
getMethod · 0.80
meteringGainMethod · 0.80
numberOfChannelsMethod · 0.45
zeroMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected