This commit is contained in:
maikirakiwi 2022-06-21 14:52:58 -07:00
parent a09127a826
commit 7d8c6a684a
2 changed files with 96 additions and 233 deletions

View file

@ -80,6 +80,7 @@ const CiderAudio = {
}
} catch (e) {
console.debug("[Cider][MaikiwiSoundCheck] normalizer func err: " + e)
}
},
normalizerOff: function () {
@ -619,89 +620,54 @@ const CiderAudio = {
switch (app.cfg.audio.maikiwiAudio.ciderPPE_value) {
case "MAIKIWI":
try {
switch (localStorage.getItem("playingBitrate")) {
case "64":
CiderAudio.audioNodes.llpw[0] = CiderAudio.context.createConvolver();
CiderAudio.audioNodes.llpw[0].normalize = false;
fetch('./cideraudio/impulses/CAP_64.wav').then(async (impulseData) => {
let bufferedImpulse = await impulseData.arrayBuffer();
CiderAudio.audioNodes.llpw[0].buffer = await CiderAudio.context.decodeAudioData(bufferedImpulse);
});
console.debug("[Cider][Audio] CAP Adaptive - 64kbps");
try {
switch (localStorage.getItem("playingBitrate")) {
case "64":
CiderAudio.audioNodes.llpw[0] = CiderAudio.context.createConvolver();
CiderAudio.audioNodes.llpw[0].normalize = false;
fetch('./cideraudio/impulses/CAP_64.wav').then(async (impulseData) => {
let bufferedImpulse = await impulseData.arrayBuffer();
CiderAudio.audioNodes.llpw[0].buffer = await CiderAudio.context.decodeAudioData(bufferedImpulse);
});
console.debug("[Cider][Audio] CAP Adaptive - 64kbps");
break;
case "256":
CiderAudio.audioNodes.llpw[0] = CiderAudio.context.createConvolver(); CiderAudio.audioNodes.llpw[0].normalize = false;
CiderAudio.audioNodes.llpw[1] = CiderAudio.context.createGain(); CiderAudio.audioNodes.llpw[1].gain.value = 2.37; // Post Gain Compensation
CiderAudio.audioNodes.llpw[0].connect(CiderAudio.audioNodes.llpw[1]);
fetch('./cideraudio/impulses/CAP_256_FINAL_48k.wav').then(async (impulseData) => {
let bufferedImpulse = await impulseData.arrayBuffer();
CiderAudio.audioNodes.llpw[0].buffer = await CiderAudio.context.decodeAudioData(bufferedImpulse);
});
console.debug("[Cider][Audio] CAP Adaptive - 256kbps_2_48k");
break;
case "256":
CiderAudio.audioNodes.llpw[0] = CiderAudio.context.createConvolver(); CiderAudio.audioNodes.llpw[0].normalize = false;
CiderAudio.audioNodes.llpw[1] = CiderAudio.context.createGain(); CiderAudio.audioNodes.llpw[1].gain.value = 2.37; // Post Gain Compensation
CiderAudio.audioNodes.llpw[0].connect(CiderAudio.audioNodes.llpw[1]);
fetch('./cideraudio/impulses/CAP_256_FINAL_48k.wav').then(async (impulseData) => {
let bufferedImpulse = await impulseData.arrayBuffer();
CiderAudio.audioNodes.llpw[0].buffer = await CiderAudio.context.decodeAudioData(bufferedImpulse);
});
console.debug("[Cider][Audio] CAP Adaptive - 256kbps_2_48k");
break;
default:
CiderAudio.audioNodes.llpw[0] = CiderAudio.context.createConvolver(); CiderAudio.audioNodes.llpw[0].normalize = false;
CiderAudio.audioNodes.llpw[1] = CiderAudio.context.createGain(); CiderAudio.audioNodes.llpw[1].gain.value = 2.37; // Post Gain Compensation
CiderAudio.audioNodes.llpw[0].connect(CiderAudio.audioNodes.llpw[1]);
fetch('./cideraudio/impulses/CAP_256_FINAL_48k.wav').then(async (impulseData) => {
let bufferedImpulse = await impulseData.arrayBuffer();
CiderAudio.audioNodes.llpw[0].buffer = await CiderAudio.context.decodeAudioData(bufferedImpulse);
});
console.debug("[Cider][Audio] CAP Adaptive - CONFIG FALLBACK - 256kbps_2_48k");
break;
default:
CiderAudio.audioNodes.llpw[0] = CiderAudio.context.createConvolver(); CiderAudio.audioNodes.llpw[0].normalize = false;
CiderAudio.audioNodes.llpw[1] = CiderAudio.context.createGain(); CiderAudio.audioNodes.llpw[1].gain.value = 2.37; // Post Gain Compensation
CiderAudio.audioNodes.llpw[0].connect(CiderAudio.audioNodes.llpw[1]);
fetch('./cideraudio/impulses/CAP_256_FINAL_48k.wav').then(async (impulseData) => {
let bufferedImpulse = await impulseData.arrayBuffer();
CiderAudio.audioNodes.llpw[0].buffer = await CiderAudio.context.decodeAudioData(bufferedImpulse);
});
console.debug("[Cider][Audio] CAP Adaptive - CONFIG FALLBACK - 256kbps_2_48k");
break;
}
} catch (e) {
CiderAudio.audioNodes.llpw[0] = CiderAudio.context.createConvolver(); CiderAudio.audioNodes.llpw[0].normalize = false;
CiderAudio.audioNodes.llpw[1] = CiderAudio.context.createGain(); CiderAudio.audioNodes.llpw[1].gain.value = 2.37;
CiderAudio.audioNodes.llpw[0].connect(CiderAudio.audioNodes.llpw[1]);
fetch('./cideraudio/impulses/CAP_256_FINAL_48k.wav').then(async (impulseData) => {
let bufferedImpulse = await impulseData.arrayBuffer();
CiderAudio.audioNodes.llpw[0].buffer = await CiderAudio.context.decodeAudioData(bufferedImpulse);
});
console.debug("[Cider][Audio] CAP Adaptive - (Error Fallback) 256kbps");
}
switch (destination) {
case "spatial":
try { CiderAudio.audioNodes.llpw.at(-1).connect(CiderAudio.audioNodes.spatialNode); console.debug("[Cider][Audio] llpw_n1 -> Spatial");} catch (e) { }
break;
case "n5":
try {
CiderAudio.audioNodes.llpw.at(-1).connect(CiderAudio.audioNodes.atmosphereRealizer2);
console.debug("[Cider][Audio] llpw_n1 -> atmosphereRealizer2");
} catch (e) { }
break;
case 'n4':
try {
CiderAudio.audioNodes.llpw.at(-1).connect(CiderAudio.audioNodes.atmosphereRealizer1);
console.debug("[Cider][Audio] llpw_n1 -> atmosphereRealizer1");
} catch (e) { }
break;
case 'n3':
try { CiderAudio.audioNodes.llpw.at(-1).connect(CiderAudio.audioNodes.vibrantbassNode[0]);
console.debug("[Cider][Audio] llpw_n1 -> vibrantbassNode");} catch (e) { }
break;
case 'n2':
try { CiderAudio.audioNodes.llpw.at(-1).connect(CiderAudio.audioNodes.audioBands[0]); console.debug("[Cider][Audio] llpw_n1 -> audioBands");} catch (e) { }
break;
case 'n1':
try {
CiderAudio.audioNodes.llpw.at(-1).connect(CiderAudio.audioNodes.llpw[0]);
console.debug("[Cider][Audio] llpw_n1 -> llpw");
} catch (e) { }
break;
case 'n0':
try { CiderAudio.audioNodes.llpw.at(-1).connect(CiderAudio.context.destination); console.debug("[Cider][Audio] llpw_n1 -> destination");} catch (e) { }
break;
break;
}
break;
} catch (e) {
CiderAudio.audioNodes.llpw[0] = CiderAudio.context.createConvolver(); CiderAudio.audioNodes.llpw[0].normalize = false;
CiderAudio.audioNodes.llpw[1] = CiderAudio.context.createGain(); CiderAudio.audioNodes.llpw[1].gain.value = 2.37;
CiderAudio.audioNodes.llpw[0].connect(CiderAudio.audioNodes.llpw[1]);
fetch('./cideraudio/impulses/CAP_256_FINAL_48k.wav').then(async (impulseData) => {
let bufferedImpulse = await impulseData.arrayBuffer();
CiderAudio.audioNodes.llpw[0].buffer = await CiderAudio.context.decodeAudioData(bufferedImpulse);
});
console.debug("[Cider][Audio] CAP Adaptive - (Error Fallback) 256kbps");
}
break;
case "MAIKIWI_LEGACY":
CiderAudio.audioNodes.llpw[0] = CiderAudio.context.createConvolver();
CiderAudio.audioNodes.llpw[0].normalize = false;
@ -709,41 +675,6 @@ const CiderAudio = {
let bufferedImpulse = await impulseData.arrayBuffer();
CiderAudio.audioNodes.llpw[0].buffer = await CiderAudio.context.decodeAudioData(bufferedImpulse);
});
switch (destination) {
case "spatial":
try { CiderAudio.audioNodes.llpw[0].connect(CiderAudio.audioNodes.spatialNode); console.debug("[Cider][Audio] llpw_n1 -> Spatial");} catch (e) { }
break;
case "n5":
try {
CiderAudio.audioNodes.llpw[0].connect(CiderAudio.audioNodes.atmosphereRealizer2);
console.debug("[Cider][Audio] llpw_n1 -> atmosphereRealizer2");
} catch (e) { }
break;
case 'n4':
try {
CiderAudio.audioNodes.llpw[0].connect(CiderAudio.audioNodes.atmosphereRealizer1);
console.debug("[Cider][Audio] llpw_n1 -> atmosphereRealizer1");
} catch (e) { }
break;
case 'n1':
try {
CiderAudio.audioNodes.llpw[0].connect(CiderAudio.audioNodes.llpw[0]);
console.debug("[Cider][Audio] llpw_n1 -> llpw");
} catch (e) { }
break;
case 'n3':
try { CiderAudio.audioNodes.llpw[0].connect(CiderAudio.audioNodes.vibrantbassNode[0]);
console.debug("[Cider][Audio] llpw_n1 -> vibrantbassNode");} catch (e) { }
break;
case 'n2':
try { CiderAudio.audioNodes.llpw[0].connect(CiderAudio.audioNodes.audioBands[0]); console.debug("[Cider][Audio] llpw_n1 -> audioBands");} catch (e) { }
break;
case 'n0':
try { CiderAudio.audioNodes.llpw[0].connect(CiderAudio.context.destination); console.debug("[Cider][Audio] llpw_n1 -> destination");} catch (e) { }
break;
}
console.debug("[Cider][Audio] CAP - Maikiwi Signature Mode");
break;
case "NATURAL":
@ -754,41 +685,6 @@ const CiderAudio = {
CiderAudio.audioNodes.llpw[0].buffer = await CiderAudio.context.decodeAudioData(bufferedImpulse);
});
switch (destination) {
case "spatial":
try { CiderAudio.audioNodes.llpw.at(-1).connect(CiderAudio.audioNodes.spatialNode); console.debug("[Cider][Audio] llpw_n1 -> Spatial");} catch (e) { }
break;
case "n5":
try {
CiderAudio.audioNodes.llpw[0].connect(CiderAudio.audioNodes.atmosphereRealizer2);
console.debug("[Cider][Audio] llpw_n1 -> atmosphereRealizer2");
} catch (e) { }
break;
case 'n4':
try {
CiderAudio.audioNodes.llpw[0].connect(CiderAudio.audioNodes.atmosphereRealizer1);
console.debug("[Cider][Audio] llpw_n1 -> atmosphereRealizer1");
} catch (e) { }
break;
case 'n1':
try {
CiderAudio.audioNodes.llpw[0].connect(CiderAudio.audioNodes.llpw[0]);
console.debug("[Cider][Audio] llpw_n1 -> llpw");
} catch (e) { }
break;
case 'n3':
try { CiderAudio.audioNodes.llpw[0].connect(CiderAudio.audioNodes.vibrantbassNode[0]);
console.debug("[Cider][Audio] llpw_n1 -> vibrantbassNode");} catch (e) { }
break;
case 'n2':
try { CiderAudio.audioNodes.llpw[0].connect(CiderAudio.audioNodes.audioBands[0]); console.debug("[Cider][Audio] llpw_n1 -> audioBands");} catch (e) { }
break;
case 'n0':
try { CiderAudio.audioNodes.llpw[0].connect(CiderAudio.context.destination); console.debug("[Cider][Audio] llpw_n1 -> destination");} catch (e) { }
break;
}
console.debug("[Cider][Audio] CAP - Natural Mode");
break;
@ -803,41 +699,7 @@ const CiderAudio = {
for (let i = 1; i < LLPW_FREQUENCIES.length; i ++) {
CiderAudio.audioNodes.llpw[i-1].connect(CiderAudio.audioNodes.llpw[i]);
}
switch (destination) {
case "spatial":
try { CiderAudio.audioNodes.llpw.at(-1).connect(CiderAudio.audioNodes.spatialNode); console.debug("[Cider][Audio] llpw_n1 -> Spatial");} catch (e) { }
break;
case "n5":
try {
CiderAudio.audioNodes.llpw.at(-1).connect(CiderAudio.audioNodes.atmosphereRealizer2);
console.debug("[Cider][Audio] llpw_n1 -> atmosphereRealizer2");
} catch (e) { }
break;
case 'n4':
try {
CiderAudio.audioNodes.llpw.at(-1).connect(CiderAudio.audioNodes.atmosphereRealizer1);
console.debug("[Cider][Audio] llpw_n1 -> atmosphereRealizer1");
} catch (e) { }
break;
case 'n1':
try {
CiderAudio.audioNodes.llpw.at(-1).connect(CiderAudio.audioNodes.llpw[0]);
console.debug("[Cider][Audio] llpw_n1 -> llpw");
} catch (e) { }
break;
case 'n3':
try { CiderAudio.audioNodes.llpw.at(-1).connect(CiderAudio.audioNodes.vibrantbassNode[0]);
console.debug("[Cider][Audio] llpw_n1 -> vibrantbassNode");} catch (e) { }
break;
case 'n2':
try { CiderAudio.audioNodes.llpw.at(-1).connect(CiderAudio.audioNodes.audioBands[0]); console.debug("[Cider][Audio] llpw_n1 -> audioBands");} catch (e) { }
break;
case 'n0':
try { CiderAudio.audioNodes.llpw.at(-1).connect(CiderAudio.context.destination); console.debug("[Cider][Audio] llpw_n1 -> destination");} catch (e) { }
break;
}
console.debug("[Cider][Audio] CAP - Legacy Mode");
console.debug("[Cider][Audio] CAP - Legacy Mode");
break;
@ -851,42 +713,43 @@ const CiderAudio = {
});
app.cfg.audio.maikiwiAudio.ciderPPE_value = "MAIKIWI";
switch (destination) {
case "spatial":
try { CiderAudio.audioNodes.llpw.at(-1).connect(CiderAudio.audioNodes.spatialNode); console.debug("[Cider][Audio] llpw_n1 -> Spatial");} catch (e) { }
break;
case "n5":
try {
CiderAudio.audioNodes.llpw[1].connect(CiderAudio.audioNodes.atmosphereRealizer2);
console.debug("[Cider][Audio] llpw_n1 -> atmosphereRealizer2");
} catch (e) { }
break;
case 'n4':
try {
CiderAudio.audioNodes.llpw[1].connect(CiderAudio.audioNodes.atmosphereRealizer1);
console.debug("[Cider][Audio] llpw_n1 -> atmosphereRealizer1");
} catch (e) { }
break;
case 'n1':
try {
CiderAudio.audioNodes.llpw[1].connect(CiderAudio.audioNodes.llpw[0]);
console.debug("[Cider][Audio] llpw_n1 -> llpw");
} catch (e) { }
break;
case 'n3':
try { CiderAudio.audioNodes.llpw[1].connect(CiderAudio.audioNodes.vibrantbassNode[0]);
console.debug("[Cider][Audio] llpw_n1 -> vibrantbassNode");} catch (e) { }
break;
case 'n2':
try { CiderAudio.audioNodes.llpw[1].connect(CiderAudio.audioNodes.audioBands[0]); console.debug("[Cider][Audio] llpw_n1 -> audioBands");} catch (e) { }
break;
case 'n0':
try { CiderAudio.audioNodes.llpw.at(-1).connect(CiderAudio.context.destination); console.debug("[Cider][Audio] llpw_n1 -> destination");} catch (e) { }
break;
}
console.debug("[Cider][Audio] CAP - Maikiwi Adaptive Mode (Defaulted from broki config)");
break;
}
switch (destination) {
case "spatial":
try { CiderAudio.audioNodes.llpw.at(-1).connect(CiderAudio.audioNodes.spatialNode); console.debug("[Cider][Audio] llpw_n1 -> Spatial");} catch (e) { }
break;
case "n5":
try {
CiderAudio.audioNodes.llpw.at(-1).connect(CiderAudio.audioNodes.atmosphereRealizer2);
console.debug("[Cider][Audio] llpw_n1 -> atmosphereRealizer2");
} catch (e) { }
break;
case 'n4':
try {
CiderAudio.audioNodes.llpw.at(-1).connect(CiderAudio.audioNodes.atmosphereRealizer1);
console.debug("[Cider][Audio] llpw_n1 -> atmosphereRealizer1");
} catch (e) { }
break;
case 'n3':
try { CiderAudio.audioNodes.llpw.at(-1).connect(CiderAudio.audioNodes.vibrantbassNode[0]);
console.debug("[Cider][Audio] llpw_n1 -> vibrantbassNode");} catch (e) { }
break;
case 'n2':
try { CiderAudio.audioNodes.llpw.at(-1).connect(CiderAudio.audioNodes.audioBands[0]); console.debug("[Cider][Audio] llpw_n1 -> audioBands");} catch (e) { }
break;
case 'n1':
try {
CiderAudio.audioNodes.llpw.at(-1).connect(CiderAudio.audioNodes.llpw[0]);
console.debug("[Cider][Audio] llpw_n1 -> llpw");
} catch (e) { }
break;
case 'n0':
try { CiderAudio.audioNodes.llpw.at(-1).connect(CiderAudio.context.destination); console.debug("[Cider][Audio] llpw_n1 -> destination");} catch (e) { }
break;
}
}
},

View file

@ -868,6 +868,7 @@ const app = new Vue({
try {
//CiderAudio.audioNodes.gainNode.gain.value = (Math.min(Math.pow(10, (replaygain.gain / 20)), (1 / replaygain.peak)))
CiderAudio.audioNodes.gainNode.gain.value = gain
CiderAudio.hierarchical_loading();
} catch (e) {
}
}
@ -937,27 +938,23 @@ const app = new Vue({
self.$refs.queue.updateQueue();
}
this.currentSongInfo = a
if (a === null) {return;} // EVIL EMPTY OBJECTS BE GONE
console.debug("songinfo: " + JSON.stringify(a))
if (app.cfg.advanced.AudioContext) {
try {
if (app.mk.nowPlayingItem.flavor.includes("64")) {
if (localStorage.getItem("playingBitrate") !== "64") {
localStorage.setItem("playingBitrate", "64")
CiderAudio.hierarchical_loading();
}
localStorage.setItem("playingBitrate", "64")
} else if (app.mk.nowPlayingItem.flavor.includes("256")) {
if (localStorage.getItem("playingBitrate") !== "256") {
localStorage.setItem("playingBitrate", "256")
CiderAudio.hierarchical_loading();
}
localStorage.setItem("playingBitrate", "256")
} else {
localStorage.setItem("playingBitrate", "256")
CiderAudio.hierarchical_loading();
}
} catch (e) {
localStorage.setItem("playingBitrate", "256")
CiderAudio.hierarchical_loading();
}
if (!app.cfg.audio.normalization) {CiderAudio.hierarchical_loading();}
}
if (app.cfg.audio.normalization) {
@ -972,14 +969,17 @@ const app = new Vue({
app.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/songs/${app.mk.nowPlayingItem?._songId ?? (app.mk.nowPlayingItem["songId"] ?? app.mk.nowPlayingItem.relationships.catalog.data[0].id)}`).then((response) => {
previewURL = response.data.data[0].attributes.previews[0].url
if (previewURL)
console.debug("[Cider][MaikiwiSoundCheck] previewURL response.data.data[0].attributes.previews[0].url: " + previewURL)
ipcRenderer.send('getPreviewURL', previewURL)
})
} else {
if (previewURL)
console.debug("[Cider][MaikiwiSoundCheck] previewURL in app.mk.nowPlayingItem.previewURL: " + previewURL)
ipcRenderer.send('getPreviewURL', previewURL)
}
} catch (e) {
if (e instanceof TypeError === false) {console.debug("[Cider][MaikiwiSoundCheck] normalizer function err: " + e)}
}
}