From 21b15a10a03d1f8df243c09afa18c7b9fb00247b Mon Sep 17 00:00:00 2001 From: Marius Begby Date: Mon, 24 Jul 2023 13:21:28 +0200 Subject: [PATCH] fix: Added Normalizer as filter, fixed bug with bassboost filter enabling normalizing filter not working properly --- src/commands/player/filters.js | 20 ++++++++++++-------- src/config_example.js | 6 ++++++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/commands/player/filters.js b/src/commands/player/filters.js index 90fc4ae..94ee366 100644 --- a/src/commands/player/filters.js +++ b/src/commands/player/filters.js @@ -132,14 +132,18 @@ module.exports = { }); } - let filtersToEnable = confirmation.values; - // if bassboost is enabled, also enable normalizer to avoid distrorion - if (confirmation.values.includes('bassboost_low') || confirmation.values.includes('bassboost')) { - filtersToEnable.push('normalizer'); + let filtersEnabledByUser = [...confirmation.values]; + + // if bassboost is enabled and not normalizer, also enable normalizer to avoid distrorion + if ( + (confirmation.values.includes('bassboost_low') || confirmation.values.includes('bassboost')) && + !confirmation.values.includes('normalizer') + ) { + confirmation.values.push('normalizer'); } // Enable provided filters - queue.filters.ffmpeg.toggle(filtersToEnable); + queue.filters.ffmpeg.toggle(confirmation.values); logger.debug( `[Shard ${interaction.guild.shardId}] Enabled filters ${confirmation.values.join(', ')} for command ${ @@ -157,12 +161,12 @@ module.exports = { .setDescription( `**${ embedOptions.icons.success - } Filters toggled**\nNow using these filters:\n${confirmation.values + } Filters toggled**\nNow using these filters:\n${filtersEnabledByUser .map( - (enabled) => + (enabledFilter) => `\`${ ffmpegFilterOptions.availableFilters.find( - (filter) => enabled == filter.value + (filter) => enabledFilter == filter.value ).label }\`` ) diff --git a/src/config_example.js b/src/config_example.js index 87a60d8..87c1b6d 100644 --- a/src/config_example.js +++ b/src/config_example.js @@ -175,6 +175,12 @@ module.exports.ffmpegFilterOptions = { value: 'treble', description: 'Increase the high frequencies.', emoji: '🎼' + }, + { + label: 'Normalizer', + value: 'normalizer', + description: 'Normalize the audio (avoid distortion).', + emoji: '🎶' } ] };