added preset import/export

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

View file

@ -238,14 +238,14 @@
"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()
} }
}, },
} }
@ -298,7 +298,8 @@
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();
} }
@ -320,8 +321,10 @@
}, },
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
CiderAudio.intelliGainComp_h0_0();
}
catch (e) { CiderAudio.hierarchical_loading(); } catch (e) { CiderAudio.hierarchical_loading(); }
} }
else { else {
@ -378,25 +381,23 @@
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) {