diff --git a/src/renderer/views/components/equalizer.ejs b/src/renderer/views/components/equalizer.ejs index e7ae2d2a..abfcd86e 100644 --- a/src/renderer/views/components/equalizer.ejs +++ b/src/renderer/views/components/equalizer.ejs @@ -129,88 +129,88 @@ }, defaultPresets: [ { - 'preset': 'default', - 'name': 'Default', - 'frequencies': [32, 63, 125, 250, 500, 1000, 2000, 4000, 8000, 16000], - 'gain': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - 'Q': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], - 'mix': 1, - 'vibrantBass': 0, - 'userGenerated': false - }, { - 'preset': 'boostAiriness', - 'name': 'Boost Airiness', - '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], - 'Q': [0.405, 2.102, 0.025, 2.5, 7.071, 1.768, 1.146, 1, 1, 1], - 'mix': 1, - 'vibrantBass': 0, - 'userGenerated': false - }, { - 'preset': 'acoustic', - 'name': 'Acoustic', - 'frequencies': [32, 75, 125, 220, 700, 1000, 2000, 4000, 10000, 16000], - '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], - 'mix': 1, - 'vibrantBass': 0, - 'userGenerated': false - }, { - 'preset': 'clearVocal', - 'name': 'Clear Vocal', - 'frequencies': [20, 63, 125, 250, 400, 1000, 2000, 4000, 8000, 20000], - '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], - 'mix': 1, - 'vibrantBass': 0, - 'userGenerated': false - }, { - 'preset': 'instrumentClarity', - 'name': 'Instrument Clarity', - 'frequencies': [20, 63, 155, 250, 500, 1000, 2000, 5000, 11000, 16000], - '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], - 'mix': 1, - 'vibrantBass': 0, - 'userGenerated': false - }, { - 'preset': 'reduceHarshness', - 'name': 'Reduce Harshness', - 'frequencies': [32, 63, 125, 250, 500, 1128, 2000, 4057, 8000, 16000], - 'gain': [0, 0, 0, 0, 0, 2, 0, -6.4, 0, 0], - 'Q': [1, 1, 1, 1, 1, 2, 1, 1, 1, 1], - 'mix': 1, - 'vibrantBass': 0, - 'userGenerated': false - }, { - 'preset': 'smileyFace', - 'name': 'Smiley Face', - 'frequencies': [35, 63, 125, 250, 500, 800, 2000, 4000, 8000, 20000], - '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], - 'mix': 1, - 'vibrantBass': 0, - 'userGenerated': false - }, - { - 'preset': 'bassBoostSurgical', - 'name': 'Surgical Bass Boost', - '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], - 'Q': [1.4, 1.4, 1.4, 1.4, 1.4, 1, 1, 1, 1, 1], - 'mix': 1, - 'vibrantBass': 0, - 'userGenerated': false - }, { - 'preset': 'bassBoostClassic', - 'name': 'Classic Bass Boost', - '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], - 'Q': [0.7, 0.7, 0.7, 0.7, 0.7, 1, 1, 1, 1, 1], - 'mix': 1, - 'vibrantBass': 0, - 'userGenerated': false - }] + 'preset': 'default', + 'name': 'Default', + 'frequencies': [32, 63, 125, 250, 500, 1000, 2000, 4000, 8000, 16000], + 'gain': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + 'Q': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + 'mix': 1, + 'vibrantBass': 0, + 'userGenerated': false + }, { + 'preset': 'boostAiriness', + 'name': 'Boost Airiness', + '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], + 'Q': [0.405, 2.102, 0.025, 2.5, 7.071, 1.768, 1.146, 1, 1, 1], + 'mix': 1, + 'vibrantBass': 0, + 'userGenerated': false + }, { + 'preset': 'acoustic', + 'name': 'Acoustic', + 'frequencies': [32, 75, 125, 220, 700, 1000, 2000, 4000, 10000, 16000], + '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], + 'mix': 1, + 'vibrantBass': 0, + 'userGenerated': false + }, { + 'preset': 'clearVocal', + 'name': 'Clear Vocal', + 'frequencies': [20, 63, 125, 250, 400, 1000, 2000, 4000, 8000, 20000], + '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], + 'mix': 1, + 'vibrantBass': 0, + 'userGenerated': false + }, { + 'preset': 'instrumentClarity', + 'name': 'Instrument Clarity', + 'frequencies': [20, 63, 155, 250, 500, 1000, 2000, 5000, 11000, 16000], + '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], + 'mix': 1, + 'vibrantBass': 0, + 'userGenerated': false + }, { + 'preset': 'reduceHarshness', + 'name': 'Reduce Harshness', + 'frequencies': [32, 63, 125, 250, 500, 1128, 2000, 4057, 8000, 16000], + 'gain': [0, 0, 0, 0, 0, 2, 0, -6.4, 0, 0], + 'Q': [1, 1, 1, 1, 1, 2, 1, 1, 1, 1], + 'mix': 1, + 'vibrantBass': 0, + 'userGenerated': false + }, { + 'preset': 'smileyFace', + 'name': 'Smiley Face', + 'frequencies': [35, 63, 125, 250, 500, 800, 2000, 4000, 8000, 20000], + '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], + 'mix': 1, + 'vibrantBass': 0, + 'userGenerated': false + }, + { + 'preset': 'bassBoostSurgical', + 'name': 'Surgical Bass Boost', + '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], + 'Q': [1.4, 1.4, 1.4, 1.4, 1.4, 1, 1, 1, 1, 1], + 'mix': 1, + 'vibrantBass': 0, + 'userGenerated': false + }, { + 'preset': 'bassBoostClassic', + 'name': 'Classic Bass Boost', + '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], + 'Q': [0.7, 0.7, 0.7, 0.7, 0.7, 1, 1, 1, 1, 1], + 'mix': 1, + 'vibrantBass': 0, + 'userGenerated': false + }] } }, props: ["src", "url"], @@ -238,20 +238,20 @@ "icon": "./assets/feather/share.svg", "name": app.getLz('action.import'), action: () => { - notyf.error("Not implemented yet") + this.importPreset() } }, "export": { "icon": "./assets/feather/share.svg", "name": app.getLz('action.export'), 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 } @@ -296,14 +296,15 @@ changeVibrantBass() { if (app.cfg.audio.equalizer.vibrantBass !== '0') { try { - 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.intelliGainComp_h0_0();} - catch(e) { + 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.intelliGainComp_h0_0(); + } + catch (e) { CiderAudio.hierarchical_loading(); } } - + else { CiderAudio.hierarchical_loading(); } @@ -312,17 +313,19 @@ if (Math.max(...app.cfg.audio.equalizer.gain) != 0) { try { 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(); - } catch(e) {CiderAudio.hierarchical_loading(); } + } catch (e) { CiderAudio.hierarchical_loading(); } } }, changeGain(i) { 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 - CiderAudio.intelliGainComp_h0_0();} - catch(e){CiderAudio.hierarchical_loading();} + try { + 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(); } } else { CiderAudio.hierarchical_loading(); @@ -378,37 +381,35 @@ notyf.success("Saved Preset") }, exportPreset() { - const 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}; - ipcRenderer.send("export-eq", jsonObj) + let preset = app.cfg.audio.equalizer.presets.find(p => p.preset == app.cfg.audio.equalizer.preset) + this.$root.copyToClipboard(btoa(JSON.stringify(preset))) }, importPreset() { - ipcRenderer.sendSync("import-eq").then((result) => { - let newPreset = new self.eqPreset() - newPreset.name = result.name - newPreset.author = result.author - newPreset.frequencies = result.frequency - newPreset.gain = result.gain - newPreset.Q = result.q - newPreset.mix = result.mix - newPreset.vibrantBass = result.vibrantBass - app.cfg.audio.equalizer.presets.push(newPreset) - notyf.success("Imported preset " + result.name) - }).catch(err => { - console.error("[EQ Import] " + err) - notyf.error("Could not import preset") + let self = this + bootbox.prompt("Enter preset share code", (res) => { + if (res) { + let preset = JSON.parse(atob(res)) + if (preset.frequencies && preset.gain && preset.Q && preset.mix && preset.vibrantBass) { + // self.applyPreset(preset) + app.cfg.audio.equalizer.presets.push(preset) + notyf.success(`${preset.name} has been imported.`) + } + else { + notyf.error("Invalid Preset") + } + } }) }, applyPreset(preset) { Object.assign(this.$root.cfg.audio.equalizer, preset) this.changeVibrantBass() 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} - catch(e){ + try { CiderAudio.audioNodes.audioBands[i].gain.value = app.cfg.audio.equalizer.gain[i] * app.cfg.audio.equalizer.mix } + catch (e) { CiderAudio.hierarchical_loading(); 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].Q.value = app.cfg.audio.equalizer.Q[i] }