MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ processing_function()

void MayaFlux::Buffers::FinalLimiterProcessor::processing_function ( const std::shared_ptr< Buffer > &  buffer)
overridevirtual

Processes a buffer by enforcing boundary conditions.

Parameters
bufferBuffer to process

This method applies a non-linear boundary enforcement algorithm to ensure all values stay within the valid range (typically -1.0 to 1.0) before being transmitted to hardware interfaces, while preserving the perceptual characteristics of the original signal.

Implements MayaFlux::Buffers::BufferProcessor.

Definition at line 170 of file RootAudioBuffer.cpp.

171{
172 auto audio_buffer = std::dynamic_pointer_cast<AudioBuffer>(buffer);
173 if (!audio_buffer) {
174 return;
175 }
176
177 auto& data = audio_buffer->get_data();
178
179 constexpr double threshold = 0.95;
180 constexpr double knee = 0.1;
181
182 for (double& sample : data) {
183 const double abs_sample = std::abs(sample);
184
185 if (abs_sample > threshold) {
186 const double excess = abs_sample - threshold;
187 const double compressed_excess = std::tanh(excess / knee) * knee;
188 const double limited_abs = threshold + compressed_excess;
189
190 sample = (sample >= 0.0) ? limited_abs : -limited_abs;
191 }
192 }
193}
std::shared_ptr< NetworkGeometryBuffer > buffer
float threshold

References buffer, and threshold.