fix normalization on library songs
This commit is contained in:
parent
2dd13756b4
commit
be6ccbada7
4 changed files with 92 additions and 77 deletions
|
@ -33,7 +33,6 @@
|
||||||
"express": "^4.17.2",
|
"express": "^4.17.2",
|
||||||
"get-port": "^5.1.1",
|
"get-port": "^5.1.1",
|
||||||
"lastfmapi": "^0.1.1",
|
"lastfmapi": "^0.1.1",
|
||||||
"media-metadata": "^2.1.0",
|
|
||||||
"mpris-service": "^2.1.2",
|
"mpris-service": "^2.1.2",
|
||||||
"music-metadata": "^7.11.4",
|
"music-metadata": "^7.11.4",
|
||||||
"react": "^17.0.2",
|
"react": "^17.0.2",
|
||||||
|
|
|
@ -234,7 +234,6 @@ const CiderBase = {
|
||||||
try {
|
try {
|
||||||
const metadata = await mm.parseBuffer(buffer, 'audio/x-m4a');
|
const metadata = await mm.parseBuffer(buffer, 'audio/x-m4a');
|
||||||
SoundCheckTag = metadata.native.iTunes[1].value
|
SoundCheckTag = metadata.native.iTunes[1].value
|
||||||
console.log(SoundCheckTag)
|
|
||||||
win.webContents.send('SoundCheckTag',SoundCheckTag)
|
win.webContents.send('SoundCheckTag',SoundCheckTag)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error.message);
|
console.error(error.message);
|
||||||
|
|
|
@ -351,7 +351,7 @@ const app = new Vue({
|
||||||
let self = this
|
let self = this
|
||||||
clearTimeout(this.hangtimer)
|
clearTimeout(this.hangtimer)
|
||||||
this.mk = MusicKit.getInstance()
|
this.mk = MusicKit.getInstance()
|
||||||
this.mk.authorize().then(()=>{
|
this.mk.authorize().then(() => {
|
||||||
self.mkIsReady = true
|
self.mkIsReady = true
|
||||||
})
|
})
|
||||||
this.$forceUpdate()
|
this.$forceUpdate()
|
||||||
|
@ -400,21 +400,21 @@ const app = new Vue({
|
||||||
};
|
};
|
||||||
|
|
||||||
// Load saved quality
|
// Load saved quality
|
||||||
switch (app.cfg.audio.quality){
|
switch (app.cfg.audio.quality) {
|
||||||
case "extreme":
|
case "extreme":
|
||||||
app.mk.bitrate = app.cfg.audio.quality = 990
|
app.mk.bitrate = app.cfg.audio.quality = 990
|
||||||
break;
|
break;
|
||||||
case "high":
|
case "high":
|
||||||
app.mk.bitrate = app.cfg.audio.quality = 256
|
app.mk.bitrate = app.cfg.audio.quality = 256
|
||||||
break;
|
break;
|
||||||
case "low":
|
case "low":
|
||||||
app.mk.bitrate = app.cfg.audio.quality = 64
|
app.mk.bitrate = app.cfg.audio.quality = 64
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
app.mk.bitrate = app.cfg.audio.quality
|
app.mk.bitrate = app.cfg.audio.quality
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// load last played track
|
// load last played track
|
||||||
try {
|
try {
|
||||||
|
@ -464,13 +464,12 @@ const app = new Vue({
|
||||||
MusicKit.getInstance().videoContainerElement = document.getElementById("apple-music-video-player")
|
MusicKit.getInstance().videoContainerElement = document.getElementById("apple-music-video-player")
|
||||||
|
|
||||||
ipcRenderer.on('SoundCheckTag', (event, tag) => {
|
ipcRenderer.on('SoundCheckTag', (event, tag) => {
|
||||||
console.log(tag)
|
let replaygain = self.parseSCTagToRG(tag)
|
||||||
let replaygain = self.parseSCTagToRG(tag)
|
try {
|
||||||
try {
|
CiderAudio.audioNodes.gainNode.gain.value = (Math.min(Math.pow(10, (replaygain.gain / 20)), (1 / replaygain.peak)))
|
||||||
CiderAudio.audioNodes.gainNode.gain.value = ( Math.min(Math.pow(10, (replaygain.gain / 20)), (1 / replaygain.peak)))
|
} catch (e) {
|
||||||
} catch (e){
|
|
||||||
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
this.mk.addEventListener(MusicKit.Events.playbackTimeDidChange, (a) => {
|
this.mk.addEventListener(MusicKit.Events.playbackTimeDidChange, (a) => {
|
||||||
|
@ -484,15 +483,33 @@ const app = new Vue({
|
||||||
self.$refs.queue.updateQueue();
|
self.$refs.queue.updateQueue();
|
||||||
}
|
}
|
||||||
this.currentSongInfo = a
|
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 {
|
try {
|
||||||
a = a.item.attributes;
|
a = a.item.attributes;
|
||||||
} catch (_) {
|
} 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"] ?? '' : '';
|
let type = (self.mk.nowPlayingItem != null) ? self.mk.nowPlayingItem["type"] ?? '' : '';
|
||||||
|
|
||||||
if (type.includes("musicVideo") || type.includes("uploadedVideo") || type.includes("music-movie")) {
|
if (type.includes("musicVideo") || type.includes("uploadedVideo") || type.includes("music-movie")) {
|
||||||
|
@ -532,7 +549,7 @@ const app = new Vue({
|
||||||
document.body.removeAttribute("loading")
|
document.body.removeAttribute("loading")
|
||||||
if (window.location.hash != "") {
|
if (window.location.hash != "") {
|
||||||
this.appRoute(window.location.hash)
|
this.appRoute(window.location.hash)
|
||||||
}else{
|
} else {
|
||||||
this.page = "home"
|
this.page = "home"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -916,8 +933,9 @@ const app = new Vue({
|
||||||
window.location.hash = `${kind}/${id}`
|
window.location.hash = `${kind}/${id}`
|
||||||
document.querySelector("#app-content").scrollTop = 0
|
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")) {
|
} 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.page = (kind) + "_" + (id);
|
||||||
app.getTypeFromID((kind), (id), (isLibrary), { extend: "editorialVideo" });
|
app.getTypeFromID((kind), (id), (isLibrary), params);
|
||||||
window.location.hash = `${kind}/${id}`
|
window.location.hash = `${kind}/${id}`
|
||||||
document.querySelector("#app-content").scrollTop = 0
|
document.querySelector("#app-content").scrollTop = 0
|
||||||
} else {
|
} else {
|
||||||
|
@ -2485,53 +2503,52 @@ const app = new Vue({
|
||||||
}
|
}
|
||||||
CiderContextMenu.Create(event, menus[useMenu])
|
CiderContextMenu.Create(event, menus[useMenu])
|
||||||
},
|
},
|
||||||
LastFMDeauthorize() {
|
LastFMDeauthorize() {
|
||||||
ipcRenderer.invoke('setStoreValue', 'lastfm.enabled', false).catch((e) => console.error(e));
|
ipcRenderer.invoke('setStoreValue', 'lastfm.enabled', false).catch((e) => console.error(e));
|
||||||
ipcRenderer.invoke('setStoreValue', 'lastfm.auth_token', '').catch((e) => console.error(e));
|
ipcRenderer.invoke('setStoreValue', 'lastfm.auth_token', '').catch((e) => console.error(e));
|
||||||
app.cfg.lastfm.auth_token = "";
|
app.cfg.lastfm.auth_token = "";
|
||||||
app.cfg.lastfm.enabled = false;
|
app.cfg.lastfm.enabled = false;
|
||||||
const element = document.getElementById('lfmConnect');
|
const element = document.getElementById('lfmConnect');
|
||||||
element.innerHTML = 'Connect';
|
element.innerHTML = 'Connect';
|
||||||
element.onclick = app.LastFMAuthenticate;
|
element.onclick = app.LastFMAuthenticate;
|
||||||
},
|
},
|
||||||
LastFMAuthenticate() {
|
LastFMAuthenticate() {
|
||||||
console.log("wag")
|
console.log("wag")
|
||||||
const element = document.getElementById('lfmConnect');
|
const element = document.getElementById('lfmConnect');
|
||||||
window.open('https://www.last.fm/api/auth?api_key=174905d201451602407b428a86e8344d&cb=ame://auth/lastfm');
|
window.open('https://www.last.fm/api/auth?api_key=174905d201451602407b428a86e8344d&cb=ame://auth/lastfm');
|
||||||
element.innerText = 'Connecting...';
|
element.innerText = 'Connecting...';
|
||||||
|
|
||||||
/* Just a timeout for the button */
|
/* Just a timeout for the button */
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (element.innerText === 'Connecting...') {
|
if (element.innerText === 'Connecting...') {
|
||||||
element.innerText = 'Connect';
|
element.innerText = 'Connect';
|
||||||
console.warn('[LastFM] Attempted connection timed out.');
|
console.warn('[LastFM] Attempted connection timed out.');
|
||||||
}
|
}
|
||||||
}, 20000);
|
}, 20000);
|
||||||
|
|
||||||
|
ipcRenderer.on('LastfmAuthenticated', function (_event, lfmAuthKey) {
|
||||||
|
app.cfg.lastfm.auth_token = lfmAuthKey;
|
||||||
|
app.cfg.lastfm.enabled = true;
|
||||||
|
element.innerHTML = `Disconnect\n<p style="font-size: 8px"><i>(Authed: ${lfmAuthKey})</i></p>`;
|
||||||
|
element.onclick = app.LastFMDeauthorize;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
parseSCTagToRG: function (tag) {
|
||||||
|
let soundcheck = tag.split(" ")
|
||||||
|
let numbers = []
|
||||||
|
for (item of soundcheck) {
|
||||||
|
numbers.push(parseInt(item, 16))
|
||||||
|
|
||||||
ipcRenderer.on('LastfmAuthenticated', function (_event, lfmAuthKey) {
|
|
||||||
app.cfg.lastfm.auth_token = lfmAuthKey;
|
|
||||||
app.cfg.lastfm.enabled = true;
|
|
||||||
element.innerHTML = `Disconnect\n<p style="font-size: 8px"><i>(Authed: ${lfmAuthKey})</i></p>`;
|
|
||||||
element.onclick = app.LastFMDeauthorize;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
parseSCTagToRG: function(tag){
|
|
||||||
let soundcheck = tag.split(" ")
|
|
||||||
let numbers = []
|
|
||||||
for (item of soundcheck){
|
|
||||||
numbers.push(parseInt(item, 16))
|
|
||||||
|
|
||||||
}
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
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
|
||||||
|
return {
|
||||||
|
gain: gain,
|
||||||
|
peak: peak
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -6,11 +6,11 @@
|
||||||
<h3>Home</h3>
|
<h3>Home</h3>
|
||||||
<div class="well profile-well">
|
<div class="well profile-well">
|
||||||
<div class="user-icon">
|
<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>
|
size="300"></mediaitem-artwork>
|
||||||
</div>
|
</div>
|
||||||
<h3 class="name">{{ profile.attributes.name }}</h3>
|
<h3 class="name" >{{ (profile && profile.attributes && profile.attributes.name) ? profile.attributes.name : "" }}</h3>
|
||||||
<h4 class="handle">@{{ profile.attributes.handle }}</h4>
|
<h4 class="handle">@{{ (profile && profile.attributes && profile.attributes.handler) ? profile.attributes.handle : "" }}</h4>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue