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

+107
View File
@@ -0,0 +1,107 @@
/**
* @module commands/bassboost
* @description Quick equalizer bass boost filter with low, medium, and hard presets.
*/
import { CommandBuilder } from "../src/commands/index.mjs";
import { EmbedBuilder } from "@fluxerjs/core";
import { getGlobalColor } from "../src/ui/index.mjs";
export const BASSBOOST_PRESETS = {
low: {
label: "Low",
equalizer: [
{ band: 0, gain: 0.25 },
{ band: 1, gain: 0.20 },
{ band: 2, gain: 0.15 },
{ band: 3, gain: 0.10 },
],
},
medium: {
label: "Medium",
equalizer: [
{ band: 0, gain: 0.60 },
{ band: 1, gain: 0.70 },
{ band: 2, gain: 0.50 },
{ band: 3, gain: 0.25 },
{ band: 4, gain: 0.00 },
{ band: 5, gain: -0.25 },
{ band: 6, gain: -0.45 },
{ band: 7, gain: -0.55 },
{ band: 8, gain: -0.60 },
],
},
hard: {
label: "Hard",
equalizer: [
{ band: 0, gain: 1.00 },
{ band: 1, gain: 1.10 },
{ band: 2, gain: 0.80 },
{ band: 3, gain: 0.50 },
{ band: 4, gain: 0.25 },
{ band: 5, gain: -0.20 },
{ band: 6, gain: -0.45 },
{ band: 7, gain: -0.65 },
{ band: 8, gain: -0.80 },
],
},
};
/**
* @type {CommandBuilder}
* @description Command definition for the bassboost command.
*/
export const command = new CommandBuilder()
.setName("bassboost")
.setDescription("Apply a low, medium, or hard bass boost equalizer effect.", "commands.bassboost")
.setCategory("music")
.addStringOption(o =>
o.setName("level")
.setDescription("Bass boost level: 'low', 'medium', 'hard', or 'off'.")
.setRequired(false)
.addChoices(
{ name: "low", value: "low" },
{ name: "medium", value: "medium" },
{ name: "hard", value: "hard" },
{ name: "off", value: "off" }
)
)
.addAliases("bb", "bass");
/**
* Run handler for the bassboost command.
*
* @param {object} message - The command message wrapper.
* @param {object} data - Parsed command data.
* @returns {Promise<void>}
*/
export async function run(message, data) {
const p = await this.getPlayer(message, false, false, false);
if (!p) return;
const levelArg = data.get("level")?.value?.toLowerCase() || "medium";
const embed = new EmbedBuilder().setColor(getGlobalColor());
if (levelArg === "off" || levelArg === "none" || levelArg === "reset") {
await p.applyFilter({}, null);
embed.setDescription("🔇 Bass boost disabled — restored original audio balance.");
return message.reply({ embeds: [embed] }).catch(() => {});
}
const preset = BASSBOOST_PRESETS[levelArg] || BASSBOOST_PRESETS.medium;
const filterMeta = {
key: `bassboost_${levelArg}`,
label: `Bass Boost (${preset.label})`,
emoji: "🔊",
};
const res = await p.applyFilter({ equalizer: preset.equalizer }, filterMeta);
if (!res.ok) {
embed.setDescription(`❌ Failed to apply bass boost: ${res.reason || "Unknown error"}`);
return message.reply({ embeds: [embed] }).catch(() => {});
}
embed.setDescription(`🔊 Applied **Bass Boost (${preset.label})**! Real-time equalizer active.`);
message.reply({ embeds: [embed] }).catch(() => {});
}
+33
View File
@@ -20,6 +20,20 @@ const FILTERS = [
desc: "Remove all filters — restore original audio",
payload: {},
},
{
emoji: "🔉",
key: "bassboost_low",
label: "Bass Boost (Low)",
desc: "Subtle low-end boost for acoustic & gentle tracks",
payload: {
equalizer: [
{ band: 0, gain: 0.25 },
{ band: 1, gain: 0.20 },
{ band: 2, gain: 0.15 },
{ band: 3, gain: 0.10 },
],
},
},
{
emoji: "🔊",
key: "bassboost",
@@ -44,6 +58,25 @@ const FILTERS = [
],
},
},
{
emoji: "💥",
key: "bassboost_hard",
label: "Bass Boost (Hard)",
desc: "Maximum sub-bass boost — skull-shattering low end",
payload: {
equalizer: [
{ band: 0, gain: 1.00 },
{ band: 1, gain: 1.10 },
{ band: 2, gain: 0.80 },
{ band: 3, gain: 0.50 },
{ band: 4, gain: 0.25 },
{ band: 5, gain: -0.20 },
{ band: 6, gain: -0.45 },
{ band: 7, gain: -0.65 },
{ band: 8, gain: -0.80 },
],
},
},
{
emoji: "🌙",
key: "nightcore",
+94
View File
@@ -0,0 +1,94 @@
/**
* @module commands/normalize
* @description Toggle dynamic volume normalization & ReplayGain leveling (EBU R128 standard).
* Prevents ear-blasting volume differences between YouTube, Spotify, and SoundCloud.
*/
import { CommandBuilder } from "../src/commands/index.mjs";
import { EmbedBuilder } from "@fluxerjs/core";
import { getGlobalColor } from "../src/ui/index.mjs";
import { calculateNormalizationGain, detectTrackSource } from "../src/music/audio/VolumeNormalizer.mjs";
/**
* @type {CommandBuilder}
* @description Command definition for the normalize command.
*/
export const command = new CommandBuilder()
.setName("normalize")
.setDescription("Toggle dynamic volume normalization (ReplayGain leveling) across music sources.", "commands.normalize")
.setCategory("music")
.addStringOption(o =>
o.setName("state")
.setDescription("Turn on/off or check status ('on', 'off', 'status'). Omit to toggle.")
.setRequired(false)
.addChoices(
{ name: "on", value: "on" },
{ name: "off", value: "off" },
{ name: "status", value: "status" }
)
)
.addAliases("replaygain", "volumenormalize", "norm");
/**
* Run handler for the normalize command.
*
* @param {object} message - The command message wrapper.
* @param {object} data - Parsed command data.
* @returns {Promise<void>}
*/
export async function run(message, data) {
const p = await this.getPlayer(message, false, false, false);
const guildSettings = this.getSettings ? this.getSettings(message) : null;
const currentSetting = guildSettings?.get ? (guildSettings.get("normalize") ?? true) : true;
const stateArg = data.get("state")?.value?.toLowerCase();
let newState;
if (stateArg === "status") {
newState = currentSetting;
} else if (stateArg === "on" || stateArg === "enable" || stateArg === "true") {
newState = true;
} else if (stateArg === "off" || stateArg === "disable" || stateArg === "false") {
newState = false;
} else {
// Toggle
newState = !currentSetting;
}
if (stateArg !== "status") {
if (guildSettings?.set) {
guildSettings.set("normalize", newState);
}
if (p) {
p.volumeNormalization = newState;
if (p._voiceConn) {
try {
p._voiceConn.setVolume(p.getEffectiveVolume());
} catch (_) {}
}
}
}
const embed = new EmbedBuilder().setColor(getGlobalColor());
const statusEmoji = newState ? "🔊" : "🔇";
const statusText = newState ? "**Enabled**" : "**Disabled**";
let desc = `${statusEmoji} Volume normalization (ReplayGain) is currently ${statusText} for this server.\n\n` +
`*When enabled, playback loudness is dynamically leveled to the international -14 LUFS standard so quiet acoustic songs and loud EDM/SoundCloud tracks play at a balanced listening volume.*`;
if (p) {
const current = p.queue?.getCurrent?.();
if (current) {
const source = detectTrackSource(current);
const gain = calculateNormalizationGain(current);
const gainDb = (20 * Math.log10(gain)).toFixed(1);
const gainSign = gain >= 1 ? "+" : "";
desc += `\n\n**Current Track Info:**\n` +
`• Source: \`${source}\`\n` +
`• Gain adjustment: \`${gainSign}${gainDb} dB\` (${(gain * 100).toFixed(0)}%)\n` +
`• Effective volume: \`${Math.round(p.getEffectiveVolume())}%\``;
}
}
message.reply({ embeds: [embed.setDescription(desc)] }).catch(() => {});
}
+83
View File
@@ -0,0 +1,83 @@
/**
* @module commands/pitch
* @description Adjust real-time audio pitch (0.5× to 2.0×) using timescale DSP filters.
*/
import { CommandBuilder } from "../src/commands/index.mjs";
import { EmbedBuilder } from "@fluxerjs/core";
import { getGlobalColor } from "../src/ui/index.mjs";
import { Utils } from "../src/utils/Utils.mjs";
/**
* @type {CommandBuilder}
* @description Command definition for the pitch command.
*/
export const command = new CommandBuilder()
.setName("pitch")
.setDescription("Adjust the audio pitch of the current track (0.5× to 2.0×).", "commands.pitch")
.setCategory("music")
.addNumberOption(o =>
o.setName("pitch")
.setDescription("Audio pitch multiplier between 0.5 and 2.0 (e.g. 1.25). Omit to reset to 1.0×.")
.setRequired(false)
)
.addAliases("semitone", "tune");
/**
* Run handler for the pitch command.
*
* @param {object} message - The command message wrapper.
* @param {object} data - Parsed command data.
* @returns {Promise<void>}
*/
export async function run(message, data) {
const p = await this.getPlayer(message, false, false, false);
if (!p) return;
const rawPitch = data.get("pitch")?.value;
const embed = new EmbedBuilder().setColor(getGlobalColor());
if (rawPitch === null || rawPitch === undefined || isNaN(Number(rawPitch))) {
const currentTimescale = p.activeFilterPayload?.timescale;
const currentPitch = currentTimescale?.pitch ?? 1.0;
if (currentPitch !== 1.0) {
const existingPayload = { ...(p.activeFilterPayload || {}) };
delete existingPayload.timescale;
await p.applyFilter(existingPayload, Object.keys(existingPayload).length > 0 ? p.activeFilter : null);
embed.setDescription("🎵 Audio pitch reset to normal **1.0×**.");
} else {
embed.setDescription(`🎵 Current audio pitch: **1.0×**.\nUse \`%pitch <0.5-2.0>\` to change pitch.`);
}
return message.reply({ embeds: [embed] }).catch(() => {});
}
const pitch = Utils.clamp(Number(rawPitch), 0.5, 2.0);
const existingTimescale = p.activeFilterPayload?.timescale || {};
const newTimescale = {
...existingTimescale,
speed: existingTimescale.speed ?? 1.0,
pitch,
rate: 1.0,
};
const payload = {
...(p.activeFilterPayload || {}),
timescale: newTimescale,
};
const filterMeta = {
key: `pitch_${pitch}`,
label: `${pitch}× Pitch`,
emoji: pitch > 1 ? "🐿️" : "🗣️",
};
const res = await p.applyFilter(payload, filterMeta);
if (!res.ok) {
embed.setDescription(`❌ Failed to adjust pitch: ${res.reason || "Unknown error"}`);
return message.reply({ embeds: [embed] }).catch(() => {});
}
embed.setDescription(`🎵 Audio pitch set to **${pitch}×**.`);
message.reply({ embeds: [embed] }).catch(() => {});
}
+86
View File
@@ -0,0 +1,86 @@
/**
* @module commands/speed
* @description Adjust real-time playback speed (0.5× to 2.0×) using timescale DSP filters.
*/
import { CommandBuilder } from "../src/commands/index.mjs";
import { EmbedBuilder } from "@fluxerjs/core";
import { getGlobalColor } from "../src/ui/index.mjs";
import { Utils } from "../src/utils/Utils.mjs";
/**
* @type {CommandBuilder}
* @description Command definition for the speed command.
*/
export const command = new CommandBuilder()
.setName("speed")
.setDescription("Adjust the playback speed of the current track (0.5× to 2.0×).", "commands.speed")
.setCategory("music")
.addNumberOption(o =>
o.setName("rate")
.setDescription("Playback speed multiplier between 0.5 and 2.0 (e.g. 1.25). Omit to reset to 1.0×.")
.setRequired(false)
)
.addAliases("rate", "tempo");
/**
* Run handler for the speed command.
*
* @param {object} message - The command message wrapper.
* @param {object} data - Parsed command data.
* @returns {Promise<void>}
*/
export async function run(message, data) {
const p = await this.getPlayer(message, false, false, false);
if (!p) return;
const rawRate = data.get("rate")?.value;
const embed = new EmbedBuilder().setColor(getGlobalColor());
if (rawRate === null || rawRate === undefined || isNaN(Number(rawRate))) {
// Reset to 1.0 or show current speed
const currentTimescale = p.activeFilterPayload?.timescale;
const currentSpeed = currentTimescale?.speed ?? 1.0;
if (currentSpeed !== 1.0) {
// Reset
const existingPayload = { ...(p.activeFilterPayload || {}) };
delete existingPayload.timescale;
await p.applyFilter(existingPayload, Object.keys(existingPayload).length > 0 ? p.activeFilter : null);
embed.setDescription("⏩ Playback speed reset to normal **1.0×**.");
} else {
embed.setDescription(`⏩ Current playback speed: **1.0×**.\nUse \`%speed <0.5-2.0>\` to change playback speed.`);
}
return message.reply({ embeds: [embed] }).catch(() => {});
}
const speed = Utils.clamp(Number(rawRate), 0.5, 2.0);
// Preserve other active filters if present, update only timescale speed
const existingTimescale = p.activeFilterPayload?.timescale || {};
const newTimescale = {
...existingTimescale,
speed,
pitch: existingTimescale.pitch ?? 1.0,
rate: 1.0,
};
const payload = {
...(p.activeFilterPayload || {}),
timescale: newTimescale,
};
const filterMeta = {
key: `speed_${speed}`,
label: `${speed}× Speed`,
emoji: speed > 1 ? "⏩" : "🐢",
};
const res = await p.applyFilter(payload, filterMeta);
if (!res.ok) {
embed.setDescription(`❌ Failed to adjust speed: ${res.reason || "Unknown error"}`);
return message.reply({ embeds: [embed] }).catch(() => {});
}
embed.setDescription(`${speed > 1 ? "⏩" : "🐢"} Playback speed set to **${speed}×**.`);
message.reply({ embeds: [embed] }).catch(() => {});
}