Skip to content

Instantly share code, notes, and snippets.

@kheldiente
Last active May 28, 2018 10:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kheldiente/3fb66d7aab74931eb05e5f2bfb4833b7 to your computer and use it in GitHub Desktop.
Save kheldiente/3fb66d7aab74931eb05e5f2bfb4833b7 to your computer and use it in GitHub Desktop.
Set equalizer class values to equalizer view
private fun setupEqualizerView() {
val numberOfBands = equalizer?.numberOfBands
val lowestBandLevel = equalizer?.bandLevelRange?.get(0)
val highestBandLevel = equalizer?.bandLevelRange?.get(1)
val max = highestBandLevel?.minus(lowestBandLevel!!)!!
var bands = ArrayList<Integer>(0)
// Get center frequency for each band
(0 until numberOfBands!!)
.map { equalizer?.getCenterFreq(it.toShort()) }
.mapTo(bands) { Integer(it?.div(1000)!!) }
view_eq.setBands(bands)
view_eq.setMax(max)
view_eq.setBandListener(this) // Activity should directly implement the listener
view_eq.draw() // Force draw with new equalizer settings
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment