use SoundCheck/ReplayGain for normalization

This commit is contained in:
vapormusic 2021-12-29 23:16:52 +07:00
parent f777f832e4
commit 610633b9e3
4 changed files with 51 additions and 25 deletions

View file

@ -9,6 +9,8 @@ const yt = require('youtube-search-without-api-key');
const discord = require('./discordrpc');
const lastfm = require('./lastfm');
const mpris = require('./mpris');
const mm = require('music-metadata');
const fetch = require('electron-fetch').default;
// Analytics for debugging.
const ElectronSentry = require("@sentry/electron");
@ -216,6 +218,7 @@ const CiderBase = {
lastfm.scrobbleSong(a)
lastfm.updateNowPlayingSong(a)
});
ipcMain.on('nowPlayingItemDidChange', (_event, a) => {
app.media = a;
discord.updateActivity(a)
@ -224,6 +227,21 @@ const CiderBase = {
lastfm.updateNowPlayingSong(a)
});
ipcMain.on("getPreviewURL", (_event, url) => {
fetch(url)
.then(res => res.buffer())
.then(async (buffer) => {
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);
}
})
});
return win
},