package com.radiola.ui.equalizer

import androidx.lifecycle.ViewModel
import com.radiola.service.AudioEffectsController
import com.radiola.service.EqState
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.StateFlow
import javax.inject.Inject

@HiltViewModel
class EqualizerViewModel @Inject constructor(
    private val audioEffects: AudioEffectsController
) : ViewModel() {

    val state: StateFlow<EqState> = audioEffects.state

    fun setEnabled(on: Boolean) = audioEffects.setEnabled(on)
    fun selectPreset(index: Int) = audioEffects.selectPreset(index)
    fun setBand(index: Int, levelMb: Int) = audioEffects.setBand(index, levelMb)
    fun setBass(value: Int) = audioEffects.setBass(value)
    fun setVirtualizer(value: Int) = audioEffects.setVirtualizer(value)
    fun setLoudness(value: Int) = audioEffects.setLoudness(value)
    fun commit() = audioEffects.commit()
}
