Created
March 29, 2017 17:28
-
-
Save mpuz/6c99ab8bab30d567a04a7cef0265231c to your computer and use it in GitHub Desktop.
Android, Java: Attenuate audio in decibels
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void AttenuateAudio(float[] data, int decibels) | |
{ | |
float gain = (float)Math.Pow(10, (double)-decibels / 20.0); | |
for (int i = 0; i < data.Length; i++) | |
{ | |
data[i] *= gain; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment