mirror of
https://github.com/damp11113/EasyMPX.git
synced 2025-04-27 06:28:10 +00:00
11 lines
462 B
C++
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;
|
|
}
|
|
}
|
|
} |