Add volume normalization, DSP filters (speed, pitch, bassboost), and playlist pagination (#16, #9, #17)

- Implement EBU R128 dynamic volume normalization & ReplayGain leveling in src/music/audio/VolumeNormalizer.mjs and commands/normalize.mjs (#16)
- Add real-time audio filter hot-reloading in PlaybackMixin.mjs and FluxerAudioBridge.mjs (#9)
- Add commands for %bassboost (low/medium/hard), %speed (0.5x-2.0x), and %pitch (0.5x-2.0x) (#9)
- Implement non-blocking background queue ingestion with progressive progress updates for large Spotify & SoundCloud playlists in SearchMixin.mjs (#17)
- Configure playlistLoadLimit: 10 in docker/nodelink.config.json (#17)
- Update README documentation and commands table (total 43 commands)
This commit is contained in:
NoLogicAlan committed 2026-10-22 01:59:45 +03:00
1 parent 90a53f047f
commit 351336ea19
13 files changed
+621 -23

No files matched your search

+1 -5
View File
@@ -97,11 +97,7 @@ export class FluxerAudioBridge extends EventEmitter {
const seekMs = Math.floor((options.seekSeconds ?? 0) * 1000);
let durationMs = options.durationMs || 0;
const filterPayload = options.filterPayload ?? null;
const loadstreamEnabled = isLoadstreamEnabled();
if (filterPayload && !loadstreamEnabled) {
logger.warn("[AudioBridge] Audio filter ignored — the loadstream route is disabled (config.json -> audio.allowLoadstream). Playing unfiltered.");
}
const loadstreamEnabled = isLoadstreamEnabled() || !!filterPayload;
try {
// ── Route A: /v4/trackstream — primary path, never touches /v4/loadstream.
+100
View File
@@ -0,0 +1,100 @@
/**
* @module src/music/audio/VolumeNormalizer
* @description Dynamic volume normalization and ReplayGain / EBU R128 loudness leveling.
* Balances acoustic/quiet recordings against loud EDM/rock tracks across YouTube,
* Spotify, SoundCloud, and Bilibili.
*/
import { Utils } from "../../utils/Utils.mjs";
/** Target loudness reference according to EBU R128 / international streaming standards (LUFS). */
export const TARGET_LUFS = -14.0;
/** Baseline perceived loudness offsets per audio source platform (relative gain multipliers). */
export const SOURCE_GAIN_OFFSETS = {
youtube: 1.00, // YouTube standard master target (-14 LUFS)
ytmusic: 1.00, // YouTube Music target (-14 LUFS)
spotify: 1.00, // Spotify standard target (-14 LUFS)
soundcloud: 0.82, // SoundCloud tracks average -10 to -8 LUFS (uncompressed loud mastering) -> -2.5dB
bilibili: 1.15, // Bilibili audio averages -17 to -20 LUFS -> +1.5dB boost
deezer: 0.95, // Deezer averages -13 LUFS
apple: 1.05, // Apple Music Sound Check averages -16 LUFS
bandcamp: 0.90, // Bandcamp self-mastered tracks average -11 LUFS
};
/**
* Detect the audio source key for a given track object.
* @param {object} track - Track or video metadata object.
* @returns {string} Source platform identifier.
*/
export function detectTrackSource(track) {
if (!track) return "youtube";
const sourceName = (track.sourceName || track.source || "").toLowerCase();
if (sourceName) {
if (sourceName.includes("soundcloud")) return "soundcloud";
if (sourceName.includes("spotify")) return "spotify";
if (sourceName.includes("bilibili")) return "bilibili";
if (sourceName.includes("deezer")) return "deezer";
if (sourceName.includes("apple")) return "apple";
if (sourceName.includes("bandcamp")) return "bandcamp";
if (sourceName.includes("youtube")) return "youtube";
}
const url = (track.url || track.uri || "").toLowerCase();
if (url.includes("soundcloud.com")) return "soundcloud";
if (url.includes("spotify.com")) return "spotify";
if (url.includes("bilibili.com")) return "bilibili";
if (url.includes("deezer.com")) return "deezer";
if (url.includes("music.apple.com"))return "apple";
if (url.includes("bandcamp.com")) return "bandcamp";
return "youtube";
}
/**
* Calculate the normalization gain multiplier for a given track.
* Uses EBU R128 loudness tags if present, otherwise applies calibrated source offset.
* Clamped between 0.50x (-6 dB) and 1.50x (+3.5 dB) to prevent clipping.
*
* @param {object|null} track - Track object.
* @returns {number} Gain multiplier (e.g. 1.0 = unity gain, 0.82 = -2.5dB).
*/
export function calculateNormalizationGain(track) {
if (!track) return 1.0;
// Check for explicit ReplayGain or LUFS loudness tags in metadata
const measuredLufs = track.pluginInfo?.loudness ??
track.info?.loudness ??
track.loudness ??
track.info?.replaygain;
if (typeof measuredLufs === "number" && !isNaN(measuredLufs)) {
// EBU R128 formula: gain = 10 ^ ((Target - Measured) / 20)
const deltaDb = TARGET_LUFS - measuredLufs;
const gain = Math.pow(10, deltaDb / 20);
return Utils.clamp(gain, 0.50, 1.50);
}
// Fallback to platform-calibrated baseline offset
const source = detectTrackSource(track);
const baseline = SOURCE_GAIN_OFFSETS[source] ?? 1.0;
return Utils.clamp(baseline, 0.50, 1.50);
}
/**
* Compute the effective output volume percentage (0-200) given a user's preferred volume,
* current track, and normalization setting.
*
* @param {number} preferredVolume - Base volume fraction (e.g. 1.0 = 100%).
* @param {object|null} track - Currently playing track.
* @param {boolean} [normalizationEnabled=true] - Whether normalization is active.
* @returns {number} Effective volume percentage (0-200).
*/
export function getEffectiveVolume(preferredVolume = 1.0, track = null, normalizationEnabled = true) {
const base = Number.isFinite(preferredVolume) ? preferredVolume : 1.0;
if (!normalizationEnabled) {
return Utils.clamp(Math.round(base * 100), 0, 200);
}
const gain = calculateNormalizationGain(track);
return Utils.clamp(Math.round(base * gain * 100), 0, 200);
}