Last active
May 28, 2018 10:04
-
-
Save kheldiente/3fb66d7aab74931eb05e5f2bfb4833b7 to your computer and use it in GitHub Desktop.
Set equalizer class values to equalizer view
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
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