lavalink-client 2.6.2 → 2.6.4
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 +18 -3
- package/dist/index.d.ts +18 -3
- package/dist/index.js +168 -178
- package/dist/index.mjs +168 -178
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -280,9 +280,6 @@ declare const EQList: {
|
|
|
280
280
|
Gaming: EQBand[];
|
|
281
281
|
};
|
|
282
282
|
|
|
283
|
-
/**
|
|
284
|
-
* The FilterManager for each player
|
|
285
|
-
*/
|
|
286
283
|
declare class FilterManager {
|
|
287
284
|
/** The Equalizer bands currently applied to the Lavalink Server */
|
|
288
285
|
equalizerBands: EQBand[];
|
|
@@ -1407,6 +1404,24 @@ declare class ManagerUtils {
|
|
|
1407
1404
|
* @param data
|
|
1408
1405
|
*/
|
|
1409
1406
|
isNodeOptions(data: LavalinkNodeOptions): boolean;
|
|
1407
|
+
/**
|
|
1408
|
+
* Validate tracks based on duration wether they are playble or broken tracks.
|
|
1409
|
+
* most tracks should be longer than 30s, so you can put a minDuration of 29e3 (cause preview tracks are exactly 30s) or put 0.
|
|
1410
|
+
* This check is not done automatically, you need to check it yourself by doing:
|
|
1411
|
+
* @example
|
|
1412
|
+
* ```ts
|
|
1413
|
+
* const tracks = await player.search("Adele");
|
|
1414
|
+
*
|
|
1415
|
+
* // short hand:
|
|
1416
|
+
* const validTracks = tracks.filter(client.lavalink.utils.isNotBrokenTrack)
|
|
1417
|
+
* // or with options:
|
|
1418
|
+
* const vaildTracks = tracks.filter(t => client.lavalink.utils.isNotBrokenTrack(t, 29e3));
|
|
1419
|
+
*
|
|
1420
|
+
* // then you can add it to the queue.
|
|
1421
|
+
* await player.queue.add(validTracks);
|
|
1422
|
+
* ```
|
|
1423
|
+
*/
|
|
1424
|
+
isNotBrokenTrack(data: Track, minDuration?: number): data is Track;
|
|
1410
1425
|
/**
|
|
1411
1426
|
* Validate if a data is equal to a track
|
|
1412
1427
|
* @param data the Track to validate
|
package/dist/index.d.ts
CHANGED
|
@@ -280,9 +280,6 @@ declare const EQList: {
|
|
|
280
280
|
Gaming: EQBand[];
|
|
281
281
|
};
|
|
282
282
|
|
|
283
|
-
/**
|
|
284
|
-
* The FilterManager for each player
|
|
285
|
-
*/
|
|
286
283
|
declare class FilterManager {
|
|
287
284
|
/** The Equalizer bands currently applied to the Lavalink Server */
|
|
288
285
|
equalizerBands: EQBand[];
|
|
@@ -1407,6 +1404,24 @@ declare class ManagerUtils {
|
|
|
1407
1404
|
* @param data
|
|
1408
1405
|
*/
|
|
1409
1406
|
isNodeOptions(data: LavalinkNodeOptions): boolean;
|
|
1407
|
+
/**
|
|
1408
|
+
* Validate tracks based on duration wether they are playble or broken tracks.
|
|
1409
|
+
* most tracks should be longer than 30s, so you can put a minDuration of 29e3 (cause preview tracks are exactly 30s) or put 0.
|
|
1410
|
+
* This check is not done automatically, you need to check it yourself by doing:
|
|
1411
|
+
* @example
|
|
1412
|
+
* ```ts
|
|
1413
|
+
* const tracks = await player.search("Adele");
|
|
1414
|
+
*
|
|
1415
|
+
* // short hand:
|
|
1416
|
+
* const validTracks = tracks.filter(client.lavalink.utils.isNotBrokenTrack)
|
|
1417
|
+
* // or with options:
|
|
1418
|
+
* const vaildTracks = tracks.filter(t => client.lavalink.utils.isNotBrokenTrack(t, 29e3));
|
|
1419
|
+
*
|
|
1420
|
+
* // then you can add it to the queue.
|
|
1421
|
+
* await player.queue.add(validTracks);
|
|
1422
|
+
* ```
|
|
1423
|
+
*/
|
|
1424
|
+
isNotBrokenTrack(data: Track, minDuration?: number): data is Track;
|
|
1410
1425
|
/**
|
|
1411
1426
|
* Validate if a data is equal to a track
|
|
1412
1427
|
* @param data the Track to validate
|
package/dist/index.js
CHANGED
|
@@ -671,6 +671,29 @@ var ManagerUtils = class {
|
|
|
671
671
|
if ("requestTimeout" in data && (typeof data.requestTimeout !== "number" || isNaN(data.requestTimeout) || data.requestTimeout <= 0 && data.requestTimeout !== void 0)) return false;
|
|
672
672
|
return true;
|
|
673
673
|
}
|
|
674
|
+
/**
|
|
675
|
+
* Validate tracks based on duration wether they are playble or broken tracks.
|
|
676
|
+
* most tracks should be longer than 30s, so you can put a minDuration of 29e3 (cause preview tracks are exactly 30s) or put 0.
|
|
677
|
+
* This check is not done automatically, you need to check it yourself by doing:
|
|
678
|
+
* @example
|
|
679
|
+
* ```ts
|
|
680
|
+
* const tracks = await player.search("Adele");
|
|
681
|
+
*
|
|
682
|
+
* // short hand:
|
|
683
|
+
* const validTracks = tracks.filter(client.lavalink.utils.isNotBrokenTrack)
|
|
684
|
+
* // or with options:
|
|
685
|
+
* const vaildTracks = tracks.filter(t => client.lavalink.utils.isNotBrokenTrack(t, 29e3));
|
|
686
|
+
*
|
|
687
|
+
* // then you can add it to the queue.
|
|
688
|
+
* await player.queue.add(validTracks);
|
|
689
|
+
* ```
|
|
690
|
+
*/
|
|
691
|
+
isNotBrokenTrack(data, minDuration = 29e3) {
|
|
692
|
+
if (typeof data?.info?.duration !== "number" || isNaN(data?.info?.duration)) return false;
|
|
693
|
+
if (data.info.duration <= Math.max(minDuration, 0)) return false;
|
|
694
|
+
if (!data.info) return false;
|
|
695
|
+
return this.isTrack(data);
|
|
696
|
+
}
|
|
674
697
|
/**
|
|
675
698
|
* Validate if a data is equal to a track
|
|
676
699
|
* @param data the Track to validate
|
|
@@ -2689,6 +2712,88 @@ var bandCampSearch = async (player, query, requestUser) => {
|
|
|
2689
2712
|
};
|
|
2690
2713
|
|
|
2691
2714
|
// src/structures/Filters.ts
|
|
2715
|
+
var DEFAULT_FILTER_DATAS = {
|
|
2716
|
+
volume: 1,
|
|
2717
|
+
lowPass: {
|
|
2718
|
+
smoothing: 0
|
|
2719
|
+
},
|
|
2720
|
+
karaoke: {
|
|
2721
|
+
level: 0,
|
|
2722
|
+
monoLevel: 0,
|
|
2723
|
+
filterBand: 0,
|
|
2724
|
+
filterWidth: 0
|
|
2725
|
+
},
|
|
2726
|
+
timescale: {
|
|
2727
|
+
speed: 1,
|
|
2728
|
+
// 0 = x
|
|
2729
|
+
pitch: 1,
|
|
2730
|
+
// 0 = x
|
|
2731
|
+
rate: 1
|
|
2732
|
+
// 0 = x
|
|
2733
|
+
},
|
|
2734
|
+
rotation: {
|
|
2735
|
+
rotationHz: 0
|
|
2736
|
+
},
|
|
2737
|
+
tremolo: {
|
|
2738
|
+
frequency: 0,
|
|
2739
|
+
// 0 < x
|
|
2740
|
+
depth: 0
|
|
2741
|
+
// 0 < x = 1
|
|
2742
|
+
},
|
|
2743
|
+
vibrato: {
|
|
2744
|
+
frequency: 0,
|
|
2745
|
+
// 0 < x <= 14
|
|
2746
|
+
depth: 0
|
|
2747
|
+
// 0 < x <= 1
|
|
2748
|
+
},
|
|
2749
|
+
channelMix: audioOutputsData.stereo,
|
|
2750
|
+
pluginFilters: {
|
|
2751
|
+
"lavalink-filter-plugin": {
|
|
2752
|
+
echo: {
|
|
2753
|
+
delay: 0,
|
|
2754
|
+
// in seconds
|
|
2755
|
+
decay: 0
|
|
2756
|
+
// 0 < 1
|
|
2757
|
+
},
|
|
2758
|
+
reverb: {
|
|
2759
|
+
delays: [],
|
|
2760
|
+
// [0.037, 0.042, 0.048, 0.053]
|
|
2761
|
+
gains: []
|
|
2762
|
+
// [0.84, 0.83, 0.82, 0.81]
|
|
2763
|
+
}
|
|
2764
|
+
},
|
|
2765
|
+
"high-pass": {
|
|
2766
|
+
// Cuts off frequencies lower than the specified {cutoffFrequency}.
|
|
2767
|
+
// "cutoffFrequency": 1475, // Integer, higher than zero, in Hz.
|
|
2768
|
+
// "boostFactor": 1.0 // Float, higher than 0.0. This alters volume output. A value of 1.0 means no volume change.
|
|
2769
|
+
},
|
|
2770
|
+
"low-pass": {
|
|
2771
|
+
// Cuts off frequencies higher than the specified {cutoffFrequency}.
|
|
2772
|
+
// "cutoffFrequency": 284, // Integer, higher than zero, in Hz.
|
|
2773
|
+
// "boostFactor": 1.24389 // Float, higher than 0.0. This alters volume output. A value of 1.0 means no volume change.
|
|
2774
|
+
},
|
|
2775
|
+
"normalization": {
|
|
2776
|
+
// Attenuates peaking where peaks are defined as having a higher value than {maxAmplitude}.
|
|
2777
|
+
// "maxAmplitude": 0.6327, // Float, within the range of 0.0 - 1.0. A value of 0.0 mutes the output.
|
|
2778
|
+
// "adaptive": true // false
|
|
2779
|
+
},
|
|
2780
|
+
"echo": {
|
|
2781
|
+
// Self-explanatory; provides an echo effect.
|
|
2782
|
+
// "echoLength": 0.5649, // Float, higher than 0.0, in seconds (1.0 = 1 second).
|
|
2783
|
+
// "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
|
|
2784
|
+
}
|
|
2785
|
+
}
|
|
2786
|
+
/*distortion: {
|
|
2787
|
+
sinOffset: 0,
|
|
2788
|
+
sinScale: 1,
|
|
2789
|
+
cosOffset: 0,
|
|
2790
|
+
cosScale: 1,
|
|
2791
|
+
tanOffset: 0,
|
|
2792
|
+
tanScale: 1,
|
|
2793
|
+
offset: 0,
|
|
2794
|
+
scale: 1
|
|
2795
|
+
}*/
|
|
2796
|
+
};
|
|
2692
2797
|
var FilterManager = class {
|
|
2693
2798
|
/** The Equalizer bands currently applied to the Lavalink Server */
|
|
2694
2799
|
equalizerBands = [];
|
|
@@ -2718,88 +2823,7 @@ var FilterManager = class {
|
|
|
2718
2823
|
audioOutput: "stereo"
|
|
2719
2824
|
};
|
|
2720
2825
|
/** The Filter Data sent to Lavalink, only if the filter is enabled (ofc.) */
|
|
2721
|
-
data =
|
|
2722
|
-
volume: 1,
|
|
2723
|
-
lowPass: {
|
|
2724
|
-
smoothing: 0
|
|
2725
|
-
},
|
|
2726
|
-
karaoke: {
|
|
2727
|
-
level: 0,
|
|
2728
|
-
monoLevel: 0,
|
|
2729
|
-
filterBand: 0,
|
|
2730
|
-
filterWidth: 0
|
|
2731
|
-
},
|
|
2732
|
-
timescale: {
|
|
2733
|
-
speed: 1,
|
|
2734
|
-
// 0 = x
|
|
2735
|
-
pitch: 1,
|
|
2736
|
-
// 0 = x
|
|
2737
|
-
rate: 1
|
|
2738
|
-
// 0 = x
|
|
2739
|
-
},
|
|
2740
|
-
rotation: {
|
|
2741
|
-
rotationHz: 0
|
|
2742
|
-
},
|
|
2743
|
-
tremolo: {
|
|
2744
|
-
frequency: 0,
|
|
2745
|
-
// 0 < x
|
|
2746
|
-
depth: 0
|
|
2747
|
-
// 0 < x = 1
|
|
2748
|
-
},
|
|
2749
|
-
vibrato: {
|
|
2750
|
-
frequency: 0,
|
|
2751
|
-
// 0 < x <= 14
|
|
2752
|
-
depth: 0
|
|
2753
|
-
// 0 < x <= 1
|
|
2754
|
-
},
|
|
2755
|
-
pluginFilters: {
|
|
2756
|
-
"lavalink-filter-plugin": {
|
|
2757
|
-
echo: {
|
|
2758
|
-
delay: 0,
|
|
2759
|
-
// in seconds
|
|
2760
|
-
decay: 0
|
|
2761
|
-
// 0 < 1
|
|
2762
|
-
},
|
|
2763
|
-
reverb: {
|
|
2764
|
-
delays: [],
|
|
2765
|
-
// [0.037, 0.042, 0.048, 0.053]
|
|
2766
|
-
gains: []
|
|
2767
|
-
// [0.84, 0.83, 0.82, 0.81]
|
|
2768
|
-
}
|
|
2769
|
-
},
|
|
2770
|
-
"high-pass": {
|
|
2771
|
-
// Cuts off frequencies lower than the specified {cutoffFrequency}.
|
|
2772
|
-
// "cutoffFrequency": 1475, // Integer, higher than zero, in Hz.
|
|
2773
|
-
// "boostFactor": 1.0 // Float, higher than 0.0. This alters volume output. A value of 1.0 means no volume change.
|
|
2774
|
-
},
|
|
2775
|
-
"low-pass": {
|
|
2776
|
-
// Cuts off frequencies higher than the specified {cutoffFrequency}.
|
|
2777
|
-
// "cutoffFrequency": 284, // Integer, higher than zero, in Hz.
|
|
2778
|
-
// "boostFactor": 1.24389 // Float, higher than 0.0. This alters volume output. A value of 1.0 means no volume change.
|
|
2779
|
-
},
|
|
2780
|
-
"normalization": {
|
|
2781
|
-
// Attenuates peaking where peaks are defined as having a higher value than {maxAmplitude}.
|
|
2782
|
-
// "maxAmplitude": 0.6327, // Float, within the range of 0.0 - 1.0. A value of 0.0 mutes the output.
|
|
2783
|
-
// "adaptive": true // false
|
|
2784
|
-
},
|
|
2785
|
-
"echo": {
|
|
2786
|
-
// Self-explanatory; provides an echo effect.
|
|
2787
|
-
// "echoLength": 0.5649, // Float, higher than 0.0, in seconds (1.0 = 1 second).
|
|
2788
|
-
// "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
|
|
2789
|
-
}
|
|
2790
|
-
},
|
|
2791
|
-
channelMix: audioOutputsData.stereo
|
|
2792
|
-
/*distortion: {
|
|
2793
|
-
sinOffset: 0,
|
|
2794
|
-
sinScale: 1,
|
|
2795
|
-
cosOffset: 0,
|
|
2796
|
-
cosScale: 1,
|
|
2797
|
-
tanOffset: 0,
|
|
2798
|
-
tanScale: 1,
|
|
2799
|
-
offset: 0,
|
|
2800
|
-
scale: 1
|
|
2801
|
-
}*/
|
|
2802
|
-
};
|
|
2826
|
+
data = structuredClone(DEFAULT_FILTER_DATAS);
|
|
2803
2827
|
/** The Player assigned to this Filter Manager */
|
|
2804
2828
|
player;
|
|
2805
2829
|
/** The Constructor for the FilterManager */
|
|
@@ -2972,6 +2996,7 @@ var FilterManager = class {
|
|
|
2972
2996
|
*/
|
|
2973
2997
|
async setVolume(volume) {
|
|
2974
2998
|
if (volume < 0 || volume > 5) throw new SyntaxError("Volume-Filter must be between 0 and 5");
|
|
2999
|
+
this.data = this.data ?? {};
|
|
2975
3000
|
this.data.volume = volume;
|
|
2976
3001
|
this.filters.volume = volume !== 1;
|
|
2977
3002
|
await this.applyPlayerFilters();
|
|
@@ -2985,6 +3010,7 @@ var FilterManager = class {
|
|
|
2985
3010
|
async setAudioOutput(type) {
|
|
2986
3011
|
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)");
|
|
2987
3012
|
if (!type || !audioOutputsData[type]) throw "Invalid audio type added, must be 'mono' / 'stereo' / 'left' / 'right'";
|
|
3013
|
+
this.data = this.data ?? {};
|
|
2988
3014
|
this.data.channelMix = audioOutputsData[type];
|
|
2989
3015
|
this.filters.audioOutput = type;
|
|
2990
3016
|
await this.applyPlayerFilters();
|
|
@@ -2997,14 +3023,10 @@ var FilterManager = class {
|
|
|
2997
3023
|
*/
|
|
2998
3024
|
async setSpeed(speed = 1) {
|
|
2999
3025
|
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)");
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
this.filters.nightcore = false;
|
|
3005
|
-
this.filters.vaporwave = false;
|
|
3006
|
-
}
|
|
3007
|
-
this.data.timescale.speed = speed;
|
|
3026
|
+
this.data = this.data ?? {};
|
|
3027
|
+
this.filters.nightcore = false;
|
|
3028
|
+
this.filters.vaporwave = false;
|
|
3029
|
+
this.data.timescale = { ...DEFAULT_FILTER_DATAS.timescale, speed };
|
|
3008
3030
|
this.isCustomFilterActive();
|
|
3009
3031
|
await this.applyPlayerFilters();
|
|
3010
3032
|
return this.filters.custom;
|
|
@@ -3016,14 +3038,10 @@ var FilterManager = class {
|
|
|
3016
3038
|
*/
|
|
3017
3039
|
async setPitch(pitch = 1) {
|
|
3018
3040
|
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)");
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
this.filters.nightcore = false;
|
|
3024
|
-
this.filters.vaporwave = false;
|
|
3025
|
-
}
|
|
3026
|
-
this.data.timescale.pitch = pitch;
|
|
3041
|
+
this.data = this.data ?? {};
|
|
3042
|
+
this.filters.nightcore = false;
|
|
3043
|
+
this.filters.vaporwave = false;
|
|
3044
|
+
this.data.timescale = { ...DEFAULT_FILTER_DATAS.timescale, pitch };
|
|
3027
3045
|
this.isCustomFilterActive();
|
|
3028
3046
|
await this.applyPlayerFilters();
|
|
3029
3047
|
return this.filters.custom;
|
|
@@ -3035,14 +3053,10 @@ var FilterManager = class {
|
|
|
3035
3053
|
*/
|
|
3036
3054
|
async setRate(rate = 1) {
|
|
3037
3055
|
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)");
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
this.filters.nightcore = false;
|
|
3043
|
-
this.filters.vaporwave = false;
|
|
3044
|
-
}
|
|
3045
|
-
this.data.timescale.rate = rate;
|
|
3056
|
+
this.data = this.data ?? {};
|
|
3057
|
+
this.filters.nightcore = false;
|
|
3058
|
+
this.filters.vaporwave = false;
|
|
3059
|
+
this.data.timescale = { ...DEFAULT_FILTER_DATAS.timescale, rate };
|
|
3046
3060
|
this.isCustomFilterActive();
|
|
3047
3061
|
await this.applyPlayerFilters();
|
|
3048
3062
|
return this.filters.custom;
|
|
@@ -3054,7 +3068,8 @@ var FilterManager = class {
|
|
|
3054
3068
|
*/
|
|
3055
3069
|
async toggleRotation(rotationHz = 0.2) {
|
|
3056
3070
|
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)");
|
|
3057
|
-
this.data
|
|
3071
|
+
this.data = this.data ?? {};
|
|
3072
|
+
this.data.rotation = this.filters.rotation ? DEFAULT_FILTER_DATAS.rotation : { rotationHz };
|
|
3058
3073
|
this.filters.rotation = !this.filters.rotation;
|
|
3059
3074
|
await this.applyPlayerFilters();
|
|
3060
3075
|
return this.filters.rotation;
|
|
@@ -3067,8 +3082,8 @@ var FilterManager = class {
|
|
|
3067
3082
|
*/
|
|
3068
3083
|
async toggleVibrato(frequency = 10, depth = 1) {
|
|
3069
3084
|
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)");
|
|
3070
|
-
this.data
|
|
3071
|
-
this.data.vibrato
|
|
3085
|
+
this.data = this.data ?? {};
|
|
3086
|
+
this.data.vibrato = this.filters.vibrato ? DEFAULT_FILTER_DATAS.vibrato : { depth, frequency };
|
|
3072
3087
|
this.filters.vibrato = !this.filters.vibrato;
|
|
3073
3088
|
await this.applyPlayerFilters();
|
|
3074
3089
|
return this.filters.vibrato;
|
|
@@ -3081,8 +3096,8 @@ var FilterManager = class {
|
|
|
3081
3096
|
*/
|
|
3082
3097
|
async toggleTremolo(frequency = 4, depth = 0.8) {
|
|
3083
3098
|
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)");
|
|
3084
|
-
this.data
|
|
3085
|
-
this.data.tremolo
|
|
3099
|
+
this.data = this.data ?? {};
|
|
3100
|
+
this.data.tremolo = this.filters.tremolo ? DEFAULT_FILTER_DATAS.tremolo : { depth, frequency };
|
|
3086
3101
|
this.filters.tremolo = !this.filters.tremolo;
|
|
3087
3102
|
await this.applyPlayerFilters();
|
|
3088
3103
|
return this.filters.tremolo;
|
|
@@ -3094,7 +3109,8 @@ var FilterManager = class {
|
|
|
3094
3109
|
*/
|
|
3095
3110
|
async toggleLowPass(smoothing = 20) {
|
|
3096
3111
|
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)");
|
|
3097
|
-
this.data
|
|
3112
|
+
this.data = this.data ?? {};
|
|
3113
|
+
this.data.lowPass = this.filters.lowPass ? DEFAULT_FILTER_DATAS.lowPass : { smoothing };
|
|
3098
3114
|
this.filters.lowPass = !this.filters.lowPass;
|
|
3099
3115
|
await this.applyPlayerFilters();
|
|
3100
3116
|
return this.filters.lowPass;
|
|
@@ -3109,17 +3125,10 @@ var FilterManager = class {
|
|
|
3109
3125
|
toggleLowPass: async (boostFactor = 1, cutoffFrequency = 80) => {
|
|
3110
3126
|
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");
|
|
3111
3127
|
if (this.player.node.info && !this.player.node.info?.filters?.includes("low-pass")) throw new Error("Node#Info#filters does not include the 'low-pass' Filter (Node has it not enable)");
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
if (
|
|
3115
|
-
|
|
3116
|
-
delete this.data.pluginFilters["low-pass"];
|
|
3117
|
-
} else {
|
|
3118
|
-
this.data.pluginFilters["low-pass"] = {
|
|
3119
|
-
boostFactor,
|
|
3120
|
-
cutoffFrequency
|
|
3121
|
-
};
|
|
3122
|
-
}
|
|
3128
|
+
this.data = this.data ?? {};
|
|
3129
|
+
this.data.pluginFilters = this.data.pluginFilters ?? {};
|
|
3130
|
+
if (this.filters.lavalinkLavaDspxPlugin.lowPass) delete this.data.pluginFilters["low-pass"];
|
|
3131
|
+
else this.data.pluginFilters["low-pass"] = { boostFactor, cutoffFrequency };
|
|
3123
3132
|
this.filters.lavalinkLavaDspxPlugin.lowPass = !this.filters.lavalinkLavaDspxPlugin.lowPass;
|
|
3124
3133
|
await this.applyPlayerFilters();
|
|
3125
3134
|
return this.filters.lavalinkLavaDspxPlugin.lowPass;
|
|
@@ -3133,17 +3142,10 @@ var FilterManager = class {
|
|
|
3133
3142
|
toggleHighPass: async (boostFactor = 1, cutoffFrequency = 80) => {
|
|
3134
3143
|
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");
|
|
3135
3144
|
if (this.player.node.info && !this.player.node.info?.filters?.includes("high-pass")) throw new Error("Node#Info#filters does not include the 'high-pass' Filter (Node has it not enable)");
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
if (
|
|
3139
|
-
|
|
3140
|
-
delete this.data.pluginFilters["high-pass"];
|
|
3141
|
-
} else {
|
|
3142
|
-
this.data.pluginFilters["high-pass"] = {
|
|
3143
|
-
boostFactor,
|
|
3144
|
-
cutoffFrequency
|
|
3145
|
-
};
|
|
3146
|
-
}
|
|
3145
|
+
this.data = this.data ?? {};
|
|
3146
|
+
this.data.pluginFilters = this.data.pluginFilters ?? {};
|
|
3147
|
+
if (this.filters.lavalinkLavaDspxPlugin.highPass) delete this.data.pluginFilters["high-pass"];
|
|
3148
|
+
else this.data.pluginFilters["high-pass"] = { boostFactor, cutoffFrequency };
|
|
3147
3149
|
this.filters.lavalinkLavaDspxPlugin.highPass = !this.filters.lavalinkLavaDspxPlugin.highPass;
|
|
3148
3150
|
await this.applyPlayerFilters();
|
|
3149
3151
|
return this.filters.lavalinkLavaDspxPlugin.highPass;
|
|
@@ -3157,17 +3159,10 @@ var FilterManager = class {
|
|
|
3157
3159
|
toggleNormalization: async (maxAmplitude = 0.75, adaptive = true) => {
|
|
3158
3160
|
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");
|
|
3159
3161
|
if (this.player.node.info && !this.player.node.info?.filters?.includes("normalization")) throw new Error("Node#Info#filters does not include the 'normalization' Filter (Node has it not enable)");
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
if (
|
|
3163
|
-
|
|
3164
|
-
delete this.data.pluginFilters.normalization;
|
|
3165
|
-
} else {
|
|
3166
|
-
this.data.pluginFilters.normalization = {
|
|
3167
|
-
adaptive,
|
|
3168
|
-
maxAmplitude
|
|
3169
|
-
};
|
|
3170
|
-
}
|
|
3162
|
+
this.data = this.data ?? {};
|
|
3163
|
+
this.data.pluginFilters = this.data.pluginFilters ?? {};
|
|
3164
|
+
if (this.filters.lavalinkLavaDspxPlugin.normalization) delete this.data.pluginFilters.normalization;
|
|
3165
|
+
else this.data.pluginFilters.normalization = { adaptive, maxAmplitude };
|
|
3171
3166
|
this.filters.lavalinkLavaDspxPlugin.normalization = !this.filters.lavalinkLavaDspxPlugin.normalization;
|
|
3172
3167
|
await this.applyPlayerFilters();
|
|
3173
3168
|
return this.filters.lavalinkLavaDspxPlugin.normalization;
|
|
@@ -3181,17 +3176,10 @@ var FilterManager = class {
|
|
|
3181
3176
|
toggleEcho: async (decay = 0.5, echoLength = 0.5) => {
|
|
3182
3177
|
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");
|
|
3183
3178
|
if (this.player.node.info && !this.player.node.info?.filters?.includes("echo")) throw new Error("Node#Info#filters does not include the 'echo' Filter (Node has it not enable)");
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
if (
|
|
3187
|
-
|
|
3188
|
-
delete this.data.pluginFilters.echo;
|
|
3189
|
-
} else {
|
|
3190
|
-
this.data.pluginFilters.echo = {
|
|
3191
|
-
decay,
|
|
3192
|
-
echoLength
|
|
3193
|
-
};
|
|
3194
|
-
}
|
|
3179
|
+
this.data = this.data ?? {};
|
|
3180
|
+
this.data.pluginFilters = this.data.pluginFilters ?? {};
|
|
3181
|
+
if (this.filters.lavalinkLavaDspxPlugin.echo) delete this.data.pluginFilters.echo;
|
|
3182
|
+
else this.data.pluginFilters.echo = { decay, echoLength };
|
|
3195
3183
|
this.filters.lavalinkLavaDspxPlugin.echo = !this.filters.lavalinkLavaDspxPlugin.echo;
|
|
3196
3184
|
await this.applyPlayerFilters();
|
|
3197
3185
|
return this.filters.lavalinkLavaDspxPlugin.echo;
|
|
@@ -3207,12 +3195,15 @@ var FilterManager = class {
|
|
|
3207
3195
|
toggleEcho: async (delay = 4, decay = 0.8) => {
|
|
3208
3196
|
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");
|
|
3209
3197
|
if (this.player.node.info && !this.player.node.info?.filters?.includes("echo")) throw new Error("Node#Info#filters does not include the 'echo' Filter (Node has it not enable aka not installed!)");
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3198
|
+
this.data = this.data ?? {};
|
|
3199
|
+
const { echo, reverb } = DEFAULT_FILTER_DATAS.pluginFilters["lavalink-filter-plugin"];
|
|
3200
|
+
this.data.pluginFilters = {
|
|
3201
|
+
...this.data.pluginFilters,
|
|
3202
|
+
["lavalink-filter-plugin"]: {
|
|
3203
|
+
reverb: this.data.pluginFilters?.["lavalink-filter-plugin"]?.reverb ?? reverb,
|
|
3204
|
+
echo: this.filters.lavalinkFilterPlugin.echo ? echo : { delay, decay }
|
|
3205
|
+
}
|
|
3206
|
+
};
|
|
3216
3207
|
this.filters.lavalinkFilterPlugin.echo = !this.filters.lavalinkFilterPlugin.echo;
|
|
3217
3208
|
await this.applyPlayerFilters();
|
|
3218
3209
|
return this.filters.lavalinkFilterPlugin.echo;
|
|
@@ -3226,12 +3217,15 @@ var FilterManager = class {
|
|
|
3226
3217
|
toggleReverb: async (delays = [0.037, 0.042, 0.048, 0.053], gains = [0.84, 0.83, 0.82, 0.81]) => {
|
|
3227
3218
|
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");
|
|
3228
3219
|
if (this.player.node.info && !this.player.node.info?.filters?.includes("reverb")) throw new Error("Node#Info#filters does not include the 'reverb' Filter (Node has it not enable aka not installed!)");
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3220
|
+
this.data = this.data ?? {};
|
|
3221
|
+
const { echo, reverb } = DEFAULT_FILTER_DATAS.pluginFilters["lavalink-filter-plugin"];
|
|
3222
|
+
this.data.pluginFilters = {
|
|
3223
|
+
...this.data.pluginFilters,
|
|
3224
|
+
["lavalink-filter-plugin"]: {
|
|
3225
|
+
echo: this.data.pluginFilters?.["lavalink-filter-plugin"]?.echo ?? echo,
|
|
3226
|
+
reverb: this.filters.lavalinkFilterPlugin.reverb ? reverb : { delays, gains }
|
|
3227
|
+
}
|
|
3228
|
+
};
|
|
3235
3229
|
this.filters.lavalinkFilterPlugin.reverb = !this.filters.lavalinkFilterPlugin.reverb;
|
|
3236
3230
|
await this.applyPlayerFilters();
|
|
3237
3231
|
return this.filters.lavalinkFilterPlugin.reverb;
|
|
@@ -3246,9 +3240,8 @@ var FilterManager = class {
|
|
|
3246
3240
|
*/
|
|
3247
3241
|
async toggleNightcore(speed = 1.289999523162842, pitch = 1.289999523162842, rate = 0.9365999523162842) {
|
|
3248
3242
|
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)");
|
|
3249
|
-
this.data
|
|
3250
|
-
this.data.timescale
|
|
3251
|
-
this.data.timescale.rate = this.filters.nightcore ? 1 : rate;
|
|
3243
|
+
this.data = this.data ?? {};
|
|
3244
|
+
this.data.timescale = this.filters.nightcore ? DEFAULT_FILTER_DATAS.timescale : { speed, pitch, rate };
|
|
3252
3245
|
this.filters.nightcore = !this.filters.nightcore;
|
|
3253
3246
|
this.filters.vaporwave = false;
|
|
3254
3247
|
this.filters.custom = false;
|
|
@@ -3264,9 +3257,8 @@ var FilterManager = class {
|
|
|
3264
3257
|
*/
|
|
3265
3258
|
async toggleVaporwave(speed = 0.8500000238418579, pitch = 0.800000011920929, rate = 1) {
|
|
3266
3259
|
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)");
|
|
3267
|
-
this.data
|
|
3268
|
-
this.data.timescale
|
|
3269
|
-
this.data.timescale.rate = this.filters.vaporwave ? 1 : rate;
|
|
3260
|
+
this.data = this.data ?? {};
|
|
3261
|
+
this.data.timescale = this.filters.vaporwave ? DEFAULT_FILTER_DATAS.timescale : { speed, pitch, rate };
|
|
3270
3262
|
this.filters.vaporwave = !this.filters.vaporwave;
|
|
3271
3263
|
this.filters.nightcore = false;
|
|
3272
3264
|
this.filters.custom = false;
|
|
@@ -3283,10 +3275,8 @@ var FilterManager = class {
|
|
|
3283
3275
|
*/
|
|
3284
3276
|
async toggleKaraoke(level = 1, monoLevel = 1, filterBand = 220, filterWidth = 100) {
|
|
3285
3277
|
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)");
|
|
3286
|
-
this.data
|
|
3287
|
-
this.data.karaoke
|
|
3288
|
-
this.data.karaoke.filterBand = this.filters.karaoke ? 0 : filterBand;
|
|
3289
|
-
this.data.karaoke.filterWidth = this.filters.karaoke ? 0 : filterWidth;
|
|
3278
|
+
this.data = this.data ?? {};
|
|
3279
|
+
this.data.karaoke = this.filters.karaoke ? DEFAULT_FILTER_DATAS.karaoke : { level, monoLevel, filterBand, filterWidth };
|
|
3290
3280
|
this.filters.karaoke = !this.filters.karaoke;
|
|
3291
3281
|
await this.applyPlayerFilters();
|
|
3292
3282
|
return this.filters.karaoke;
|
package/dist/index.mjs
CHANGED
|
@@ -611,6 +611,29 @@ var ManagerUtils = class {
|
|
|
611
611
|
if ("requestTimeout" in data && (typeof data.requestTimeout !== "number" || isNaN(data.requestTimeout) || data.requestTimeout <= 0 && data.requestTimeout !== void 0)) return false;
|
|
612
612
|
return true;
|
|
613
613
|
}
|
|
614
|
+
/**
|
|
615
|
+
* Validate tracks based on duration wether they are playble or broken tracks.
|
|
616
|
+
* most tracks should be longer than 30s, so you can put a minDuration of 29e3 (cause preview tracks are exactly 30s) or put 0.
|
|
617
|
+
* This check is not done automatically, you need to check it yourself by doing:
|
|
618
|
+
* @example
|
|
619
|
+
* ```ts
|
|
620
|
+
* const tracks = await player.search("Adele");
|
|
621
|
+
*
|
|
622
|
+
* // short hand:
|
|
623
|
+
* const validTracks = tracks.filter(client.lavalink.utils.isNotBrokenTrack)
|
|
624
|
+
* // or with options:
|
|
625
|
+
* const vaildTracks = tracks.filter(t => client.lavalink.utils.isNotBrokenTrack(t, 29e3));
|
|
626
|
+
*
|
|
627
|
+
* // then you can add it to the queue.
|
|
628
|
+
* await player.queue.add(validTracks);
|
|
629
|
+
* ```
|
|
630
|
+
*/
|
|
631
|
+
isNotBrokenTrack(data, minDuration = 29e3) {
|
|
632
|
+
if (typeof data?.info?.duration !== "number" || isNaN(data?.info?.duration)) return false;
|
|
633
|
+
if (data.info.duration <= Math.max(minDuration, 0)) return false;
|
|
634
|
+
if (!data.info) return false;
|
|
635
|
+
return this.isTrack(data);
|
|
636
|
+
}
|
|
614
637
|
/**
|
|
615
638
|
* Validate if a data is equal to a track
|
|
616
639
|
* @param data the Track to validate
|
|
@@ -2629,6 +2652,88 @@ var bandCampSearch = async (player, query, requestUser) => {
|
|
|
2629
2652
|
};
|
|
2630
2653
|
|
|
2631
2654
|
// src/structures/Filters.ts
|
|
2655
|
+
var DEFAULT_FILTER_DATAS = {
|
|
2656
|
+
volume: 1,
|
|
2657
|
+
lowPass: {
|
|
2658
|
+
smoothing: 0
|
|
2659
|
+
},
|
|
2660
|
+
karaoke: {
|
|
2661
|
+
level: 0,
|
|
2662
|
+
monoLevel: 0,
|
|
2663
|
+
filterBand: 0,
|
|
2664
|
+
filterWidth: 0
|
|
2665
|
+
},
|
|
2666
|
+
timescale: {
|
|
2667
|
+
speed: 1,
|
|
2668
|
+
// 0 = x
|
|
2669
|
+
pitch: 1,
|
|
2670
|
+
// 0 = x
|
|
2671
|
+
rate: 1
|
|
2672
|
+
// 0 = x
|
|
2673
|
+
},
|
|
2674
|
+
rotation: {
|
|
2675
|
+
rotationHz: 0
|
|
2676
|
+
},
|
|
2677
|
+
tremolo: {
|
|
2678
|
+
frequency: 0,
|
|
2679
|
+
// 0 < x
|
|
2680
|
+
depth: 0
|
|
2681
|
+
// 0 < x = 1
|
|
2682
|
+
},
|
|
2683
|
+
vibrato: {
|
|
2684
|
+
frequency: 0,
|
|
2685
|
+
// 0 < x <= 14
|
|
2686
|
+
depth: 0
|
|
2687
|
+
// 0 < x <= 1
|
|
2688
|
+
},
|
|
2689
|
+
channelMix: audioOutputsData.stereo,
|
|
2690
|
+
pluginFilters: {
|
|
2691
|
+
"lavalink-filter-plugin": {
|
|
2692
|
+
echo: {
|
|
2693
|
+
delay: 0,
|
|
2694
|
+
// in seconds
|
|
2695
|
+
decay: 0
|
|
2696
|
+
// 0 < 1
|
|
2697
|
+
},
|
|
2698
|
+
reverb: {
|
|
2699
|
+
delays: [],
|
|
2700
|
+
// [0.037, 0.042, 0.048, 0.053]
|
|
2701
|
+
gains: []
|
|
2702
|
+
// [0.84, 0.83, 0.82, 0.81]
|
|
2703
|
+
}
|
|
2704
|
+
},
|
|
2705
|
+
"high-pass": {
|
|
2706
|
+
// Cuts off frequencies lower than the specified {cutoffFrequency}.
|
|
2707
|
+
// "cutoffFrequency": 1475, // Integer, higher than zero, in Hz.
|
|
2708
|
+
// "boostFactor": 1.0 // Float, higher than 0.0. This alters volume output. A value of 1.0 means no volume change.
|
|
2709
|
+
},
|
|
2710
|
+
"low-pass": {
|
|
2711
|
+
// Cuts off frequencies higher than the specified {cutoffFrequency}.
|
|
2712
|
+
// "cutoffFrequency": 284, // Integer, higher than zero, in Hz.
|
|
2713
|
+
// "boostFactor": 1.24389 // Float, higher than 0.0. This alters volume output. A value of 1.0 means no volume change.
|
|
2714
|
+
},
|
|
2715
|
+
"normalization": {
|
|
2716
|
+
// Attenuates peaking where peaks are defined as having a higher value than {maxAmplitude}.
|
|
2717
|
+
// "maxAmplitude": 0.6327, // Float, within the range of 0.0 - 1.0. A value of 0.0 mutes the output.
|
|
2718
|
+
// "adaptive": true // false
|
|
2719
|
+
},
|
|
2720
|
+
"echo": {
|
|
2721
|
+
// Self-explanatory; provides an echo effect.
|
|
2722
|
+
// "echoLength": 0.5649, // Float, higher than 0.0, in seconds (1.0 = 1 second).
|
|
2723
|
+
// "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
|
|
2724
|
+
}
|
|
2725
|
+
}
|
|
2726
|
+
/*distortion: {
|
|
2727
|
+
sinOffset: 0,
|
|
2728
|
+
sinScale: 1,
|
|
2729
|
+
cosOffset: 0,
|
|
2730
|
+
cosScale: 1,
|
|
2731
|
+
tanOffset: 0,
|
|
2732
|
+
tanScale: 1,
|
|
2733
|
+
offset: 0,
|
|
2734
|
+
scale: 1
|
|
2735
|
+
}*/
|
|
2736
|
+
};
|
|
2632
2737
|
var FilterManager = class {
|
|
2633
2738
|
/** The Equalizer bands currently applied to the Lavalink Server */
|
|
2634
2739
|
equalizerBands = [];
|
|
@@ -2658,88 +2763,7 @@ var FilterManager = class {
|
|
|
2658
2763
|
audioOutput: "stereo"
|
|
2659
2764
|
};
|
|
2660
2765
|
/** The Filter Data sent to Lavalink, only if the filter is enabled (ofc.) */
|
|
2661
|
-
data =
|
|
2662
|
-
volume: 1,
|
|
2663
|
-
lowPass: {
|
|
2664
|
-
smoothing: 0
|
|
2665
|
-
},
|
|
2666
|
-
karaoke: {
|
|
2667
|
-
level: 0,
|
|
2668
|
-
monoLevel: 0,
|
|
2669
|
-
filterBand: 0,
|
|
2670
|
-
filterWidth: 0
|
|
2671
|
-
},
|
|
2672
|
-
timescale: {
|
|
2673
|
-
speed: 1,
|
|
2674
|
-
// 0 = x
|
|
2675
|
-
pitch: 1,
|
|
2676
|
-
// 0 = x
|
|
2677
|
-
rate: 1
|
|
2678
|
-
// 0 = x
|
|
2679
|
-
},
|
|
2680
|
-
rotation: {
|
|
2681
|
-
rotationHz: 0
|
|
2682
|
-
},
|
|
2683
|
-
tremolo: {
|
|
2684
|
-
frequency: 0,
|
|
2685
|
-
// 0 < x
|
|
2686
|
-
depth: 0
|
|
2687
|
-
// 0 < x = 1
|
|
2688
|
-
},
|
|
2689
|
-
vibrato: {
|
|
2690
|
-
frequency: 0,
|
|
2691
|
-
// 0 < x <= 14
|
|
2692
|
-
depth: 0
|
|
2693
|
-
// 0 < x <= 1
|
|
2694
|
-
},
|
|
2695
|
-
pluginFilters: {
|
|
2696
|
-
"lavalink-filter-plugin": {
|
|
2697
|
-
echo: {
|
|
2698
|
-
delay: 0,
|
|
2699
|
-
// in seconds
|
|
2700
|
-
decay: 0
|
|
2701
|
-
// 0 < 1
|
|
2702
|
-
},
|
|
2703
|
-
reverb: {
|
|
2704
|
-
delays: [],
|
|
2705
|
-
// [0.037, 0.042, 0.048, 0.053]
|
|
2706
|
-
gains: []
|
|
2707
|
-
// [0.84, 0.83, 0.82, 0.81]
|
|
2708
|
-
}
|
|
2709
|
-
},
|
|
2710
|
-
"high-pass": {
|
|
2711
|
-
// Cuts off frequencies lower than the specified {cutoffFrequency}.
|
|
2712
|
-
// "cutoffFrequency": 1475, // Integer, higher than zero, in Hz.
|
|
2713
|
-
// "boostFactor": 1.0 // Float, higher than 0.0. This alters volume output. A value of 1.0 means no volume change.
|
|
2714
|
-
},
|
|
2715
|
-
"low-pass": {
|
|
2716
|
-
// Cuts off frequencies higher than the specified {cutoffFrequency}.
|
|
2717
|
-
// "cutoffFrequency": 284, // Integer, higher than zero, in Hz.
|
|
2718
|
-
// "boostFactor": 1.24389 // Float, higher than 0.0. This alters volume output. A value of 1.0 means no volume change.
|
|
2719
|
-
},
|
|
2720
|
-
"normalization": {
|
|
2721
|
-
// Attenuates peaking where peaks are defined as having a higher value than {maxAmplitude}.
|
|
2722
|
-
// "maxAmplitude": 0.6327, // Float, within the range of 0.0 - 1.0. A value of 0.0 mutes the output.
|
|
2723
|
-
// "adaptive": true // false
|
|
2724
|
-
},
|
|
2725
|
-
"echo": {
|
|
2726
|
-
// Self-explanatory; provides an echo effect.
|
|
2727
|
-
// "echoLength": 0.5649, // Float, higher than 0.0, in seconds (1.0 = 1 second).
|
|
2728
|
-
// "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
|
|
2729
|
-
}
|
|
2730
|
-
},
|
|
2731
|
-
channelMix: audioOutputsData.stereo
|
|
2732
|
-
/*distortion: {
|
|
2733
|
-
sinOffset: 0,
|
|
2734
|
-
sinScale: 1,
|
|
2735
|
-
cosOffset: 0,
|
|
2736
|
-
cosScale: 1,
|
|
2737
|
-
tanOffset: 0,
|
|
2738
|
-
tanScale: 1,
|
|
2739
|
-
offset: 0,
|
|
2740
|
-
scale: 1
|
|
2741
|
-
}*/
|
|
2742
|
-
};
|
|
2766
|
+
data = structuredClone(DEFAULT_FILTER_DATAS);
|
|
2743
2767
|
/** The Player assigned to this Filter Manager */
|
|
2744
2768
|
player;
|
|
2745
2769
|
/** The Constructor for the FilterManager */
|
|
@@ -2912,6 +2936,7 @@ var FilterManager = class {
|
|
|
2912
2936
|
*/
|
|
2913
2937
|
async setVolume(volume) {
|
|
2914
2938
|
if (volume < 0 || volume > 5) throw new SyntaxError("Volume-Filter must be between 0 and 5");
|
|
2939
|
+
this.data = this.data ?? {};
|
|
2915
2940
|
this.data.volume = volume;
|
|
2916
2941
|
this.filters.volume = volume !== 1;
|
|
2917
2942
|
await this.applyPlayerFilters();
|
|
@@ -2925,6 +2950,7 @@ var FilterManager = class {
|
|
|
2925
2950
|
async setAudioOutput(type) {
|
|
2926
2951
|
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)");
|
|
2927
2952
|
if (!type || !audioOutputsData[type]) throw "Invalid audio type added, must be 'mono' / 'stereo' / 'left' / 'right'";
|
|
2953
|
+
this.data = this.data ?? {};
|
|
2928
2954
|
this.data.channelMix = audioOutputsData[type];
|
|
2929
2955
|
this.filters.audioOutput = type;
|
|
2930
2956
|
await this.applyPlayerFilters();
|
|
@@ -2937,14 +2963,10 @@ var FilterManager = class {
|
|
|
2937
2963
|
*/
|
|
2938
2964
|
async setSpeed(speed = 1) {
|
|
2939
2965
|
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)");
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
this.filters.nightcore = false;
|
|
2945
|
-
this.filters.vaporwave = false;
|
|
2946
|
-
}
|
|
2947
|
-
this.data.timescale.speed = speed;
|
|
2966
|
+
this.data = this.data ?? {};
|
|
2967
|
+
this.filters.nightcore = false;
|
|
2968
|
+
this.filters.vaporwave = false;
|
|
2969
|
+
this.data.timescale = { ...DEFAULT_FILTER_DATAS.timescale, speed };
|
|
2948
2970
|
this.isCustomFilterActive();
|
|
2949
2971
|
await this.applyPlayerFilters();
|
|
2950
2972
|
return this.filters.custom;
|
|
@@ -2956,14 +2978,10 @@ var FilterManager = class {
|
|
|
2956
2978
|
*/
|
|
2957
2979
|
async setPitch(pitch = 1) {
|
|
2958
2980
|
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)");
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
this.filters.nightcore = false;
|
|
2964
|
-
this.filters.vaporwave = false;
|
|
2965
|
-
}
|
|
2966
|
-
this.data.timescale.pitch = pitch;
|
|
2981
|
+
this.data = this.data ?? {};
|
|
2982
|
+
this.filters.nightcore = false;
|
|
2983
|
+
this.filters.vaporwave = false;
|
|
2984
|
+
this.data.timescale = { ...DEFAULT_FILTER_DATAS.timescale, pitch };
|
|
2967
2985
|
this.isCustomFilterActive();
|
|
2968
2986
|
await this.applyPlayerFilters();
|
|
2969
2987
|
return this.filters.custom;
|
|
@@ -2975,14 +2993,10 @@ var FilterManager = class {
|
|
|
2975
2993
|
*/
|
|
2976
2994
|
async setRate(rate = 1) {
|
|
2977
2995
|
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)");
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
this.filters.nightcore = false;
|
|
2983
|
-
this.filters.vaporwave = false;
|
|
2984
|
-
}
|
|
2985
|
-
this.data.timescale.rate = rate;
|
|
2996
|
+
this.data = this.data ?? {};
|
|
2997
|
+
this.filters.nightcore = false;
|
|
2998
|
+
this.filters.vaporwave = false;
|
|
2999
|
+
this.data.timescale = { ...DEFAULT_FILTER_DATAS.timescale, rate };
|
|
2986
3000
|
this.isCustomFilterActive();
|
|
2987
3001
|
await this.applyPlayerFilters();
|
|
2988
3002
|
return this.filters.custom;
|
|
@@ -2994,7 +3008,8 @@ var FilterManager = class {
|
|
|
2994
3008
|
*/
|
|
2995
3009
|
async toggleRotation(rotationHz = 0.2) {
|
|
2996
3010
|
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)");
|
|
2997
|
-
this.data
|
|
3011
|
+
this.data = this.data ?? {};
|
|
3012
|
+
this.data.rotation = this.filters.rotation ? DEFAULT_FILTER_DATAS.rotation : { rotationHz };
|
|
2998
3013
|
this.filters.rotation = !this.filters.rotation;
|
|
2999
3014
|
await this.applyPlayerFilters();
|
|
3000
3015
|
return this.filters.rotation;
|
|
@@ -3007,8 +3022,8 @@ var FilterManager = class {
|
|
|
3007
3022
|
*/
|
|
3008
3023
|
async toggleVibrato(frequency = 10, depth = 1) {
|
|
3009
3024
|
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)");
|
|
3010
|
-
this.data
|
|
3011
|
-
this.data.vibrato
|
|
3025
|
+
this.data = this.data ?? {};
|
|
3026
|
+
this.data.vibrato = this.filters.vibrato ? DEFAULT_FILTER_DATAS.vibrato : { depth, frequency };
|
|
3012
3027
|
this.filters.vibrato = !this.filters.vibrato;
|
|
3013
3028
|
await this.applyPlayerFilters();
|
|
3014
3029
|
return this.filters.vibrato;
|
|
@@ -3021,8 +3036,8 @@ var FilterManager = class {
|
|
|
3021
3036
|
*/
|
|
3022
3037
|
async toggleTremolo(frequency = 4, depth = 0.8) {
|
|
3023
3038
|
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)");
|
|
3024
|
-
this.data
|
|
3025
|
-
this.data.tremolo
|
|
3039
|
+
this.data = this.data ?? {};
|
|
3040
|
+
this.data.tremolo = this.filters.tremolo ? DEFAULT_FILTER_DATAS.tremolo : { depth, frequency };
|
|
3026
3041
|
this.filters.tremolo = !this.filters.tremolo;
|
|
3027
3042
|
await this.applyPlayerFilters();
|
|
3028
3043
|
return this.filters.tremolo;
|
|
@@ -3034,7 +3049,8 @@ var FilterManager = class {
|
|
|
3034
3049
|
*/
|
|
3035
3050
|
async toggleLowPass(smoothing = 20) {
|
|
3036
3051
|
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)");
|
|
3037
|
-
this.data
|
|
3052
|
+
this.data = this.data ?? {};
|
|
3053
|
+
this.data.lowPass = this.filters.lowPass ? DEFAULT_FILTER_DATAS.lowPass : { smoothing };
|
|
3038
3054
|
this.filters.lowPass = !this.filters.lowPass;
|
|
3039
3055
|
await this.applyPlayerFilters();
|
|
3040
3056
|
return this.filters.lowPass;
|
|
@@ -3049,17 +3065,10 @@ var FilterManager = class {
|
|
|
3049
3065
|
toggleLowPass: async (boostFactor = 1, cutoffFrequency = 80) => {
|
|
3050
3066
|
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");
|
|
3051
3067
|
if (this.player.node.info && !this.player.node.info?.filters?.includes("low-pass")) throw new Error("Node#Info#filters does not include the 'low-pass' Filter (Node has it not enable)");
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
if (
|
|
3055
|
-
|
|
3056
|
-
delete this.data.pluginFilters["low-pass"];
|
|
3057
|
-
} else {
|
|
3058
|
-
this.data.pluginFilters["low-pass"] = {
|
|
3059
|
-
boostFactor,
|
|
3060
|
-
cutoffFrequency
|
|
3061
|
-
};
|
|
3062
|
-
}
|
|
3068
|
+
this.data = this.data ?? {};
|
|
3069
|
+
this.data.pluginFilters = this.data.pluginFilters ?? {};
|
|
3070
|
+
if (this.filters.lavalinkLavaDspxPlugin.lowPass) delete this.data.pluginFilters["low-pass"];
|
|
3071
|
+
else this.data.pluginFilters["low-pass"] = { boostFactor, cutoffFrequency };
|
|
3063
3072
|
this.filters.lavalinkLavaDspxPlugin.lowPass = !this.filters.lavalinkLavaDspxPlugin.lowPass;
|
|
3064
3073
|
await this.applyPlayerFilters();
|
|
3065
3074
|
return this.filters.lavalinkLavaDspxPlugin.lowPass;
|
|
@@ -3073,17 +3082,10 @@ var FilterManager = class {
|
|
|
3073
3082
|
toggleHighPass: async (boostFactor = 1, cutoffFrequency = 80) => {
|
|
3074
3083
|
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");
|
|
3075
3084
|
if (this.player.node.info && !this.player.node.info?.filters?.includes("high-pass")) throw new Error("Node#Info#filters does not include the 'high-pass' Filter (Node has it not enable)");
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
if (
|
|
3079
|
-
|
|
3080
|
-
delete this.data.pluginFilters["high-pass"];
|
|
3081
|
-
} else {
|
|
3082
|
-
this.data.pluginFilters["high-pass"] = {
|
|
3083
|
-
boostFactor,
|
|
3084
|
-
cutoffFrequency
|
|
3085
|
-
};
|
|
3086
|
-
}
|
|
3085
|
+
this.data = this.data ?? {};
|
|
3086
|
+
this.data.pluginFilters = this.data.pluginFilters ?? {};
|
|
3087
|
+
if (this.filters.lavalinkLavaDspxPlugin.highPass) delete this.data.pluginFilters["high-pass"];
|
|
3088
|
+
else this.data.pluginFilters["high-pass"] = { boostFactor, cutoffFrequency };
|
|
3087
3089
|
this.filters.lavalinkLavaDspxPlugin.highPass = !this.filters.lavalinkLavaDspxPlugin.highPass;
|
|
3088
3090
|
await this.applyPlayerFilters();
|
|
3089
3091
|
return this.filters.lavalinkLavaDspxPlugin.highPass;
|
|
@@ -3097,17 +3099,10 @@ var FilterManager = class {
|
|
|
3097
3099
|
toggleNormalization: async (maxAmplitude = 0.75, adaptive = true) => {
|
|
3098
3100
|
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");
|
|
3099
3101
|
if (this.player.node.info && !this.player.node.info?.filters?.includes("normalization")) throw new Error("Node#Info#filters does not include the 'normalization' Filter (Node has it not enable)");
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
if (
|
|
3103
|
-
|
|
3104
|
-
delete this.data.pluginFilters.normalization;
|
|
3105
|
-
} else {
|
|
3106
|
-
this.data.pluginFilters.normalization = {
|
|
3107
|
-
adaptive,
|
|
3108
|
-
maxAmplitude
|
|
3109
|
-
};
|
|
3110
|
-
}
|
|
3102
|
+
this.data = this.data ?? {};
|
|
3103
|
+
this.data.pluginFilters = this.data.pluginFilters ?? {};
|
|
3104
|
+
if (this.filters.lavalinkLavaDspxPlugin.normalization) delete this.data.pluginFilters.normalization;
|
|
3105
|
+
else this.data.pluginFilters.normalization = { adaptive, maxAmplitude };
|
|
3111
3106
|
this.filters.lavalinkLavaDspxPlugin.normalization = !this.filters.lavalinkLavaDspxPlugin.normalization;
|
|
3112
3107
|
await this.applyPlayerFilters();
|
|
3113
3108
|
return this.filters.lavalinkLavaDspxPlugin.normalization;
|
|
@@ -3121,17 +3116,10 @@ var FilterManager = class {
|
|
|
3121
3116
|
toggleEcho: async (decay = 0.5, echoLength = 0.5) => {
|
|
3122
3117
|
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");
|
|
3123
3118
|
if (this.player.node.info && !this.player.node.info?.filters?.includes("echo")) throw new Error("Node#Info#filters does not include the 'echo' Filter (Node has it not enable)");
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
if (
|
|
3127
|
-
|
|
3128
|
-
delete this.data.pluginFilters.echo;
|
|
3129
|
-
} else {
|
|
3130
|
-
this.data.pluginFilters.echo = {
|
|
3131
|
-
decay,
|
|
3132
|
-
echoLength
|
|
3133
|
-
};
|
|
3134
|
-
}
|
|
3119
|
+
this.data = this.data ?? {};
|
|
3120
|
+
this.data.pluginFilters = this.data.pluginFilters ?? {};
|
|
3121
|
+
if (this.filters.lavalinkLavaDspxPlugin.echo) delete this.data.pluginFilters.echo;
|
|
3122
|
+
else this.data.pluginFilters.echo = { decay, echoLength };
|
|
3135
3123
|
this.filters.lavalinkLavaDspxPlugin.echo = !this.filters.lavalinkLavaDspxPlugin.echo;
|
|
3136
3124
|
await this.applyPlayerFilters();
|
|
3137
3125
|
return this.filters.lavalinkLavaDspxPlugin.echo;
|
|
@@ -3147,12 +3135,15 @@ var FilterManager = class {
|
|
|
3147
3135
|
toggleEcho: async (delay = 4, decay = 0.8) => {
|
|
3148
3136
|
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");
|
|
3149
3137
|
if (this.player.node.info && !this.player.node.info?.filters?.includes("echo")) throw new Error("Node#Info#filters does not include the 'echo' Filter (Node has it not enable aka not installed!)");
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3138
|
+
this.data = this.data ?? {};
|
|
3139
|
+
const { echo, reverb } = DEFAULT_FILTER_DATAS.pluginFilters["lavalink-filter-plugin"];
|
|
3140
|
+
this.data.pluginFilters = {
|
|
3141
|
+
...this.data.pluginFilters,
|
|
3142
|
+
["lavalink-filter-plugin"]: {
|
|
3143
|
+
reverb: this.data.pluginFilters?.["lavalink-filter-plugin"]?.reverb ?? reverb,
|
|
3144
|
+
echo: this.filters.lavalinkFilterPlugin.echo ? echo : { delay, decay }
|
|
3145
|
+
}
|
|
3146
|
+
};
|
|
3156
3147
|
this.filters.lavalinkFilterPlugin.echo = !this.filters.lavalinkFilterPlugin.echo;
|
|
3157
3148
|
await this.applyPlayerFilters();
|
|
3158
3149
|
return this.filters.lavalinkFilterPlugin.echo;
|
|
@@ -3166,12 +3157,15 @@ var FilterManager = class {
|
|
|
3166
3157
|
toggleReverb: async (delays = [0.037, 0.042, 0.048, 0.053], gains = [0.84, 0.83, 0.82, 0.81]) => {
|
|
3167
3158
|
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
3159
|
if (this.player.node.info && !this.player.node.info?.filters?.includes("reverb")) throw new Error("Node#Info#filters does not include the 'reverb' Filter (Node has it not enable aka not installed!)");
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3160
|
+
this.data = this.data ?? {};
|
|
3161
|
+
const { echo, reverb } = DEFAULT_FILTER_DATAS.pluginFilters["lavalink-filter-plugin"];
|
|
3162
|
+
this.data.pluginFilters = {
|
|
3163
|
+
...this.data.pluginFilters,
|
|
3164
|
+
["lavalink-filter-plugin"]: {
|
|
3165
|
+
echo: this.data.pluginFilters?.["lavalink-filter-plugin"]?.echo ?? echo,
|
|
3166
|
+
reverb: this.filters.lavalinkFilterPlugin.reverb ? reverb : { delays, gains }
|
|
3167
|
+
}
|
|
3168
|
+
};
|
|
3175
3169
|
this.filters.lavalinkFilterPlugin.reverb = !this.filters.lavalinkFilterPlugin.reverb;
|
|
3176
3170
|
await this.applyPlayerFilters();
|
|
3177
3171
|
return this.filters.lavalinkFilterPlugin.reverb;
|
|
@@ -3186,9 +3180,8 @@ var FilterManager = class {
|
|
|
3186
3180
|
*/
|
|
3187
3181
|
async toggleNightcore(speed = 1.289999523162842, pitch = 1.289999523162842, rate = 0.9365999523162842) {
|
|
3188
3182
|
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)");
|
|
3189
|
-
this.data
|
|
3190
|
-
this.data.timescale
|
|
3191
|
-
this.data.timescale.rate = this.filters.nightcore ? 1 : rate;
|
|
3183
|
+
this.data = this.data ?? {};
|
|
3184
|
+
this.data.timescale = this.filters.nightcore ? DEFAULT_FILTER_DATAS.timescale : { speed, pitch, rate };
|
|
3192
3185
|
this.filters.nightcore = !this.filters.nightcore;
|
|
3193
3186
|
this.filters.vaporwave = false;
|
|
3194
3187
|
this.filters.custom = false;
|
|
@@ -3204,9 +3197,8 @@ var FilterManager = class {
|
|
|
3204
3197
|
*/
|
|
3205
3198
|
async toggleVaporwave(speed = 0.8500000238418579, pitch = 0.800000011920929, rate = 1) {
|
|
3206
3199
|
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)");
|
|
3207
|
-
this.data
|
|
3208
|
-
this.data.timescale
|
|
3209
|
-
this.data.timescale.rate = this.filters.vaporwave ? 1 : rate;
|
|
3200
|
+
this.data = this.data ?? {};
|
|
3201
|
+
this.data.timescale = this.filters.vaporwave ? DEFAULT_FILTER_DATAS.timescale : { speed, pitch, rate };
|
|
3210
3202
|
this.filters.vaporwave = !this.filters.vaporwave;
|
|
3211
3203
|
this.filters.nightcore = false;
|
|
3212
3204
|
this.filters.custom = false;
|
|
@@ -3223,10 +3215,8 @@ var FilterManager = class {
|
|
|
3223
3215
|
*/
|
|
3224
3216
|
async toggleKaraoke(level = 1, monoLevel = 1, filterBand = 220, filterWidth = 100) {
|
|
3225
3217
|
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)");
|
|
3226
|
-
this.data
|
|
3227
|
-
this.data.karaoke
|
|
3228
|
-
this.data.karaoke.filterBand = this.filters.karaoke ? 0 : filterBand;
|
|
3229
|
-
this.data.karaoke.filterWidth = this.filters.karaoke ? 0 : filterWidth;
|
|
3218
|
+
this.data = this.data ?? {};
|
|
3219
|
+
this.data.karaoke = this.filters.karaoke ? DEFAULT_FILTER_DATAS.karaoke : { level, monoLevel, filterBand, filterWidth };
|
|
3230
3220
|
this.filters.karaoke = !this.filters.karaoke;
|
|
3231
3221
|
await this.applyPlayerFilters();
|
|
3232
3222
|
return this.filters.karaoke;
|
package/package.json
CHANGED