lavalink-client 2.6.4 → 2.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +334 -76
- package/dist/index.d.ts +334 -76
- package/dist/index.js +315 -146
- package/dist/index.mjs +315 -146
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2735,6 +2735,7 @@ var DEFAULT_FILTER_DATAS = {
|
|
|
2735
2735
|
}*/
|
|
2736
2736
|
};
|
|
2737
2737
|
var FilterManager = class {
|
|
2738
|
+
static EQList = EQList;
|
|
2738
2739
|
/** The Equalizer bands currently applied to the Lavalink Server */
|
|
2739
2740
|
equalizerBands = [];
|
|
2740
2741
|
/** Private Util for the instaFix Filters option */
|
|
@@ -2772,6 +2773,17 @@ var FilterManager = class {
|
|
|
2772
2773
|
}
|
|
2773
2774
|
/**
|
|
2774
2775
|
* Apply Player filters for lavalink filter sending data, if the filter is enabled / not
|
|
2776
|
+
*
|
|
2777
|
+
* @returns {Promise<void>}
|
|
2778
|
+
*
|
|
2779
|
+
* @example
|
|
2780
|
+
* ```ts
|
|
2781
|
+
* // Apply the filters after changing them manually:
|
|
2782
|
+
* player.filterManager.data.volume = 0.5;
|
|
2783
|
+
* // maybe you wanna manually set a distorition filter? then do it like this...
|
|
2784
|
+
* player.filterManager.data.distortion = { sinOffset: 0.5, sinScale: 2, cosOffset: 0.5, cosScale: 2, tanOffset: 0.5, tanScale: 2, offset: 0.5, scale: 2 };
|
|
2785
|
+
* await player.filterManager.applyPlayerFilters();
|
|
2786
|
+
* ```
|
|
2775
2787
|
*/
|
|
2776
2788
|
async applyPlayerFilters() {
|
|
2777
2789
|
const sendData = { ...this.data };
|
|
@@ -2811,9 +2823,17 @@ var FilterManager = class {
|
|
|
2811
2823
|
return;
|
|
2812
2824
|
}
|
|
2813
2825
|
/**
|
|
2814
|
-
* Checks if the filters are correctly stated (active / not-active)
|
|
2826
|
+
* Checks if the filters are correctly stated (active / not-active) - mostly used internally.
|
|
2815
2827
|
* @param oldFilterTimescale
|
|
2816
|
-
* @returns
|
|
2828
|
+
* @returns {boolean} True, if the check was successfull
|
|
2829
|
+
*
|
|
2830
|
+
* @example
|
|
2831
|
+
* ```ts
|
|
2832
|
+
* // Check the filter states
|
|
2833
|
+
* player.filterManager.checkFiltersState();
|
|
2834
|
+
* // Apply the filters after checking
|
|
2835
|
+
* await player.filterManager.applyPlayerFilters();
|
|
2836
|
+
* ```
|
|
2817
2837
|
*/
|
|
2818
2838
|
checkFiltersState(oldFilterTimescale) {
|
|
2819
2839
|
this.filters.rotation = this.data.rotation.rotationHz !== 0;
|
|
@@ -2839,6 +2859,13 @@ var FilterManager = class {
|
|
|
2839
2859
|
}
|
|
2840
2860
|
/**
|
|
2841
2861
|
* Reset all Filters
|
|
2862
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
2863
|
+
*
|
|
2864
|
+
* @example
|
|
2865
|
+
* ```ts
|
|
2866
|
+
* // Reset all filters
|
|
2867
|
+
* await player.filterManager.resetFilters();
|
|
2868
|
+
* ```
|
|
2842
2869
|
*/
|
|
2843
2870
|
async resetFilters() {
|
|
2844
2871
|
this.filters.lavalinkLavaDspxPlugin.echo = false;
|
|
@@ -2856,83 +2883,21 @@ var FilterManager = class {
|
|
|
2856
2883
|
this.filters.karaoke = false;
|
|
2857
2884
|
this.filters.volume = false;
|
|
2858
2885
|
this.filters.audioOutput = "stereo";
|
|
2859
|
-
|
|
2860
|
-
volume: 1,
|
|
2861
|
-
lowPass: {
|
|
2862
|
-
smoothing: 0
|
|
2863
|
-
},
|
|
2864
|
-
karaoke: {
|
|
2865
|
-
level: 0,
|
|
2866
|
-
monoLevel: 0,
|
|
2867
|
-
filterBand: 0,
|
|
2868
|
-
filterWidth: 0
|
|
2869
|
-
},
|
|
2870
|
-
timescale: {
|
|
2871
|
-
speed: 1,
|
|
2872
|
-
// 0 = x
|
|
2873
|
-
pitch: 1,
|
|
2874
|
-
// 0 = x
|
|
2875
|
-
rate: 1
|
|
2876
|
-
// 0 = x
|
|
2877
|
-
},
|
|
2878
|
-
pluginFilters: {
|
|
2879
|
-
"lavalink-filter-plugin": {
|
|
2880
|
-
echo: {
|
|
2881
|
-
// delay: 0, // in seconds
|
|
2882
|
-
// decay: 0 // 0 < 1
|
|
2883
|
-
},
|
|
2884
|
-
reverb: {
|
|
2885
|
-
// delays: [], // [0.037, 0.042, 0.048, 0.053]
|
|
2886
|
-
// gains: [] // [0.84, 0.83, 0.82, 0.81]
|
|
2887
|
-
}
|
|
2888
|
-
},
|
|
2889
|
-
"high-pass": {
|
|
2890
|
-
// Cuts off frequencies lower than the specified {cutoffFrequency}.
|
|
2891
|
-
// "cutoffFrequency": 1475, // Integer, higher than zero, in Hz.
|
|
2892
|
-
// "boostFactor": 1.0 // Float, higher than 0.0. This alters volume output. A value of 1.0 means no volume change.
|
|
2893
|
-
},
|
|
2894
|
-
"low-pass": {
|
|
2895
|
-
// Cuts off frequencies higher than the specified {cutoffFrequency}.
|
|
2896
|
-
// "cutoffFrequency": 284, // Integer, higher than zero, in Hz.
|
|
2897
|
-
// "boostFactor": 1.24389 // Float, higher than 0.0. This alters volume output. A value of 1.0 means no volume change.
|
|
2898
|
-
},
|
|
2899
|
-
"normalization": {
|
|
2900
|
-
// Attenuates peaking where peaks are defined as having a higher value than {maxAmplitude}.
|
|
2901
|
-
// "maxAmplitude": 0.6327, // Float, within the range of 0.0 - 1.0. A value of 0.0 mutes the output.
|
|
2902
|
-
// "adaptive": true // false
|
|
2903
|
-
},
|
|
2904
|
-
"echo": {
|
|
2905
|
-
// Self-explanatory; provides an echo effect.
|
|
2906
|
-
// "echoLength": 0.5649, // Float, higher than 0.0, in seconds (1.0 = 1 second).
|
|
2907
|
-
// "decay": 0.4649 // Float, within the range of 0.0 - 1.0. A value of 1.0 means no decay, and a value of 0.0 means
|
|
2908
|
-
}
|
|
2909
|
-
},
|
|
2910
|
-
rotation: {
|
|
2911
|
-
rotationHz: 0
|
|
2912
|
-
},
|
|
2913
|
-
tremolo: {
|
|
2914
|
-
frequency: 0,
|
|
2915
|
-
// 0 < x
|
|
2916
|
-
depth: 0
|
|
2917
|
-
// 0 < x = 1
|
|
2918
|
-
},
|
|
2919
|
-
vibrato: {
|
|
2920
|
-
frequency: 0,
|
|
2921
|
-
// 0 < x = 14
|
|
2922
|
-
depth: 0
|
|
2923
|
-
// 0 < x = 1
|
|
2924
|
-
},
|
|
2925
|
-
channelMix: audioOutputsData.stereo
|
|
2926
|
-
})) {
|
|
2927
|
-
this.data[key] = value;
|
|
2928
|
-
}
|
|
2886
|
+
this.data = structuredClone(DEFAULT_FILTER_DATAS);
|
|
2929
2887
|
await this.applyPlayerFilters();
|
|
2930
|
-
return this
|
|
2888
|
+
return this;
|
|
2931
2889
|
}
|
|
2932
2890
|
/**
|
|
2933
2891
|
* Set the Filter Volume
|
|
2934
|
-
* @param volume
|
|
2935
|
-
* @returns
|
|
2892
|
+
* @param volume the volume (0.0 - 5.0)
|
|
2893
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
2894
|
+
*
|
|
2895
|
+
* @example
|
|
2896
|
+
* ```ts
|
|
2897
|
+
* // Set Volume to 50%
|
|
2898
|
+
* await player.filterManager.setVolume(0.5);
|
|
2899
|
+
* // note this is a filter, so it will "jump" to the volume, i think it's like a "volume boost effect" so i marketed it as a filter
|
|
2900
|
+
* ```
|
|
2936
2901
|
*/
|
|
2937
2902
|
async setVolume(volume) {
|
|
2938
2903
|
if (volume < 0 || volume > 5) throw new SyntaxError("Volume-Filter must be between 0 and 5");
|
|
@@ -2940,12 +2905,27 @@ var FilterManager = class {
|
|
|
2940
2905
|
this.data.volume = volume;
|
|
2941
2906
|
this.filters.volume = volume !== 1;
|
|
2942
2907
|
await this.applyPlayerFilters();
|
|
2943
|
-
return this
|
|
2908
|
+
return this;
|
|
2944
2909
|
}
|
|
2945
2910
|
/**
|
|
2946
2911
|
* Set the AudioOutput Filter
|
|
2947
|
-
* @param type
|
|
2948
|
-
* @returns
|
|
2912
|
+
* @param {AudioOutputs} type the audio output type
|
|
2913
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
2914
|
+
*
|
|
2915
|
+
* @example
|
|
2916
|
+
* ```ts
|
|
2917
|
+
* // Set Audio Output to Mono
|
|
2918
|
+
* await player.filterManager.setAudioOutput("mono");
|
|
2919
|
+
*
|
|
2920
|
+
* // Set Audio Output to Stereo
|
|
2921
|
+
* await player.filterManager.setAudioOutput("stereo");
|
|
2922
|
+
*
|
|
2923
|
+
* // Set Audio Output to Left
|
|
2924
|
+
* await player.filterManager.setAudioOutput("left");
|
|
2925
|
+
*
|
|
2926
|
+
* // Set Audio Output to Right
|
|
2927
|
+
* await player.filterManager.setAudioOutput("right");
|
|
2928
|
+
* ```
|
|
2949
2929
|
*/
|
|
2950
2930
|
async setAudioOutput(type) {
|
|
2951
2931
|
if (this.player.node.info && !this.player.node.info?.filters?.includes("channelMix")) throw new Error("Node#Info#filters does not include the 'channelMix' Filter (Node has it not enable)");
|
|
@@ -2954,12 +2934,18 @@ var FilterManager = class {
|
|
|
2954
2934
|
this.data.channelMix = audioOutputsData[type];
|
|
2955
2935
|
this.filters.audioOutput = type;
|
|
2956
2936
|
await this.applyPlayerFilters();
|
|
2957
|
-
return this
|
|
2937
|
+
return this;
|
|
2958
2938
|
}
|
|
2959
2939
|
/**
|
|
2960
2940
|
* Set custom filter.timescale#speed . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
|
|
2961
|
-
* @param speed
|
|
2962
|
-
* @returns
|
|
2941
|
+
* @param {number} speed set the speed of the filter
|
|
2942
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
2943
|
+
*
|
|
2944
|
+
* @example
|
|
2945
|
+
* ```ts
|
|
2946
|
+
* // Set Speed to 1.25 (disableds nightcore and vaporwave effect which are pre-made timescale settings of rate,pitch and speed)
|
|
2947
|
+
* await player.filterManager.setSpeed(1.25);
|
|
2948
|
+
* ```
|
|
2963
2949
|
*/
|
|
2964
2950
|
async setSpeed(speed = 1) {
|
|
2965
2951
|
if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale")) throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
|
|
@@ -2969,12 +2955,18 @@ var FilterManager = class {
|
|
|
2969
2955
|
this.data.timescale = { ...DEFAULT_FILTER_DATAS.timescale, speed };
|
|
2970
2956
|
this.isCustomFilterActive();
|
|
2971
2957
|
await this.applyPlayerFilters();
|
|
2972
|
-
return this
|
|
2958
|
+
return this;
|
|
2973
2959
|
}
|
|
2974
2960
|
/**
|
|
2975
2961
|
* Set custom filter.timescale#pitch . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
|
|
2976
|
-
* @param
|
|
2977
|
-
* @returns
|
|
2962
|
+
* @param {number} pitch set the pitch of the filter
|
|
2963
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
2964
|
+
*
|
|
2965
|
+
* @example
|
|
2966
|
+
* ```ts
|
|
2967
|
+
* // Set Pitch to 1.25 (disableds nightcore and vaporwave effect which are pre-made timescale settings of rate,pitch and speed)
|
|
2968
|
+
* await player.filterManager.setPitch(1.25);
|
|
2969
|
+
* ```
|
|
2978
2970
|
*/
|
|
2979
2971
|
async setPitch(pitch = 1) {
|
|
2980
2972
|
if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale")) throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
|
|
@@ -2984,12 +2976,18 @@ var FilterManager = class {
|
|
|
2984
2976
|
this.data.timescale = { ...DEFAULT_FILTER_DATAS.timescale, pitch };
|
|
2985
2977
|
this.isCustomFilterActive();
|
|
2986
2978
|
await this.applyPlayerFilters();
|
|
2987
|
-
return this
|
|
2979
|
+
return this;
|
|
2988
2980
|
}
|
|
2989
2981
|
/**
|
|
2990
2982
|
* Set custom filter.timescale#rate . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
|
|
2991
|
-
* @param
|
|
2992
|
-
* @returns
|
|
2983
|
+
* @param {number} rate set the rate of the filter
|
|
2984
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
2985
|
+
*
|
|
2986
|
+
* @example
|
|
2987
|
+
* ```ts
|
|
2988
|
+
* // Set Rate to 1.25 (disableds nightcore and vaporwave effect which are pre-made timescale settings of rate,pitch and speed)
|
|
2989
|
+
* await player.filterManager.setRate(1.25);
|
|
2990
|
+
* ```
|
|
2993
2991
|
*/
|
|
2994
2992
|
async setRate(rate = 1) {
|
|
2995
2993
|
if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale")) throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
|
|
@@ -2999,12 +2997,21 @@ var FilterManager = class {
|
|
|
2999
2997
|
this.data.timescale = { ...DEFAULT_FILTER_DATAS.timescale, rate };
|
|
3000
2998
|
this.isCustomFilterActive();
|
|
3001
2999
|
await this.applyPlayerFilters();
|
|
3002
|
-
return this
|
|
3000
|
+
return this;
|
|
3003
3001
|
}
|
|
3004
3002
|
/**
|
|
3005
3003
|
* Enables / Disables the rotation effect, (Optional: provide your Own Data)
|
|
3006
|
-
* @param rotationHz
|
|
3007
|
-
* @returns
|
|
3004
|
+
* @param {number} rotationHz set the rotationHz of the filter
|
|
3005
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3006
|
+
*
|
|
3007
|
+
* @example
|
|
3008
|
+
* ```ts
|
|
3009
|
+
* // Toggle Rotation filter with custom settings
|
|
3010
|
+
* await player.filterManager.toggleRotation(0.4);
|
|
3011
|
+
* // or use the defaults
|
|
3012
|
+
* await player.filterManager.toggleRotation();
|
|
3013
|
+
* // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
|
|
3014
|
+
* ```
|
|
3008
3015
|
*/
|
|
3009
3016
|
async toggleRotation(rotationHz = 0.2) {
|
|
3010
3017
|
if (this.player.node.info && !this.player.node.info?.filters?.includes("rotation")) throw new Error("Node#Info#filters does not include the 'rotation' Filter (Node has it not enable)");
|
|
@@ -3012,13 +3019,22 @@ var FilterManager = class {
|
|
|
3012
3019
|
this.data.rotation = this.filters.rotation ? DEFAULT_FILTER_DATAS.rotation : { rotationHz };
|
|
3013
3020
|
this.filters.rotation = !this.filters.rotation;
|
|
3014
3021
|
await this.applyPlayerFilters();
|
|
3015
|
-
return this
|
|
3022
|
+
return this;
|
|
3016
3023
|
}
|
|
3017
3024
|
/**
|
|
3018
3025
|
* Enables / Disables the Vibrato effect, (Optional: provide your Own Data)
|
|
3019
|
-
* @param frequency
|
|
3020
|
-
* @param depth
|
|
3021
|
-
* @returns
|
|
3026
|
+
* @param {number} frequency set the frequency of the filter
|
|
3027
|
+
* @param {number} depth set the depth of the filter
|
|
3028
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3029
|
+
*
|
|
3030
|
+
* @example
|
|
3031
|
+
* ```ts
|
|
3032
|
+
* // Toggle Vibrato filter with custom settings
|
|
3033
|
+
* await player.filterManager.toggleVibrato(8, 0.5);
|
|
3034
|
+
* // or use the defaults
|
|
3035
|
+
* await player.filterManager.toggleVibrato();
|
|
3036
|
+
* // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
|
|
3037
|
+
* ```
|
|
3022
3038
|
*/
|
|
3023
3039
|
async toggleVibrato(frequency = 10, depth = 1) {
|
|
3024
3040
|
if (this.player.node.info && !this.player.node.info?.filters?.includes("vibrato")) throw new Error("Node#Info#filters does not include the 'vibrato' Filter (Node has it not enable)");
|
|
@@ -3026,13 +3042,22 @@ var FilterManager = class {
|
|
|
3026
3042
|
this.data.vibrato = this.filters.vibrato ? DEFAULT_FILTER_DATAS.vibrato : { depth, frequency };
|
|
3027
3043
|
this.filters.vibrato = !this.filters.vibrato;
|
|
3028
3044
|
await this.applyPlayerFilters();
|
|
3029
|
-
return this
|
|
3045
|
+
return this;
|
|
3030
3046
|
}
|
|
3031
3047
|
/**
|
|
3032
3048
|
* Enables / Disables the Tremolo effect, (Optional: provide your Own Data)
|
|
3033
|
-
* @param frequency
|
|
3034
|
-
* @param depth
|
|
3035
|
-
* @returns
|
|
3049
|
+
* @param {number} frequency set the frequency of the filter
|
|
3050
|
+
* @param {number} depth set the depth of the filter
|
|
3051
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3052
|
+
*
|
|
3053
|
+
* @example
|
|
3054
|
+
* ```ts
|
|
3055
|
+
* // Toggle Tremolo filter with custom settings
|
|
3056
|
+
* await player.filterManager.toggleTremolo(5, 0.7);
|
|
3057
|
+
* // or use the defaults
|
|
3058
|
+
* await player.filterManager.toggleTremolo();
|
|
3059
|
+
* // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
|
|
3060
|
+
* ```
|
|
3036
3061
|
*/
|
|
3037
3062
|
async toggleTremolo(frequency = 4, depth = 0.8) {
|
|
3038
3063
|
if (this.player.node.info && !this.player.node.info?.filters?.includes("tremolo")) throw new Error("Node#Info#filters does not include the 'tremolo' Filter (Node has it not enable)");
|
|
@@ -3040,12 +3065,21 @@ var FilterManager = class {
|
|
|
3040
3065
|
this.data.tremolo = this.filters.tremolo ? DEFAULT_FILTER_DATAS.tremolo : { depth, frequency };
|
|
3041
3066
|
this.filters.tremolo = !this.filters.tremolo;
|
|
3042
3067
|
await this.applyPlayerFilters();
|
|
3043
|
-
return this
|
|
3068
|
+
return this;
|
|
3044
3069
|
}
|
|
3045
3070
|
/**
|
|
3046
3071
|
* Enables / Disables the LowPass effect, (Optional: provide your Own Data)
|
|
3047
|
-
* @param smoothing
|
|
3048
|
-
* @returns
|
|
3072
|
+
* @param {number} smoothing set the smoothing of the filter
|
|
3073
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3074
|
+
*
|
|
3075
|
+
* @example
|
|
3076
|
+
* ```ts
|
|
3077
|
+
* // Toggle LowPass filter with custom settings
|
|
3078
|
+
* await player.filterManager.toggleLowPass(30);
|
|
3079
|
+
* // or use the defaults
|
|
3080
|
+
* await player.filterManager.toggleLowPass();
|
|
3081
|
+
* // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
|
|
3082
|
+
* ```
|
|
3049
3083
|
*/
|
|
3050
3084
|
async toggleLowPass(smoothing = 20) {
|
|
3051
3085
|
if (this.player.node.info && !this.player.node.info?.filters?.includes("lowPass")) throw new Error("Node#Info#filters does not include the 'lowPass' Filter (Node has it not enable)");
|
|
@@ -3053,14 +3087,26 @@ var FilterManager = class {
|
|
|
3053
3087
|
this.data.lowPass = this.filters.lowPass ? DEFAULT_FILTER_DATAS.lowPass : { smoothing };
|
|
3054
3088
|
this.filters.lowPass = !this.filters.lowPass;
|
|
3055
3089
|
await this.applyPlayerFilters();
|
|
3056
|
-
return this
|
|
3090
|
+
return this;
|
|
3057
3091
|
}
|
|
3092
|
+
/**
|
|
3093
|
+
* Lavalink LavaDspx Plugin Filters
|
|
3094
|
+
*/
|
|
3058
3095
|
lavalinkLavaDspxPlugin = {
|
|
3059
3096
|
/**
|
|
3060
3097
|
* Enables / Disables the LowPass effect, (Optional: provide your Own Data)
|
|
3061
|
-
* @param boostFactor
|
|
3062
|
-
* @param cutoffFrequency
|
|
3063
|
-
* @returns
|
|
3098
|
+
* @param {number} boostFactor set the boost factor of the filter
|
|
3099
|
+
* @param {number} cutoffFrequency set the cutoff frequency of the filter
|
|
3100
|
+
* @returns {Promise<boolean>} the state of the filter after execution.
|
|
3101
|
+
*
|
|
3102
|
+
* @example
|
|
3103
|
+
* ```ts
|
|
3104
|
+
* // Toggle LowPass filter with custom settings
|
|
3105
|
+
* await player.filterManager.lavalinkLavaDspxPlugin.toggleLowPass(1.2, 300);
|
|
3106
|
+
* // or use the defaults
|
|
3107
|
+
* await player.filterManager.lavalinkLavaDspxPlugin.toggleLowPass();
|
|
3108
|
+
* // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
|
|
3109
|
+
* ```
|
|
3064
3110
|
*/
|
|
3065
3111
|
toggleLowPass: async (boostFactor = 1, cutoffFrequency = 80) => {
|
|
3066
3112
|
if (this.player.node.info && !this.player.node.info?.plugins?.find((v) => v.name === "lavadspx-plugin")) throw new Error("Node#Info#plugins does not include the lavadspx plugin");
|
|
@@ -3071,13 +3117,22 @@ var FilterManager = class {
|
|
|
3071
3117
|
else this.data.pluginFilters["low-pass"] = { boostFactor, cutoffFrequency };
|
|
3072
3118
|
this.filters.lavalinkLavaDspxPlugin.lowPass = !this.filters.lavalinkLavaDspxPlugin.lowPass;
|
|
3073
3119
|
await this.applyPlayerFilters();
|
|
3074
|
-
return this
|
|
3120
|
+
return this;
|
|
3075
3121
|
},
|
|
3076
3122
|
/**
|
|
3077
3123
|
* Enables / Disables the HighPass effect, (Optional: provide your Own Data)
|
|
3078
|
-
* @param boostFactor
|
|
3079
|
-
* @param cutoffFrequency
|
|
3080
|
-
* @returns
|
|
3124
|
+
* @param {number} boostFactor [] set the boost factor of the filter
|
|
3125
|
+
* @param {number} cutoffFrequency set the cutoff frequency of the filter
|
|
3126
|
+
* @returns {Promise<boolean>} the state of the filter after execution.
|
|
3127
|
+
*
|
|
3128
|
+
* @example
|
|
3129
|
+
* ```ts
|
|
3130
|
+
* // Toggle HighPass filter with custom settings
|
|
3131
|
+
* await player.filterManager.lavalinkLavaDspxPlugin.toggleHighPass(1.2, 150); // custom values
|
|
3132
|
+
* // or use the defaults
|
|
3133
|
+
* await player.filterManager.lavalinkLavaDspxPlugin.toggleHighPass();
|
|
3134
|
+
* // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
|
|
3135
|
+
* ```
|
|
3081
3136
|
*/
|
|
3082
3137
|
toggleHighPass: async (boostFactor = 1, cutoffFrequency = 80) => {
|
|
3083
3138
|
if (this.player.node.info && !this.player.node.info?.plugins?.find((v) => v.name === "lavadspx-plugin")) throw new Error("Node#Info#plugins does not include the lavadspx plugin");
|
|
@@ -3088,13 +3143,22 @@ var FilterManager = class {
|
|
|
3088
3143
|
else this.data.pluginFilters["high-pass"] = { boostFactor, cutoffFrequency };
|
|
3089
3144
|
this.filters.lavalinkLavaDspxPlugin.highPass = !this.filters.lavalinkLavaDspxPlugin.highPass;
|
|
3090
3145
|
await this.applyPlayerFilters();
|
|
3091
|
-
return this
|
|
3146
|
+
return this;
|
|
3092
3147
|
},
|
|
3093
3148
|
/**
|
|
3094
3149
|
* Enables / Disables the Normalization effect.
|
|
3095
3150
|
* @param {number} [maxAmplitude=0.75] - The maximum amplitude of the audio.
|
|
3096
|
-
* @param {boolean} [adaptive=true]
|
|
3097
|
-
* @returns {Promise<
|
|
3151
|
+
* @param {boolean} [adaptive=true] Whether to use adaptive normalization or not.
|
|
3152
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3153
|
+
*
|
|
3154
|
+
* @example
|
|
3155
|
+
* ```ts
|
|
3156
|
+
* // Toggle Normalization filter with custom settings
|
|
3157
|
+
* await player.filterManager.lavalinkLavaDspxPlugin.toggleNormalization(0.9, false); // custom values
|
|
3158
|
+
* // or use the defaults
|
|
3159
|
+
* await player.filterManager.lavalinkLavaDspxPlugin.toggleNormalization();
|
|
3160
|
+
* // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
|
|
3161
|
+
* ```
|
|
3098
3162
|
*/
|
|
3099
3163
|
toggleNormalization: async (maxAmplitude = 0.75, adaptive = true) => {
|
|
3100
3164
|
if (this.player.node.info && !this.player.node.info?.plugins?.find((v) => v.name === "lavadspx-plugin")) throw new Error("Node#Info#plugins does not include the lavadspx plugin");
|
|
@@ -3105,13 +3169,22 @@ var FilterManager = class {
|
|
|
3105
3169
|
else this.data.pluginFilters.normalization = { adaptive, maxAmplitude };
|
|
3106
3170
|
this.filters.lavalinkLavaDspxPlugin.normalization = !this.filters.lavalinkLavaDspxPlugin.normalization;
|
|
3107
3171
|
await this.applyPlayerFilters();
|
|
3108
|
-
return this
|
|
3172
|
+
return this;
|
|
3109
3173
|
},
|
|
3110
3174
|
/**
|
|
3111
3175
|
* Enables / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
|
|
3112
|
-
* @param {number} [decay=0.5]
|
|
3113
|
-
* @param {number} [echoLength=0.5]
|
|
3114
|
-
* @returns {Promise<
|
|
3176
|
+
* @param {number} [decay=0.5] The decay of the echo effect.
|
|
3177
|
+
* @param {number} [echoLength=0.5] The length of the echo effect.
|
|
3178
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3179
|
+
*
|
|
3180
|
+
* @example
|
|
3181
|
+
* ```ts
|
|
3182
|
+
* // Toggle Echo filter with custom settings
|
|
3183
|
+
* await player.filterManager.lavalinkLavaDspxPlugin.toggleEcho(0.7, 0.6); // custom values
|
|
3184
|
+
* // or use the defaults
|
|
3185
|
+
* await player.filterManager.lavalinkLavaDspxPlugin.toggleEcho();
|
|
3186
|
+
* // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
|
|
3187
|
+
* ```
|
|
3115
3188
|
*/
|
|
3116
3189
|
toggleEcho: async (decay = 0.5, echoLength = 0.5) => {
|
|
3117
3190
|
if (this.player.node.info && !this.player.node.info?.plugins?.find((v) => v.name === "lavadspx-plugin")) throw new Error("Node#Info#plugins does not include the lavadspx plugin");
|
|
@@ -3122,15 +3195,27 @@ var FilterManager = class {
|
|
|
3122
3195
|
else this.data.pluginFilters.echo = { decay, echoLength };
|
|
3123
3196
|
this.filters.lavalinkLavaDspxPlugin.echo = !this.filters.lavalinkLavaDspxPlugin.echo;
|
|
3124
3197
|
await this.applyPlayerFilters();
|
|
3125
|
-
return this
|
|
3198
|
+
return this;
|
|
3126
3199
|
}
|
|
3127
3200
|
};
|
|
3201
|
+
/**
|
|
3202
|
+
* LavalinkFilter Plugin specific Filters
|
|
3203
|
+
*/
|
|
3128
3204
|
lavalinkFilterPlugin = {
|
|
3129
3205
|
/**
|
|
3130
3206
|
* Enables / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
|
|
3131
|
-
* @param delay
|
|
3132
|
-
* @param decay
|
|
3133
|
-
* @returns
|
|
3207
|
+
* @param {number} delay set the delay of the echo
|
|
3208
|
+
* @param {number} decay set the decay of the echo
|
|
3209
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3210
|
+
*
|
|
3211
|
+
* @example
|
|
3212
|
+
* ```ts
|
|
3213
|
+
* // Toggle Echo filter with custom settings
|
|
3214
|
+
* await player.filterManager.lavalinkFilterPlugin.toggleEcho(3, 0.7); // custom values
|
|
3215
|
+
* // or use the defaults
|
|
3216
|
+
* await player.filterManager.lavalinkFilterPlugin.toggleEcho();
|
|
3217
|
+
* // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
|
|
3218
|
+
* ```
|
|
3134
3219
|
*/
|
|
3135
3220
|
toggleEcho: async (delay = 4, decay = 0.8) => {
|
|
3136
3221
|
if (this.player.node.info && !this.player.node.info?.plugins?.find((v) => v.name === "lavalink-filter-plugin")) throw new Error("Node#Info#plugins does not include the lavalink-filter-plugin plugin");
|
|
@@ -3146,13 +3231,22 @@ var FilterManager = class {
|
|
|
3146
3231
|
};
|
|
3147
3232
|
this.filters.lavalinkFilterPlugin.echo = !this.filters.lavalinkFilterPlugin.echo;
|
|
3148
3233
|
await this.applyPlayerFilters();
|
|
3149
|
-
return this
|
|
3234
|
+
return this;
|
|
3150
3235
|
},
|
|
3151
3236
|
/**
|
|
3152
3237
|
* Enables / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
|
|
3153
|
-
* @param delays
|
|
3154
|
-
* @param gains
|
|
3155
|
-
* @returns
|
|
3238
|
+
* @param {number} delays set the delays of the reverb
|
|
3239
|
+
* @param {number} gains set the gains of the reverb
|
|
3240
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3241
|
+
*
|
|
3242
|
+
* @example
|
|
3243
|
+
* ```ts
|
|
3244
|
+
* // Toggle Reverb filter with custom settings
|
|
3245
|
+
* await player.filterManager.lavalinkFilterPlugin.toggleReverb([0.04, 0.045, 0.05, 0.055], [0.85, 0.84, 0.83, 0.82]);
|
|
3246
|
+
* // or use the defaults
|
|
3247
|
+
* await player.filterManager.lavalinkFilterPlugin.toggleReverb();
|
|
3248
|
+
* // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
|
|
3249
|
+
* ```
|
|
3156
3250
|
*/
|
|
3157
3251
|
toggleReverb: async (delays = [0.037, 0.042, 0.048, 0.053], gains = [0.84, 0.83, 0.82, 0.81]) => {
|
|
3158
3252
|
if (this.player.node.info && !this.player.node.info?.plugins?.find((v) => v.name === "lavalink-filter-plugin")) throw new Error("Node#Info#plugins does not include the lavalink-filter-plugin plugin");
|
|
@@ -3168,15 +3262,24 @@ var FilterManager = class {
|
|
|
3168
3262
|
};
|
|
3169
3263
|
this.filters.lavalinkFilterPlugin.reverb = !this.filters.lavalinkFilterPlugin.reverb;
|
|
3170
3264
|
await this.applyPlayerFilters();
|
|
3171
|
-
return this
|
|
3265
|
+
return this;
|
|
3172
3266
|
}
|
|
3173
3267
|
};
|
|
3174
3268
|
/**
|
|
3175
3269
|
* Enables / Disables a Nightcore-like filter Effect. Disables/Overrides both: custom and Vaporwave Filter
|
|
3176
|
-
* @param speed
|
|
3177
|
-
* @param pitch
|
|
3178
|
-
* @param rate
|
|
3179
|
-
* @returns
|
|
3270
|
+
* @param {number} speed set the speed of the filter
|
|
3271
|
+
* @param {number} pitch set the pitch of the filter
|
|
3272
|
+
* @param {number} rate set the rate of the filter
|
|
3273
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3274
|
+
*
|
|
3275
|
+
* @example
|
|
3276
|
+
* ```ts
|
|
3277
|
+
* // Toggle Nightcore filter with custom settings
|
|
3278
|
+
* await player.filterManager.toggleNightcore(1.3, 1.3, 0.9);
|
|
3279
|
+
* // or use the defaults
|
|
3280
|
+
* await player.filterManager.toggleNightcore();
|
|
3281
|
+
* // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
|
|
3282
|
+
* ```
|
|
3180
3283
|
*/
|
|
3181
3284
|
async toggleNightcore(speed = 1.289999523162842, pitch = 1.289999523162842, rate = 0.9365999523162842) {
|
|
3182
3285
|
if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale")) throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
|
|
@@ -3186,14 +3289,23 @@ var FilterManager = class {
|
|
|
3186
3289
|
this.filters.vaporwave = false;
|
|
3187
3290
|
this.filters.custom = false;
|
|
3188
3291
|
await this.applyPlayerFilters();
|
|
3189
|
-
return this
|
|
3292
|
+
return this;
|
|
3190
3293
|
}
|
|
3191
3294
|
/**
|
|
3192
3295
|
* Enables / Disables a Vaporwave-like filter Effect. Disables/Overrides both: custom and nightcore Filter
|
|
3193
|
-
* @param speed
|
|
3194
|
-
* @param pitch
|
|
3195
|
-
* @param rate
|
|
3196
|
-
* @returns
|
|
3296
|
+
* @param {number} speed set the speed of the filterq
|
|
3297
|
+
* @param {number} pitch set the pitch of the filter
|
|
3298
|
+
* @param {number} rate set the rate of the filter
|
|
3299
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3300
|
+
*
|
|
3301
|
+
* @example
|
|
3302
|
+
* ```ts
|
|
3303
|
+
* // Toggle Vaporwave filter with custom settings
|
|
3304
|
+
* await player.filterManager.toggleVaporwave(0.9, 0.7, 1);
|
|
3305
|
+
* // or use the defaults
|
|
3306
|
+
* await player.filterManager.toggleVaporwave();
|
|
3307
|
+
* // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
|
|
3308
|
+
* ```
|
|
3197
3309
|
*/
|
|
3198
3310
|
async toggleVaporwave(speed = 0.8500000238418579, pitch = 0.800000011920929, rate = 1) {
|
|
3199
3311
|
if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale")) throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
|
|
@@ -3203,15 +3315,24 @@ var FilterManager = class {
|
|
|
3203
3315
|
this.filters.nightcore = false;
|
|
3204
3316
|
this.filters.custom = false;
|
|
3205
3317
|
await this.applyPlayerFilters();
|
|
3206
|
-
return this
|
|
3318
|
+
return this;
|
|
3207
3319
|
}
|
|
3208
3320
|
/**
|
|
3209
3321
|
* Enable / Disables a Karaoke like Filter Effect
|
|
3210
|
-
* @param level
|
|
3211
|
-
* @param monoLevel
|
|
3212
|
-
* @param filterBand
|
|
3213
|
-
* @param filterWidth
|
|
3214
|
-
* @returns
|
|
3322
|
+
* @param {number} level set the level of the filter
|
|
3323
|
+
* @param {number} monoLevel set the mono level of the filter
|
|
3324
|
+
* @param {number} filterBand set the filter band of the filter
|
|
3325
|
+
* @param {number} filterWidth set the filter width of the filter
|
|
3326
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3327
|
+
*
|
|
3328
|
+
* @example
|
|
3329
|
+
* ```ts
|
|
3330
|
+
* // Toggle Karaoke filter with custom settings
|
|
3331
|
+
* await player.filterManager.toggleKaraoke(1.5, 1.0, 220, 100);
|
|
3332
|
+
* // or use the defaults
|
|
3333
|
+
* await player.filterManager.toggleKaraoke();
|
|
3334
|
+
* // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
|
|
3335
|
+
* ```
|
|
3215
3336
|
*/
|
|
3216
3337
|
async toggleKaraoke(level = 1, monoLevel = 1, filterBand = 220, filterWidth = 100) {
|
|
3217
3338
|
if (this.player.node.info && !this.player.node.info?.filters?.includes("karaoke")) throw new Error("Node#Info#filters does not include the 'karaoke' Filter (Node has it not enable)");
|
|
@@ -3219,17 +3340,56 @@ var FilterManager = class {
|
|
|
3219
3340
|
this.data.karaoke = this.filters.karaoke ? DEFAULT_FILTER_DATAS.karaoke : { level, monoLevel, filterBand, filterWidth };
|
|
3220
3341
|
this.filters.karaoke = !this.filters.karaoke;
|
|
3221
3342
|
await this.applyPlayerFilters();
|
|
3222
|
-
return this
|
|
3343
|
+
return this;
|
|
3223
3344
|
}
|
|
3224
|
-
/**
|
|
3345
|
+
/**
|
|
3346
|
+
* Function to find out if currently there is a custom timescamle etc. filter applied
|
|
3347
|
+
* @returns {boolean} whether a custom filter is active
|
|
3348
|
+
*
|
|
3349
|
+
* @example
|
|
3350
|
+
* ```ts
|
|
3351
|
+
* // Check if a custom filter is active
|
|
3352
|
+
* const isCustom = player.filterManager.isCustomFilterActive();
|
|
3353
|
+
* console.log(`Is custom filter active? ${isCustom}`);
|
|
3354
|
+
* ```
|
|
3355
|
+
*/
|
|
3225
3356
|
isCustomFilterActive() {
|
|
3226
3357
|
this.filters.custom = !this.filters.nightcore && !this.filters.vaporwave && Object.values(this.data.timescale).some((d) => d !== 1);
|
|
3227
3358
|
return this.filters.custom;
|
|
3228
3359
|
}
|
|
3229
3360
|
/**
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3361
|
+
* Sets the players equalizer bands using one of the predefined presets.
|
|
3362
|
+
* @param {keyof typeof EQList} preset The preset to use.
|
|
3363
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3364
|
+
*
|
|
3365
|
+
* @example
|
|
3366
|
+
* ```ts
|
|
3367
|
+
* // Set EQ preset
|
|
3368
|
+
* await player.filterManager.setEQPreset('BassboostMedium');
|
|
3369
|
+
* ```
|
|
3370
|
+
*/
|
|
3371
|
+
async setEQPreset(preset) {
|
|
3372
|
+
const bands = EQList[preset];
|
|
3373
|
+
return this.setEQ(bands);
|
|
3374
|
+
}
|
|
3375
|
+
/**
|
|
3376
|
+
* Sets the players equalizer band on-top of the existing ones.
|
|
3377
|
+
* @param {number} bands
|
|
3378
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3379
|
+
*
|
|
3380
|
+
* @example
|
|
3381
|
+
* ```ts
|
|
3382
|
+
* // Set EQ bands
|
|
3383
|
+
* await player.filterManager.setEQ([
|
|
3384
|
+
* { band: 0, gain: 0.3 },
|
|
3385
|
+
* { band: 1, gain: -0.2 },
|
|
3386
|
+
* { band: 2, gain: 0.1 }
|
|
3387
|
+
* ]);
|
|
3388
|
+
*
|
|
3389
|
+
* // or use one of the templates:
|
|
3390
|
+
* await player.filterManager.setEQ(player.filterManager.EQList.BassboostMedium); // you can also import EQList from somewhere package if wanted.
|
|
3391
|
+
* ```
|
|
3392
|
+
*/
|
|
3233
3393
|
async setEQ(bands) {
|
|
3234
3394
|
if (!Array.isArray(bands)) bands = [bands];
|
|
3235
3395
|
if (!bands.length || !bands.every((band) => safeStringify(Object.keys(band).sort()) === '["band","gain"]')) throw new TypeError("Bands must be a non-empty object array containing 'band' and 'gain' properties.");
|
|
@@ -3246,7 +3406,16 @@ var FilterManager = class {
|
|
|
3246
3406
|
this.player.ping.lavalink = Math.round((performance.now() - now) / 10) / 100;
|
|
3247
3407
|
return this;
|
|
3248
3408
|
}
|
|
3249
|
-
/**
|
|
3409
|
+
/**
|
|
3410
|
+
* Clears the equalizer bands.
|
|
3411
|
+
* @returns {Promise<FilterManager>} The Filter Manager, for chaining.
|
|
3412
|
+
*
|
|
3413
|
+
* @example
|
|
3414
|
+
* ```ts
|
|
3415
|
+
* // Clear all EQ bands
|
|
3416
|
+
* await player.filterManager.clearEQ();
|
|
3417
|
+
* ```
|
|
3418
|
+
*/
|
|
3250
3419
|
async clearEQ() {
|
|
3251
3420
|
return this.setEQ(Array.from({ length: 15 }, (_v, i) => ({ band: i, gain: 0 })));
|
|
3252
3421
|
}
|