fix normalization on library songs

This commit is contained in:
vapormusic 2021-12-30 09:42:11 +07:00
parent 2dd13756b4
commit be6ccbada7
4 changed files with 92 additions and 77 deletions

View file

@ -33,7 +33,6 @@
"express": "^4.17.2",
"get-port": "^5.1.1",
"lastfmapi": "^0.1.1",
"media-metadata": "^2.1.0",
"mpris-service": "^2.1.2",
"music-metadata": "^7.11.4",
"react": "^17.0.2",

View file

@ -234,7 +234,6 @@ const CiderBase = {
try {
const metadata = await mm.parseBuffer(buffer, 'audio/x-m4a');
SoundCheckTag = metadata.native.iTunes[1].value
console.log(SoundCheckTag)
win.webContents.send('SoundCheckTag',SoundCheckTag)
} catch (error) {
console.error(error.message);

View file

@ -464,7 +464,6 @@ const app = new Vue({
MusicKit.getInstance().videoContainerElement = document.getElementById("apple-music-video-player")
ipcRenderer.on('SoundCheckTag', (event, tag) => {
console.log(tag)
let replaygain = self.parseSCTagToRG(tag)
try {
CiderAudio.audioNodes.gainNode.gain.value = (Math.min(Math.pow(10, (replaygain.gain / 20)), (1 / replaygain.peak)))
@ -484,15 +483,33 @@ const app = new Vue({
self.$refs.queue.updateQueue();
}
this.currentSongInfo = a
if (app.cfg.audio.normalization) {
// get unencrypted audio previews to get SoundCheck's normalization tag
try {
let previewURL = null
try {
previewURL = app.mk.nowPlayingItem.previewURL
} catch (e) { }
if (!previewURL) {
app.mk.api.song(app.mk.nowPlayingItem._songId ?? app.mk.nowPlayingItem.relationships.catalog.data[0].id).then((response) => {
previewURL = response.attributes.previews[0].url
if (previewURL)
ipcRenderer.send('getPreviewURL', previewURL)
})
} else {
if (previewURL)
ipcRenderer.send('getPreviewURL', previewURL)
}
} catch (e) { }
}
try {
a = a.item.attributes;
} catch (_) {
}
if (app.cfg.audio.normalization){
try{ ipcRenderer.send('getPreviewURL', self.mk.nowPlayingItem.previewURL)} catch(e){}
}
let type = (self.mk.nowPlayingItem != null) ? self.mk.nowPlayingItem["type"] ?? '' : '';
if (type.includes("musicVideo") || type.includes("uploadedVideo") || type.includes("music-movie")) {
@ -916,8 +933,9 @@ const app = new Vue({
window.location.hash = `${kind}/${id}`
document.querySelector("#app-content").scrollTop = 0
} else if (!kind.toString().includes("radioStation") && !kind.toString().includes("song") && !kind.toString().includes("musicVideo") && !kind.toString().includes("uploadedVideo") && !kind.toString().includes("music-movie")) {
let params = { extend: "editorialVideo" }
app.page = (kind) + "_" + (id);
app.getTypeFromID((kind), (id), (isLibrary), { extend: "editorialVideo" });
app.getTypeFromID((kind), (id), (isLibrary), params);
window.location.hash = `${kind}/${id}`
document.querySelector("#app-content").scrollTop = 0
} else {
@ -2525,7 +2543,6 @@ const app = new Vue({
numbers.shift()
let gain = Math.log10((Math.max(numbers[0], numbers[1]) ?? 1000) / 1000.0) * -10
let peak = Math.max(numbers[6], numbers[7]) / 32768.0
console.log(gain,peak)
return {
gain: gain,
peak: peak

View file

@ -6,11 +6,11 @@
<h3>Home</h3>
<div class="well profile-well">
<div class="user-icon">
<mediaitem-artwork shadow="none" :url="profile.attributes.artwork.url"
<mediaitem-artwork shadow="none" :url="(profile && profile.attributes && profile.attributes.artwork) ? profile.attributes.artwork.url : ''"
size="300"></mediaitem-artwork>
</div>
<h3 class="name">{{ profile.attributes.name }}</h3>
<h4 class="handle">@{{ profile.attributes.handle }}</h4>
<h3 class="name" >{{ (profile && profile.attributes && profile.attributes.name) ? profile.attributes.name : "" }}</h3>
<h4 class="handle">@{{ (profile && profile.attributes && profile.attributes.handler) ? profile.attributes.handle : "" }}</h4>
</div>
</div>
<div class="col">