2022-11-02 19:25:22 +00:00
|
|
|
import { preferenceStore as preferences } from '@/stores'
|
|
|
|
import { equalizerPresets as presets } from '@/config'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
|
|
|
export const equalizerStore = {
|
2022-06-10 10:47:46 +00:00
|
|
|
getPresetById (id: number) {
|
2022-11-02 19:25:22 +00:00
|
|
|
return presets.find(preset => preset.id === id)
|
2022-04-15 14:24:30 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the current equalizer config.
|
|
|
|
*/
|
2022-11-02 19:25:22 +00:00
|
|
|
getConfig () {
|
|
|
|
if (preferences.equalizer.id === -1) {
|
|
|
|
return preferences.equalizer
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// If the user chose a preset (instead of customizing one), just return it.
|
2022-11-02 19:25:22 +00:00
|
|
|
return this.getPresetById(preferences.equalizer.id) || presets[0]
|
2022-04-15 14:24:30 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Save the current equalizer config.
|
|
|
|
*/
|
2022-11-02 19:25:22 +00:00
|
|
|
saveConfig (id: number, preamp: number, gains: number[]) {
|
|
|
|
const preset = this.getPresetById(id)
|
|
|
|
|
|
|
|
preferences.equalizer = preset || {
|
2022-04-15 14:24:30 +00:00
|
|
|
preamp,
|
2022-11-02 19:25:22 +00:00
|
|
|
gains,
|
|
|
|
id: -1,
|
|
|
|
name: 'Custom'
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|