added preset import/export

This commit is contained in:
booploops 2022-04-13 08:38:12 -07:00
parent 05abb26625
commit 46da10803e

View file

@ -129,88 +129,88 @@
}, },
defaultPresets: [ defaultPresets: [
{ {
'preset': 'default', 'preset': 'default',
'name': 'Default', 'name': 'Default',
'frequencies': [32, 63, 125, 250, 500, 1000, 2000, 4000, 8000, 16000], 'frequencies': [32, 63, 125, 250, 500, 1000, 2000, 4000, 8000, 16000],
'gain': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 'gain': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
'Q': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 'Q': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
'mix': 1, 'mix': 1,
'vibrantBass': 0, 'vibrantBass': 0,
'userGenerated': false 'userGenerated': false
}, { }, {
'preset': 'boostAiriness', 'preset': 'boostAiriness',
'name': 'Boost Airiness', 'name': 'Boost Airiness',
'frequencies': [1169, 1733, 5962, 8688, 14125, 18628, 18628, 19000, 19500, 20000], 'frequencies': [1169, 1733, 5962, 8688, 14125, 18628, 18628, 19000, 19500, 20000],
'gain': [-1.41, 0.25, 3.33, 0.22, -0.53, 0.2, 3.64, 0, 0, 0], 'gain': [-1.41, 0.25, 3.33, 0.22, -0.53, 0.2, 3.64, 0, 0, 0],
'Q': [0.405, 2.102, 0.025, 2.5, 7.071, 1.768, 1.146, 1, 1, 1], 'Q': [0.405, 2.102, 0.025, 2.5, 7.071, 1.768, 1.146, 1, 1, 1],
'mix': 1, 'mix': 1,
'vibrantBass': 0, 'vibrantBass': 0,
'userGenerated': false 'userGenerated': false
}, { }, {
'preset': 'acoustic', 'preset': 'acoustic',
'name': 'Acoustic', 'name': 'Acoustic',
'frequencies': [32, 75, 125, 220, 700, 1000, 2000, 4000, 10000, 16000], 'frequencies': [32, 75, 125, 220, 700, 1000, 2000, 4000, 10000, 16000],
'gain': [0, -8, 0, -0.1, -3, 0, 0, 0, 4, 0], 'gain': [0, -8, 0, -0.1, -3, 0, 0, 0, 4, 0],
'Q': [1, 0.2, 1, 2.0, 1.4, 1, 1, 1, 0.1, 1], 'Q': [1, 0.2, 1, 2.0, 1.4, 1, 1, 1, 0.1, 1],
'mix': 1, 'mix': 1,
'vibrantBass': 0, 'vibrantBass': 0,
'userGenerated': false 'userGenerated': false
}, { }, {
'preset': 'clearVocal', 'preset': 'clearVocal',
'name': 'Clear Vocal', 'name': 'Clear Vocal',
'frequencies': [20, 63, 125, 250, 400, 1000, 2000, 4000, 8000, 20000], 'frequencies': [20, 63, 125, 250, 400, 1000, 2000, 4000, 8000, 20000],
'gain': [-22, 0, 0, 0, -3, 0, 1.8, 0, 0, 3.5], 'gain': [-22, 0, 0, 0, -3, 0, 1.8, 0, 0, 3.5],
'Q': [0.3, 1, 1, 1, 2.0, 1, 0.7, 1, 1, 0.8], 'Q': [0.3, 1, 1, 1, 2.0, 1, 0.7, 1, 1, 0.8],
'mix': 1, 'mix': 1,
'vibrantBass': 0, 'vibrantBass': 0,
'userGenerated': false 'userGenerated': false
}, { }, {
'preset': 'instrumentClarity', 'preset': 'instrumentClarity',
'name': 'Instrument Clarity', 'name': 'Instrument Clarity',
'frequencies': [20, 63, 155, 250, 500, 1000, 2000, 5000, 11000, 16000], 'frequencies': [20, 63, 155, 250, 500, 1000, 2000, 5000, 11000, 16000],
'gain': [-15, 0, -3, 0, 0, 0, 0, 3.1, 0, 0], 'gain': [-15, 0, -3, 0, 0, 0, 0, 3.1, 0, 0],
'Q': [0.5, 1, 2, 1, 1, 1, 1, 1.5, 0.1, 1], 'Q': [0.5, 1, 2, 1, 1, 1, 1, 1.5, 0.1, 1],
'mix': 1, 'mix': 1,
'vibrantBass': 0, 'vibrantBass': 0,
'userGenerated': false 'userGenerated': false
}, { }, {
'preset': 'reduceHarshness', 'preset': 'reduceHarshness',
'name': 'Reduce Harshness', 'name': 'Reduce Harshness',
'frequencies': [32, 63, 125, 250, 500, 1128, 2000, 4057, 8000, 16000], 'frequencies': [32, 63, 125, 250, 500, 1128, 2000, 4057, 8000, 16000],
'gain': [0, 0, 0, 0, 0, 2, 0, -6.4, 0, 0], 'gain': [0, 0, 0, 0, 0, 2, 0, -6.4, 0, 0],
'Q': [1, 1, 1, 1, 1, 2, 1, 1, 1, 1], 'Q': [1, 1, 1, 1, 1, 2, 1, 1, 1, 1],
'mix': 1, 'mix': 1,
'vibrantBass': 0, 'vibrantBass': 0,
'userGenerated': false 'userGenerated': false
}, { }, {
'preset': 'smileyFace', 'preset': 'smileyFace',
'name': 'Smiley Face', 'name': 'Smiley Face',
'frequencies': [35, 63, 125, 250, 500, 800, 2000, 4000, 8000, 20000], 'frequencies': [35, 63, 125, 250, 500, 800, 2000, 4000, 8000, 20000],
'gain': [5, 0, 0, 0, 0, -5, 0, 0, 0, 5], 'gain': [5, 0, 0, 0, 0, -5, 0, 0, 0, 5],
'Q': [0.1, 1, 1, 1, 1, 0.6, 1, 1, 1, 0.2], 'Q': [0.1, 1, 1, 1, 1, 0.6, 1, 1, 1, 0.2],
'mix': 1, 'mix': 1,
'vibrantBass': 0, 'vibrantBass': 0,
'userGenerated': false 'userGenerated': false
}, },
{ {
'preset': 'bassBoostSurgical', 'preset': 'bassBoostSurgical',
'name': 'Surgical Bass Boost', 'name': 'Surgical Bass Boost',
'frequencies': [32, 63, 125, 250, 500, 1000, 2000, 4000, 8000, 16000], 'frequencies': [32, 63, 125, 250, 500, 1000, 2000, 4000, 8000, 16000],
'gain': [2.7, 2.2, 1.6, 1.4, 0.6, 0, 0, 0, 0, 0], 'gain': [2.7, 2.2, 1.6, 1.4, 0.6, 0, 0, 0, 0, 0],
'Q': [1.4, 1.4, 1.4, 1.4, 1.4, 1, 1, 1, 1, 1], 'Q': [1.4, 1.4, 1.4, 1.4, 1.4, 1, 1, 1, 1, 1],
'mix': 1, 'mix': 1,
'vibrantBass': 0, 'vibrantBass': 0,
'userGenerated': false 'userGenerated': false
}, { }, {
'preset': 'bassBoostClassic', 'preset': 'bassBoostClassic',
'name': 'Classic Bass Boost', 'name': 'Classic Bass Boost',
'frequencies': [32, 63, 160, 250, 500, 1000, 2000, 3500, 8000, 20000], 'frequencies': [32, 63, 160, 250, 500, 1000, 2000, 3500, 8000, 20000],
'gain': [2.7, 2.2, 1.6, 1.4, 0.6, 0, 0, 0, 0, 0], 'gain': [2.7, 2.2, 1.6, 1.4, 0.6, 0, 0, 0, 0, 0],
'Q': [0.7, 0.7, 0.7, 0.7, 0.7, 1, 1, 1, 1, 1], 'Q': [0.7, 0.7, 0.7, 0.7, 0.7, 1, 1, 1, 1, 1],
'mix': 1, 'mix': 1,
'vibrantBass': 0, 'vibrantBass': 0,
'userGenerated': false 'userGenerated': false
}] }]
} }
}, },
props: ["src", "url"], props: ["src", "url"],
@ -238,20 +238,20 @@
"icon": "./assets/feather/share.svg", "icon": "./assets/feather/share.svg",
"name": app.getLz('action.import'), "name": app.getLz('action.import'),
action: () => { action: () => {
notyf.error("Not implemented yet") this.importPreset()
} }
}, },
"export": { "export": {
"icon": "./assets/feather/share.svg", "icon": "./assets/feather/share.svg",
"name": app.getLz('action.export'), "name": app.getLz('action.export'),
action: () => { action: () => {
notyf.error("Not implemented yet") this.exportPreset()
} }
}, },
} }
} }
if(!this.$root.cfg.audio.equalizer.userGenerated) { if (!this.$root.cfg.audio.equalizer.userGenerated) {
delete menu.items.delete delete menu.items.delete
} }
@ -296,14 +296,15 @@
changeVibrantBass() { changeVibrantBass() {
if (app.cfg.audio.equalizer.vibrantBass !== '0') { if (app.cfg.audio.equalizer.vibrantBass !== '0') {
try { try {
for (var i = 0; i < 21; i++) { for (var i = 0; i < 21; i++) {
CiderAudio.audioNodes.vibrantbassNode[i].gain.value = app.cfg.audio.maikiwiAudio.vibrantBass.gain[i] * (app.cfg.audio.equalizer.vibrantBass / 10); CiderAudio.audioNodes.vibrantbassNode[i].gain.value = app.cfg.audio.maikiwiAudio.vibrantBass.gain[i] * (app.cfg.audio.equalizer.vibrantBass / 10);
} CiderAudio.intelliGainComp_h0_0();} } CiderAudio.intelliGainComp_h0_0();
catch(e) { }
catch (e) {
CiderAudio.hierarchical_loading(); CiderAudio.hierarchical_loading();
} }
} }
else { else {
CiderAudio.hierarchical_loading(); CiderAudio.hierarchical_loading();
} }
@ -312,17 +313,19 @@
if (Math.max(...app.cfg.audio.equalizer.gain) != 0) { if (Math.max(...app.cfg.audio.equalizer.gain) != 0) {
try { try {
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
CiderAudio.audioNodes.audioBands[i].gain.value = app.cfg.audio.equalizer.gain[i] * app.cfg.audio.equalizer.mix CiderAudio.audioNodes.audioBands[i].gain.value = app.cfg.audio.equalizer.gain[i] * app.cfg.audio.equalizer.mix
} }
CiderAudio.intelliGainComp_h0_0(); CiderAudio.intelliGainComp_h0_0();
} catch(e) {CiderAudio.hierarchical_loading(); } } catch (e) { CiderAudio.hierarchical_loading(); }
} }
}, },
changeGain(i) { changeGain(i) {
if (Math.max(...app.cfg.audio.equalizer.gain) != 0) { if (Math.max(...app.cfg.audio.equalizer.gain) != 0) {
try {CiderAudio.audioNodes.audioBands[i].gain.value = app.cfg.audio.equalizer.gain[i] * app.cfg.audio.equalizer.mix try {
CiderAudio.intelliGainComp_h0_0();} CiderAudio.audioNodes.audioBands[i].gain.value = app.cfg.audio.equalizer.gain[i] * app.cfg.audio.equalizer.mix
catch(e){CiderAudio.hierarchical_loading();} CiderAudio.intelliGainComp_h0_0();
}
catch (e) { CiderAudio.hierarchical_loading(); }
} }
else { else {
CiderAudio.hierarchical_loading(); CiderAudio.hierarchical_loading();
@ -378,37 +381,35 @@
notyf.success("Saved Preset") notyf.success("Saved Preset")
}, },
exportPreset() { exportPreset() {
const preset = app.cfg.audio.equalizer.presets.find(p => p.preset == app.cfg.audio.equalizer.preset) let preset = app.cfg.audio.equalizer.presets.find(p => p.preset == app.cfg.audio.equalizer.preset)
const jsonObj = {"name": preset.name, "author": app.chrome.userinfo.attributes.name, "frequency": preset.frequencies, "gain": preset.gain, "q": preset.Q, "mix": preset.mix, "vibrantBass": preset.vibrantBass}; this.$root.copyToClipboard(btoa(JSON.stringify(preset)))
ipcRenderer.send("export-eq", jsonObj)
}, },
importPreset() { importPreset() {
ipcRenderer.sendSync("import-eq").then((result) => { let self = this
let newPreset = new self.eqPreset() bootbox.prompt("Enter preset share code", (res) => {
newPreset.name = result.name if (res) {
newPreset.author = result.author let preset = JSON.parse(atob(res))
newPreset.frequencies = result.frequency if (preset.frequencies && preset.gain && preset.Q && preset.mix && preset.vibrantBass) {
newPreset.gain = result.gain // self.applyPreset(preset)
newPreset.Q = result.q app.cfg.audio.equalizer.presets.push(preset)
newPreset.mix = result.mix notyf.success(`${preset.name} has been imported.`)
newPreset.vibrantBass = result.vibrantBass }
app.cfg.audio.equalizer.presets.push(newPreset) else {
notyf.success("Imported preset " + result.name) notyf.error("Invalid Preset")
}).catch(err => { }
console.error("[EQ Import] " + err) }
notyf.error("Could not import preset")
}) })
}, },
applyPreset(preset) { applyPreset(preset) {
Object.assign(this.$root.cfg.audio.equalizer, preset) Object.assign(this.$root.cfg.audio.equalizer, preset)
this.changeVibrantBass() this.changeVibrantBass()
for (var i = 0; i < 10; i++) { for (var i = 0; i < 10; i++) {
try {CiderAudio.audioNodes.audioBands[i].gain.value = app.cfg.audio.equalizer.gain[i] * app.cfg.audio.equalizer.mix} try { CiderAudio.audioNodes.audioBands[i].gain.value = app.cfg.audio.equalizer.gain[i] * app.cfg.audio.equalizer.mix }
catch(e){ catch (e) {
CiderAudio.hierarchical_loading(); CiderAudio.hierarchical_loading();
CiderAudio.audioNodes.audioBands[i].gain.value = app.cfg.audio.equalizer.gain[i] * app.cfg.audio.equalizer.mix CiderAudio.audioNodes.audioBands[i].gain.value = app.cfg.audio.equalizer.gain[i] * app.cfg.audio.equalizer.mix
} }
CiderAudio.audioNodes.audioBands[i].frequency.value = app.cfg.audio.equalizer.frequencies[i] CiderAudio.audioNodes.audioBands[i].frequency.value = app.cfg.audio.equalizer.frequencies[i]
CiderAudio.audioNodes.audioBands[i].Q.value = app.cfg.audio.equalizer.Q[i] CiderAudio.audioNodes.audioBands[i].Q.value = app.cfg.audio.equalizer.Q[i]
} }