[Audio] Added CAP & Normalization behavior for local files

This commit is contained in:
maikirakiwi 2022-07-02 23:58:21 -07:00
parent d4f0b32c15
commit c9ba30df06
2 changed files with 23 additions and 18 deletions

View file

@ -721,18 +721,12 @@ const CiderAudio = {
let bufferedImpulse = await impulseData.arrayBuffer();
CiderAudio.audioNodes.llpw[0].buffer = await CiderAudio.context.decodeAudioData(bufferedImpulse);
});
console.debug("[Cider][Audio] CAP Adaptive - 256kbps_2_48k");
console.debug("[Cider][Audio] CAP Adaptive - 256kbps");
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");
CiderAudio.audioNodes.llpw[0] = CiderAudio.context.createGain(); CiderAudio.audioNodes.llpw[0].gain.value = 1
console.debug("[Cider][Audio] CAP Disabled (Passthrough) : Non-Lossy Bitrate.");
break;
}

View file

@ -956,17 +956,20 @@ const app = new Vue({
if (self.$refs.queue) {
self.$refs.queue.updateQueue();
}
this.currentSongInfo = a
this.currentSongInfo = a;
if (this.currentSongInfo === null || this.currentSongInfo === undefined) { return; } // EVIL EMPTY OBJECTS BE GONE
let localFiles = false;
try {
if (app.mk.nowPlayingItem.flavor.includes("64")) {
if (app.mk.nowPlayingItem.flavor.includes("64") && app.mk.nowPlayingItem.flavor.includes(":")) {
localStorage.setItem("playingBitrate", "64")
} else if (app.mk.nowPlayingItem.flavor.includes("256")) {
} else if (app.mk.nowPlayingItem.flavor.includes("256") && app.mk.nowPlayingItem.flavor.includes(":")) {
localStorage.setItem("playingBitrate", "256")
} else {
localStorage.setItem("playingBitrate", "256")
localFiles = true;
localStorage.setItem("playingBitrate", app.mk.nowPlayingItem.flavor)
}
} catch (e) {
console.error(e)
localStorage.setItem("playingBitrate", "256")
}
if (!app.cfg.audio.normalization) { CiderAudio.hierarchical_loading(); }
@ -978,22 +981,30 @@ const app = new Vue({
try {
previewURL = app.mk.nowPlayingItem.previewURL
} catch (e) {
if (e instanceof TypeError === false) { console.debug("[Cider][MaikiwiSoundCheck] normalizer function err: " + e) }
else {
if (localFiles === true) {CiderAudio.audioNodes.gainNode.gain = 0.8222426499470}
}
}
if (previewURL == null && ((app.mk.nowPlayingItem?._songId ?? (app.mk.nowPlayingItem["songId"] ?? app.mk.nowPlayingItem.relationships.catalog.data[0].id)) != -1)) {
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)
if (previewURL) {
console.debug("[Cider][MaikiwiSoundCheck] previewURL response.data.data[0].attributes.previews[0].url: " + previewURL)
ipcRenderer.send('getPreviewURL', previewURL)
}
})
} else {
if (previewURL)
if (previewURL) {
console.debug("[Cider][MaikiwiSoundCheck] previewURL in app.mk.nowPlayingItem.previewURL: " + previewURL)
ipcRenderer.send('getPreviewURL', previewURL)
ipcRenderer.send('getPreviewURL', previewURL)}
}
} catch (e) {
if (e instanceof TypeError === false) { console.debug("[Cider][MaikiwiSoundCheck] normalizer function err: " + e) }
else {
if (localFiles === true) {CiderAudio.audioNodes.gainNode.gain = 0.8222426499470}
}
}
}