koel/resources/assets/js/stores/equalizer.js

121 lines
2.4 KiB
JavaScript
Raw Normal View History

2016-06-28 06:39:42 +00:00
import { find } from 'lodash';
2016-06-25 10:15:57 +00:00
import { preferenceStore } from '.';
2016-01-19 11:00:23 +00:00
2016-06-25 10:15:57 +00:00
export const equalizerStore = {
2016-06-25 16:05:24 +00:00
presets: [
{
2016-06-28 06:39:42 +00:00
id: 0,
2016-06-25 16:05:24 +00:00
name: 'Default',
preamp: 0,
gains: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
},
{
2016-06-28 06:39:42 +00:00
id: 1,
2016-06-25 16:05:24 +00:00
name: 'Classical',
preamp: -1,
gains: [-1, -1, -1, -1, -1, -1, -7, -7, -7, -9],
},
{
2016-06-28 06:39:42 +00:00
id: 2,
2016-06-25 16:05:24 +00:00
name: 'Club',
preamp: -6.7,
gains: [-1, -1, 8, 5, 5, 5, 3, -1, -1, -1],
},
{
2016-06-28 06:39:42 +00:00
id: 3,
2016-06-25 16:05:24 +00:00
name: 'Dance',
preamp: -4.3,
gains: [9, 7, 2, -1, -1, -5, -7, -7, -1, -1],
},
{
2016-06-28 06:39:42 +00:00
id: 4,
2016-06-25 16:05:24 +00:00
name: 'Full Bass',
preamp: -7.2,
gains: [-8, 9, 9, 5, 1, -4, -8, -10, -11, -11]
},
{
2016-06-28 06:39:42 +00:00
id: 5,
2016-06-25 16:05:24 +00:00
name: 'Full Treble',
preamp: -12,
gains: [-9, -9, -9, -4, 2, 11, 16, 16, 16, 16]
},
{
2016-06-28 06:39:42 +00:00
id: 6,
2016-06-25 16:05:24 +00:00
name: 'Headphone',
preamp: -8,
gains: [4, 11, 5, -3, -2, 1, 4, 9, 12, 14]
},
{
2016-06-28 06:39:42 +00:00
id: 7,
2016-06-25 16:05:24 +00:00
name: 'Large Hall',
preamp: -7.2,
gains: [10, 10, 5, 5, -1, -4, -4, -4, -1, -1],
},
{
2016-06-28 06:39:42 +00:00
id: 8,
2016-06-25 16:05:24 +00:00
name: 'Live',
preamp: -5.3,
gains: [-4, -1, 4, 5, 5, 5, 4, 2, 2, 2],
},
{
2016-06-28 06:39:42 +00:00
id: 9,
2016-06-25 16:05:24 +00:00
name: 'Pop',
preamp: -6.2,
gains: [-1, 4, 7, 8, 5, -1, -2, -2, -1, -1],
},
{
2016-06-28 06:39:42 +00:00
id: 10,
2016-06-25 16:05:24 +00:00
name: 'Reggae',
preamp: -8.2,
gains: [-1, -1, -1, -5, -1, 6, 6, -1, -1, -1],
},
{
2016-06-28 06:39:42 +00:00
id: 11,
2016-06-25 16:05:24 +00:00
name: 'Rock',
preamp: -10,
gains: [8, 4, -5, -8, -3, 4, 8, 11, 11, 11],
},
{
2016-06-28 06:39:42 +00:00
id: 12,
2016-06-25 16:05:24 +00:00
name: 'Soft Rock',
preamp: -5.3,
gains: [4, 4, 2, -1, -4, -5, -3, -1, 2, 8],
},
{
2016-06-28 06:39:42 +00:00
id: 13,
2016-06-25 16:05:24 +00:00
name: 'Techno',
preamp: -7.7,
gains: [8, 5, -1, -5, -4, -1, 8, 9, 9, 8],
},
],
2016-01-19 11:00:23 +00:00
2016-06-28 06:39:42 +00:00
getPresetById(id) {
return find(this.presets, { id });
},
2016-06-25 16:05:24 +00:00
/**
* Get the current equalizer config.
*
* @return {Object}
*/
get() {
if (!this.presets[preferenceStore.selectedPreset]) {
return preferenceStore.equalizer;
}
2016-06-25 16:05:24 +00:00
// If the user chose a preset (instead of customizing one), just return it.
2016-06-28 06:39:42 +00:00
return this.getPresetById(preferenceStore.selectedPreset)
2016-06-25 16:05:24 +00:00
},
2016-01-19 11:00:23 +00:00
2016-06-25 16:05:24 +00:00
/**
* Save the current equalizer config.
*
* @param {Number} preamp The preamp value (dB)
* @param {Array.<Number>} gains The band's gain value (dB)
*/
set(preamp, gains) {
preferenceStore.equalizer = { preamp, gains };
},
2016-01-19 11:00:23 +00:00
};