Skip to content

Instantly share code, notes, and snippets.

@mpuz
Created March 29, 2017 17:28
Show Gist options
  • Save mpuz/6c99ab8bab30d567a04a7cef0265231c to your computer and use it in GitHub Desktop.
Save mpuz/6c99ab8bab30d567a04a7cef0265231c to your computer and use it in GitHub Desktop.
Android, Java: Attenuate audio in decibels
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