EasyMPX/FMPX generator/PaProcessFunc.cpp
2024-01-07 22:16:45 +07:00

11 lines
462 B
C++

void audioCompressor(float* audioBuffer, int bufferSize, float threshold, float ratio) {
for (int i = 0; i < bufferSize; ++i) {
// Apply compression algorithm to each sample
if (audioBuffer[i] > threshold) {
audioBuffer[i] = threshold + (audioBuffer[i] - threshold) / ratio;
}
else if (audioBuffer[i] < -threshold) {
audioBuffer[i] = -threshold + (audioBuffer[i] + threshold) / ratio;
}
}
}