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
import android.content.Context | |
import android.content.SharedPreferences | |
import org.json.JSONObject | |
object AppSettings { | |
private val PREF_NAME = "settings_pref" | |
// Settings | |
val EQUALIZER_ENABLED = "settings_eq_enabled" |
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
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:background="@color/colorPrimary" | |
android:orientation="vertical" | |
tools:context="midien.kheldiente.equalizer.MainActivity" | |
> |
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
import android.media.MediaPlayer | |
import android.support.v7.app.AppCompatActivity | |
import android.os.Bundle | |
import android.media.audiofx.Equalizer | |
import android.support.v7.widget.LinearLayoutManager | |
import android.util.Log | |
import android.widget.CompoundButton | |
import kotlinx.android.synthetic.main.activity_main.* | |
import kotlinx.android.synthetic.main.layout_switch.* | |
import midien.kheldiente.equalizer.adapter.PresetAdapter |
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
override fun onCheckedChanged(compoundButton: CompoundButton?, checked: Boolean) { | |
enableEqualizer(checked) | |
presetAdapter?.enableAll(checked) // Update color state of list | |
} | |
private fun enableEqualizer(enable: Boolean) { | |
equalizer?.enabled = enable | |
} |
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
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:background="@color/colorPrimary" | |
android:paddingLeft="15dp" | |
android:paddingTop="15dp" | |
android:paddingRight="10dp" |
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
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.constraint.ConstraintLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:background="@color/colorPrimary" | |
android:padding="15dp" | |
> |
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
import android.content.Context | |
import android.support.v7.widget.RecyclerView | |
import android.util.Log | |
import android.view.LayoutInflater | |
import android.view.View | |
import android.view.ViewGroup | |
import android.widget.CheckBox | |
import android.widget.CompoundButton | |
import android.widget.TextView | |
import kotlinx.android.synthetic.main.item_preset.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 val presetList = ArrayList<Preset>(0) | |
private var presetAdapter: PresetAdapter? = null | |
private fun setupPresetList() { | |
presetAdapter = PresetAdapter(this) { position: Int, preset: Preset -> | |
setSelectedPreset(position, preset) | |
} | |
presetAdapter?.enabled = eqEnabled | |
presetAdapter?.currentPreset = eqPreset |
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
override fun onBandLevelChanged(bandId: Int, value: Int, fromUser: Boolean) { | |
val lowestBandLevel = equalizer?.bandLevelRange?.get(0) | |
val bandLevel = (value.plus(lowestBandLevel!!)).toShort() | |
// Manipulate equalizer band level | |
setBandLevel(bandId.toShort(), bandLevel) | |
... Cached current value of band | |
} |
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()) } |
NewerOlder