lavalink-client 2.1.3 → 2.1.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/README.md +92 -2
- package/dist/cjs/structures/Filters.d.ts +360 -360
- package/dist/cjs/structures/Filters.js +899 -899
- package/dist/cjs/structures/LavalinkManager.d.ts +160 -9
- package/dist/cjs/structures/LavalinkManager.js +160 -7
- package/dist/cjs/structures/Player.d.ts +1 -1
- package/dist/esm/structures/Filters.d.ts +360 -360
- package/dist/esm/structures/Filters.js +895 -895
- package/dist/esm/structures/LavalinkManager.d.ts +160 -9
- package/dist/esm/structures/LavalinkManager.js +160 -7
- package/dist/esm/structures/Player.d.ts +1 -1
- package/dist/types/structures/Filters.d.ts +360 -360
- package/dist/types/structures/LavalinkManager.d.ts +160 -9
- package/dist/types/structures/Player.d.ts +1 -1
- package/package.json +5 -2
|
@@ -1,895 +1,895 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The FilterManager for each player
|
|
3
|
-
*/
|
|
4
|
-
export class FilterManager {
|
|
5
|
-
/** The Equalizer bands currently applied to the Lavalink Server */
|
|
6
|
-
equalizerBands = [];
|
|
7
|
-
/** Private Util for the instaFix Filters option */
|
|
8
|
-
filterUpdatedState = 0;
|
|
9
|
-
/** All "Active" / "disabled" Player Filters */
|
|
10
|
-
filters = {
|
|
11
|
-
volume: false,
|
|
12
|
-
vaporwave: false,
|
|
13
|
-
custom: false,
|
|
14
|
-
nightcore: false,
|
|
15
|
-
rotation: false,
|
|
16
|
-
karaoke: false,
|
|
17
|
-
tremolo: false,
|
|
18
|
-
vibrato: false,
|
|
19
|
-
lowPass: false,
|
|
20
|
-
lavalinkFilterPlugin: {
|
|
21
|
-
echo: false,
|
|
22
|
-
reverb: false,
|
|
23
|
-
},
|
|
24
|
-
lavalinkLavaDspxPlugin: {
|
|
25
|
-
lowPass: false,
|
|
26
|
-
highPass: false,
|
|
27
|
-
normalization: false,
|
|
28
|
-
echo: false,
|
|
29
|
-
},
|
|
30
|
-
audioOutput: "stereo",
|
|
31
|
-
};
|
|
32
|
-
/** The Filter Data sent to Lavalink, only if the filter is enabled (ofc.) */
|
|
33
|
-
data = {
|
|
34
|
-
lowPass: {
|
|
35
|
-
smoothing: 0
|
|
36
|
-
},
|
|
37
|
-
karaoke: {
|
|
38
|
-
level: 0,
|
|
39
|
-
monoLevel: 0,
|
|
40
|
-
filterBand: 0,
|
|
41
|
-
filterWidth: 0
|
|
42
|
-
},
|
|
43
|
-
timescale: {
|
|
44
|
-
speed: 1,
|
|
45
|
-
pitch: 1,
|
|
46
|
-
rate: 1 // 0 = x
|
|
47
|
-
},
|
|
48
|
-
rotation: {
|
|
49
|
-
rotationHz: 0
|
|
50
|
-
},
|
|
51
|
-
tremolo: {
|
|
52
|
-
frequency: 0,
|
|
53
|
-
depth: 0 // 0 < x = 1
|
|
54
|
-
},
|
|
55
|
-
vibrato: {
|
|
56
|
-
frequency: 0,
|
|
57
|
-
depth: 0 // 0 < x <= 1
|
|
58
|
-
},
|
|
59
|
-
pluginFilters: {
|
|
60
|
-
"lavalink-filter-plugin": {
|
|
61
|
-
echo: {
|
|
62
|
-
delay: 0,
|
|
63
|
-
decay: 0 // 0 < 1
|
|
64
|
-
},
|
|
65
|
-
reverb: {
|
|
66
|
-
delays: [],
|
|
67
|
-
gains: [] // [0.84, 0.83, 0.82, 0.81]
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
"high-pass": { // Cuts off frequencies lower than the specified {cutoffFrequency}.
|
|
71
|
-
// "cutoffFrequency": 1475, // Integer, higher than zero, in Hz.
|
|
72
|
-
// "boostFactor": 1.0 // Float, higher than 0.0. This alters volume output. A value of 1.0 means no volume change.
|
|
73
|
-
},
|
|
74
|
-
"low-pass": { // Cuts off frequencies higher than the specified {cutoffFrequency}.
|
|
75
|
-
// "cutoffFrequency": 284, // Integer, higher than zero, in Hz.
|
|
76
|
-
// "boostFactor": 1.24389 // Float, higher than 0.0. This alters volume output. A value of 1.0 means no volume change.
|
|
77
|
-
},
|
|
78
|
-
"normalization": { // Attenuates peaking where peaks are defined as having a higher value than {maxAmplitude}.
|
|
79
|
-
// "maxAmplitude": 0.6327, // Float, within the range of 0.0 - 1.0. A value of 0.0 mutes the output.
|
|
80
|
-
// "adaptive": true // false
|
|
81
|
-
},
|
|
82
|
-
"echo": { // Self-explanatory; provides an echo effect.
|
|
83
|
-
// "echoLength": 0.5649, // Float, higher than 0.0, in seconds (1.0 = 1 second).
|
|
84
|
-
// "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
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
channelMix: audioOutputsData.stereo,
|
|
88
|
-
/*distortion: {
|
|
89
|
-
sinOffset: 0,
|
|
90
|
-
sinScale: 1,
|
|
91
|
-
cosOffset: 0,
|
|
92
|
-
cosScale: 1,
|
|
93
|
-
tanOffset: 0,
|
|
94
|
-
tanScale: 1,
|
|
95
|
-
offset: 0,
|
|
96
|
-
scale: 1
|
|
97
|
-
}*/
|
|
98
|
-
};
|
|
99
|
-
/** The Player assigned to this Filter Manager */
|
|
100
|
-
player;
|
|
101
|
-
/** The Constructor for the FilterManager */
|
|
102
|
-
constructor(player) {
|
|
103
|
-
/** Assign the player to the filter manager */
|
|
104
|
-
this.player = player;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Apply Player filters for lavalink filter sending data, if the filter is enabled / not
|
|
108
|
-
*/
|
|
109
|
-
async applyPlayerFilters() {
|
|
110
|
-
const sendData = { ...this.data };
|
|
111
|
-
this.checkFiltersState();
|
|
112
|
-
if (!this.filters.volume)
|
|
113
|
-
delete sendData.volume;
|
|
114
|
-
if (!this.filters.tremolo)
|
|
115
|
-
delete sendData.tremolo;
|
|
116
|
-
if (!this.filters.vibrato)
|
|
117
|
-
delete sendData.vibrato;
|
|
118
|
-
if (!this.filters.lavalinkFilterPlugin.echo)
|
|
119
|
-
delete sendData.pluginFilters?.["lavalink-filter-plugin"]?.echo;
|
|
120
|
-
if (!this.filters.lavalinkFilterPlugin.reverb)
|
|
121
|
-
delete sendData.pluginFilters?.["lavalink-filter-plugin"]?.reverb;
|
|
122
|
-
if (!this.filters.lavalinkLavaDspxPlugin.echo)
|
|
123
|
-
delete sendData.pluginFilters?.echo;
|
|
124
|
-
if (!this.filters.lavalinkLavaDspxPlugin.normalization)
|
|
125
|
-
delete sendData.pluginFilters?.normalization;
|
|
126
|
-
if (!this.filters.lavalinkLavaDspxPlugin.highPass)
|
|
127
|
-
delete sendData.pluginFilters?.["high-pass"];
|
|
128
|
-
if (!this.filters.lavalinkLavaDspxPlugin.lowPass)
|
|
129
|
-
delete sendData.pluginFilters?.["low-pass"];
|
|
130
|
-
if (sendData.pluginFilters?.["lavalink-filter-plugin"] && Object.values(sendData.pluginFilters?.["lavalink-filter-plugin"]).length === 0)
|
|
131
|
-
delete sendData.pluginFilters["lavalink-filter-plugin"];
|
|
132
|
-
if (sendData.pluginFilters && Object.values(sendData.pluginFilters).length === 0)
|
|
133
|
-
delete sendData.pluginFilters;
|
|
134
|
-
if (!this.filters.lowPass)
|
|
135
|
-
delete sendData.lowPass;
|
|
136
|
-
if (!this.filters.karaoke)
|
|
137
|
-
delete sendData.karaoke;
|
|
138
|
-
if (!this.filters.rotation)
|
|
139
|
-
delete sendData.rotation;
|
|
140
|
-
if (this.filters.audioOutput === "stereo")
|
|
141
|
-
delete sendData.channelMix;
|
|
142
|
-
if (Object.values(this.data.timescale).every(v => v === 1))
|
|
143
|
-
delete sendData.timescale;
|
|
144
|
-
if (!this.player.node.sessionId)
|
|
145
|
-
throw new Error("The Lavalink-Node is either not ready or not up to date");
|
|
146
|
-
sendData.equalizer = [...this.equalizerBands];
|
|
147
|
-
if (sendData.equalizer.length === 0)
|
|
148
|
-
delete sendData.equalizer;
|
|
149
|
-
for (const key of [...Object.keys(sendData)]) {
|
|
150
|
-
// delete disabled filters
|
|
151
|
-
if (key === "pluginFilters") {
|
|
152
|
-
// for(const key of [...Object.keys(sendData.pluginFilters)]) {
|
|
153
|
-
// // if (this.player.node.info && !this.player.node.info?.plugins?.find?.(v => v.name === key)) delete sendData[key];
|
|
154
|
-
// }
|
|
155
|
-
}
|
|
156
|
-
else if (this.player.node.info && !this.player.node.info?.filters?.includes?.(key))
|
|
157
|
-
delete sendData[key];
|
|
158
|
-
}
|
|
159
|
-
const now = performance.now();
|
|
160
|
-
await this.player.node.updatePlayer({
|
|
161
|
-
guildId: this.player.guildId,
|
|
162
|
-
playerOptions: {
|
|
163
|
-
filters: sendData,
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
this.player.ping.lavalink = Math.round((performance.now() - now) / 10) / 100;
|
|
167
|
-
if (this.player.options.instaUpdateFiltersFix === true)
|
|
168
|
-
this.filterUpdatedState = 1;
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Checks if the filters are correctly stated (active / not-active)
|
|
173
|
-
* @param oldFilterTimescale
|
|
174
|
-
* @returns
|
|
175
|
-
*/
|
|
176
|
-
checkFiltersState(oldFilterTimescale) {
|
|
177
|
-
this.filters.rotation = this.data.rotation.rotationHz !== 0;
|
|
178
|
-
this.filters.vibrato = this.data.vibrato.frequency !== 0 || this.data.vibrato.depth !== 0;
|
|
179
|
-
this.filters.tremolo = this.data.tremolo.frequency !== 0 || this.data.tremolo.depth !== 0;
|
|
180
|
-
const lavalinkFilterData = (this.data.pluginFilters?.["lavalink-filter-plugin"] || { echo: { decay: this.data.pluginFilters?.echo?.decay && !this.data.pluginFilters?.echo?.echoLength ? this.data.pluginFilters.echo.decay : 0, delay: this.data.pluginFilters?.echo?.delay || 0 }, reverb: { gains: [], delays: [], ...((this.data.pluginFilters.reverb) || {}) } });
|
|
181
|
-
this.filters.lavalinkFilterPlugin.echo = lavalinkFilterData.echo.decay !== 0 || lavalinkFilterData.echo.delay !== 0;
|
|
182
|
-
this.filters.lavalinkFilterPlugin.reverb = lavalinkFilterData.reverb?.delays?.length !== 0 || lavalinkFilterData.reverb?.gains?.length !== 0;
|
|
183
|
-
this.filters.lavalinkLavaDspxPlugin.highPass = Object.values(this.data.pluginFilters["high-pass"] || {}).length > 0;
|
|
184
|
-
this.filters.lavalinkLavaDspxPlugin.lowPass = Object.values(this.data.pluginFilters["low-pass"] || {}).length > 0;
|
|
185
|
-
this.filters.lavalinkLavaDspxPlugin.normalization = Object.values(this.data.pluginFilters.normalization || {}).length > 0;
|
|
186
|
-
this.filters.lavalinkLavaDspxPlugin.echo = Object.values(this.data.pluginFilters.echo || {}).length > 0 && typeof this.data.pluginFilters?.echo?.delay === "undefined";
|
|
187
|
-
this.filters.lowPass = this.data.lowPass.smoothing !== 0;
|
|
188
|
-
this.filters.karaoke = Object.values(this.data.karaoke).some(v => v !== 0);
|
|
189
|
-
if ((this.filters.nightcore || this.filters.vaporwave) && oldFilterTimescale) {
|
|
190
|
-
if (oldFilterTimescale.pitch !== this.data.timescale.pitch || oldFilterTimescale.rate !== this.data.timescale.rate || oldFilterTimescale.speed !== this.data.timescale.speed) {
|
|
191
|
-
this.filters.custom = Object.values(this.data.timescale).some(v => v !== 1);
|
|
192
|
-
this.filters.nightcore = false;
|
|
193
|
-
this.filters.vaporwave = false;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
return true;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Reset all Filters
|
|
200
|
-
*/
|
|
201
|
-
async resetFilters() {
|
|
202
|
-
this.filters.lavalinkLavaDspxPlugin.echo = false;
|
|
203
|
-
this.filters.lavalinkLavaDspxPlugin.normalization = false;
|
|
204
|
-
this.filters.lavalinkLavaDspxPlugin.highPass = false;
|
|
205
|
-
this.filters.lavalinkLavaDspxPlugin.lowPass = false;
|
|
206
|
-
this.filters.lavalinkFilterPlugin.echo = false;
|
|
207
|
-
this.filters.lavalinkFilterPlugin.reverb = false;
|
|
208
|
-
this.filters.nightcore = false;
|
|
209
|
-
this.filters.lowPass = false;
|
|
210
|
-
this.filters.rotation = false;
|
|
211
|
-
this.filters.tremolo = false;
|
|
212
|
-
this.filters.vibrato = false;
|
|
213
|
-
this.filters.karaoke = false;
|
|
214
|
-
this.filters.karaoke = false;
|
|
215
|
-
this.filters.volume = false;
|
|
216
|
-
this.filters.audioOutput = "stereo";
|
|
217
|
-
// reset all filter datas
|
|
218
|
-
for (const [key, value] of Object.entries({
|
|
219
|
-
volume: 1,
|
|
220
|
-
lowPass: {
|
|
221
|
-
smoothing: 0
|
|
222
|
-
},
|
|
223
|
-
karaoke: {
|
|
224
|
-
level: 0,
|
|
225
|
-
monoLevel: 0,
|
|
226
|
-
filterBand: 0,
|
|
227
|
-
filterWidth: 0
|
|
228
|
-
},
|
|
229
|
-
timescale: {
|
|
230
|
-
speed: 1,
|
|
231
|
-
pitch: 1,
|
|
232
|
-
rate: 1 // 0 = x
|
|
233
|
-
},
|
|
234
|
-
pluginFilters: {
|
|
235
|
-
"lavalink-filter-plugin": {
|
|
236
|
-
echo: {
|
|
237
|
-
// delay: 0, // in seconds
|
|
238
|
-
// decay: 0 // 0 < 1
|
|
239
|
-
},
|
|
240
|
-
reverb: {
|
|
241
|
-
// delays: [], // [0.037, 0.042, 0.048, 0.053]
|
|
242
|
-
// gains: [] // [0.84, 0.83, 0.82, 0.81]
|
|
243
|
-
}
|
|
244
|
-
},
|
|
245
|
-
"high-pass": { // Cuts off frequencies lower than the specified {cutoffFrequency}.
|
|
246
|
-
// "cutoffFrequency": 1475, // Integer, higher than zero, in Hz.
|
|
247
|
-
// "boostFactor": 1.0 // Float, higher than 0.0. This alters volume output. A value of 1.0 means no volume change.
|
|
248
|
-
},
|
|
249
|
-
"low-pass": { // Cuts off frequencies higher than the specified {cutoffFrequency}.
|
|
250
|
-
// "cutoffFrequency": 284, // Integer, higher than zero, in Hz.
|
|
251
|
-
// "boostFactor": 1.24389 // Float, higher than 0.0. This alters volume output. A value of 1.0 means no volume change.
|
|
252
|
-
},
|
|
253
|
-
"normalization": { // Attenuates peaking where peaks are defined as having a higher value than {maxAmplitude}.
|
|
254
|
-
// "maxAmplitude": 0.6327, // Float, within the range of 0.0 - 1.0. A value of 0.0 mutes the output.
|
|
255
|
-
// "adaptive": true // false
|
|
256
|
-
},
|
|
257
|
-
"echo": { // Self-explanatory; provides an echo effect.
|
|
258
|
-
// "echoLength": 0.5649, // Float, higher than 0.0, in seconds (1.0 = 1 second).
|
|
259
|
-
// "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
|
|
260
|
-
},
|
|
261
|
-
},
|
|
262
|
-
rotation: {
|
|
263
|
-
rotationHz: 0
|
|
264
|
-
},
|
|
265
|
-
tremolo: {
|
|
266
|
-
frequency:
|
|
267
|
-
depth: 0
|
|
268
|
-
},
|
|
269
|
-
vibrato: {
|
|
270
|
-
frequency:
|
|
271
|
-
depth: 0
|
|
272
|
-
},
|
|
273
|
-
channelMix: audioOutputsData.stereo,
|
|
274
|
-
})) {
|
|
275
|
-
this.data[key] = value;
|
|
276
|
-
}
|
|
277
|
-
await this.applyPlayerFilters();
|
|
278
|
-
return this.filters;
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* Set the Filter Volume
|
|
282
|
-
* @param volume
|
|
283
|
-
* @returns
|
|
284
|
-
*/
|
|
285
|
-
async setVolume(volume) {
|
|
286
|
-
if (volume < 0 || volume > 5)
|
|
287
|
-
throw new SyntaxError("Volume-Filter must be between 0 and 5");
|
|
288
|
-
this.data.volume = volume;
|
|
289
|
-
await this.applyPlayerFilters();
|
|
290
|
-
return this.filters.volume;
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* Set the AudioOutput Filter
|
|
294
|
-
* @param type
|
|
295
|
-
* @returns
|
|
296
|
-
*/
|
|
297
|
-
async setAudioOutput(type) {
|
|
298
|
-
if (this.player.node.info && !this.player.node.info?.filters?.includes("channelMix"))
|
|
299
|
-
throw new Error("Node#Info#filters does not include the 'channelMix' Filter (Node has it not enable)");
|
|
300
|
-
if (!type || !audioOutputsData[type])
|
|
301
|
-
throw "Invalid audio type added, must be 'mono' / 'stereo' / 'left' / 'right'";
|
|
302
|
-
this.data.channelMix = audioOutputsData[type];
|
|
303
|
-
this.filters.audioOutput = type;
|
|
304
|
-
await this.applyPlayerFilters();
|
|
305
|
-
return this.filters.audioOutput;
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* Set custom filter.timescale#speed . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
|
|
309
|
-
* @param speed
|
|
310
|
-
* @returns
|
|
311
|
-
*/
|
|
312
|
-
async setSpeed(speed = 1) {
|
|
313
|
-
if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale"))
|
|
314
|
-
throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
|
|
315
|
-
// reset nightcore / vaporwave filter if enabled
|
|
316
|
-
if (this.filters.nightcore || this.filters.vaporwave) {
|
|
317
|
-
this.data.timescale.pitch = 1;
|
|
318
|
-
this.data.timescale.speed = 1;
|
|
319
|
-
this.data.timescale.rate = 1;
|
|
320
|
-
this.filters.nightcore = false;
|
|
321
|
-
this.filters.vaporwave = false;
|
|
322
|
-
}
|
|
323
|
-
this.data.timescale.speed = speed;
|
|
324
|
-
// check if custom filter is active / not
|
|
325
|
-
this.isCustomFilterActive();
|
|
326
|
-
await this.applyPlayerFilters();
|
|
327
|
-
return this.filters.custom;
|
|
328
|
-
}
|
|
329
|
-
/**
|
|
330
|
-
* Set custom filter.timescale#pitch . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
|
|
331
|
-
* @param speed
|
|
332
|
-
* @returns
|
|
333
|
-
*/
|
|
334
|
-
async setPitch(pitch = 1) {
|
|
335
|
-
if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale"))
|
|
336
|
-
throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
|
|
337
|
-
// reset nightcore / vaporwave filter if enabled
|
|
338
|
-
if (this.filters.nightcore || this.filters.vaporwave) {
|
|
339
|
-
this.data.timescale.pitch = 1;
|
|
340
|
-
this.data.timescale.speed = 1;
|
|
341
|
-
this.data.timescale.rate = 1;
|
|
342
|
-
this.filters.nightcore = false;
|
|
343
|
-
this.filters.vaporwave = false;
|
|
344
|
-
}
|
|
345
|
-
this.data.timescale.pitch = pitch;
|
|
346
|
-
// check if custom filter is active / not
|
|
347
|
-
this.isCustomFilterActive();
|
|
348
|
-
await this.applyPlayerFilters();
|
|
349
|
-
return this.filters.custom;
|
|
350
|
-
}
|
|
351
|
-
/**
|
|
352
|
-
* Set custom filter.timescale#rate . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
|
|
353
|
-
* @param speed
|
|
354
|
-
* @returns
|
|
355
|
-
*/
|
|
356
|
-
async setRate(rate = 1) {
|
|
357
|
-
if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale"))
|
|
358
|
-
throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
|
|
359
|
-
// reset nightcore / vaporwave filter if enabled
|
|
360
|
-
if (this.filters.nightcore || this.filters.vaporwave) {
|
|
361
|
-
this.data.timescale.pitch = 1;
|
|
362
|
-
this.data.timescale.speed = 1;
|
|
363
|
-
this.data.timescale.rate = 1;
|
|
364
|
-
this.filters.nightcore = false;
|
|
365
|
-
this.filters.vaporwave = false;
|
|
366
|
-
}
|
|
367
|
-
this.data.timescale.rate = rate;
|
|
368
|
-
// check if custom filter is active / not
|
|
369
|
-
this.isCustomFilterActive();
|
|
370
|
-
await this.applyPlayerFilters();
|
|
371
|
-
return this.filters.custom;
|
|
372
|
-
}
|
|
373
|
-
/**
|
|
374
|
-
*
|
|
375
|
-
* @param rotationHz
|
|
376
|
-
* @returns
|
|
377
|
-
*/
|
|
378
|
-
async toggleRotation(rotationHz = 0.2) {
|
|
379
|
-
if (this.player.node.info && !this.player.node.info?.filters?.includes("rotation"))
|
|
380
|
-
throw new Error("Node#Info#filters does not include the 'rotation' Filter (Node has it not enable)");
|
|
381
|
-
this.data.rotation.rotationHz = this.filters.rotation ? 0 : rotationHz;
|
|
382
|
-
this.filters.rotation = !this.filters.rotation;
|
|
383
|
-
return await this.applyPlayerFilters(), this.filters.rotation;
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
*
|
|
387
|
-
* @param frequency
|
|
388
|
-
* @param depth
|
|
389
|
-
* @returns
|
|
390
|
-
*/
|
|
391
|
-
async toggleVibrato(frequency = 10, depth = 1) {
|
|
392
|
-
if (this.player.node.info && !this.player.node.info?.filters?.includes("vibrato"))
|
|
393
|
-
throw new Error("Node#Info#filters does not include the 'vibrato' Filter (Node has it not enable)");
|
|
394
|
-
this.data.vibrato.frequency = this.filters.vibrato ? 0 : frequency;
|
|
395
|
-
this.data.vibrato.depth = this.filters.vibrato ? 0 : depth;
|
|
396
|
-
this.filters.vibrato = !this.filters.vibrato;
|
|
397
|
-
await this.applyPlayerFilters();
|
|
398
|
-
return this.filters.vibrato;
|
|
399
|
-
}
|
|
400
|
-
/**
|
|
401
|
-
*
|
|
402
|
-
* @param frequency
|
|
403
|
-
* @param depth
|
|
404
|
-
* @returns
|
|
405
|
-
*/
|
|
406
|
-
async toggleTremolo(frequency = 4, depth = 0.8) {
|
|
407
|
-
if (this.player.node.info && !this.player.node.info?.filters?.includes("tremolo"))
|
|
408
|
-
throw new Error("Node#Info#filters does not include the 'tremolo' Filter (Node has it not enable)");
|
|
409
|
-
this.data.tremolo.frequency = this.filters.tremolo ? 0 : frequency;
|
|
410
|
-
this.data.tremolo.depth = this.filters.tremolo ? 0 : depth;
|
|
411
|
-
this.filters.tremolo = !this.filters.tremolo;
|
|
412
|
-
await this.applyPlayerFilters();
|
|
413
|
-
return this.filters.tremolo;
|
|
414
|
-
}
|
|
415
|
-
/**
|
|
416
|
-
*
|
|
417
|
-
* @param smoothing
|
|
418
|
-
* @returns
|
|
419
|
-
*/
|
|
420
|
-
async toggleLowPass(smoothing = 20) {
|
|
421
|
-
if (this.player.node.info && !this.player.node.info?.filters?.includes("lowPass"))
|
|
422
|
-
throw new Error("Node#Info#filters does not include the 'lowPass' Filter (Node has it not enable)");
|
|
423
|
-
this.data.lowPass.smoothing = this.filters.lowPass ? 0 : smoothing;
|
|
424
|
-
this.filters.lowPass = !this.filters.lowPass;
|
|
425
|
-
await this.applyPlayerFilters();
|
|
426
|
-
return this.filters.lowPass;
|
|
427
|
-
}
|
|
428
|
-
lavalinkLavaDspxPlugin = {
|
|
429
|
-
toggleLowPass: async (boostFactor = 1.0, cutoffFrequency = 80) => {
|
|
430
|
-
if (this.player.node.info && !this.player.node.info?.plugins?.find(v => v.name === "lavadspx-plugin"))
|
|
431
|
-
throw new Error("Node#Info#plugins does not include the lavadspx plugin");
|
|
432
|
-
if (this.player.node.info && !this.player.node.info?.filters?.includes("low-pass"))
|
|
433
|
-
throw new Error("Node#Info#filters does not include the 'low-pass' Filter (Node has it not enable)");
|
|
434
|
-
if (!this.data)
|
|
435
|
-
this.data = {};
|
|
436
|
-
if (!this.data.pluginFilters)
|
|
437
|
-
this.data.pluginFilters = {};
|
|
438
|
-
if (!this.data.pluginFilters["low-pass"])
|
|
439
|
-
this.data.pluginFilters["low-pass"] = {};
|
|
440
|
-
if (this.filters.lavalinkLavaDspxPlugin.lowPass) {
|
|
441
|
-
delete this.data.pluginFilters["low-pass"];
|
|
442
|
-
}
|
|
443
|
-
else {
|
|
444
|
-
this.data.pluginFilters["low-pass"] = {
|
|
445
|
-
boostFactor: boostFactor,
|
|
446
|
-
cutoffFrequency: cutoffFrequency
|
|
447
|
-
};
|
|
448
|
-
}
|
|
449
|
-
this.filters.lavalinkLavaDspxPlugin.lowPass = !this.filters.lavalinkLavaDspxPlugin.lowPass;
|
|
450
|
-
await this.applyPlayerFilters();
|
|
451
|
-
return this.filters.lavalinkLavaDspxPlugin.lowPass;
|
|
452
|
-
},
|
|
453
|
-
toggleHighPass: async (boostFactor = 1.0, cutoffFrequency = 80) => {
|
|
454
|
-
if (this.player.node.info && !this.player.node.info?.plugins?.find(v => v.name === "lavadspx-plugin"))
|
|
455
|
-
throw new Error("Node#Info#plugins does not include the lavadspx plugin");
|
|
456
|
-
if (this.player.node.info && !this.player.node.info?.filters?.includes("high-pass"))
|
|
457
|
-
throw new Error("Node#Info#filters does not include the 'high-pass' Filter (Node has it not enable)");
|
|
458
|
-
if (!this.data)
|
|
459
|
-
this.data = {};
|
|
460
|
-
if (!this.data.pluginFilters)
|
|
461
|
-
this.data.pluginFilters = {};
|
|
462
|
-
if (!this.data.pluginFilters["high-pass"])
|
|
463
|
-
this.data.pluginFilters["high-pass"] = {};
|
|
464
|
-
if (this.filters.lavalinkLavaDspxPlugin.highPass) {
|
|
465
|
-
delete this.data.pluginFilters["high-pass"];
|
|
466
|
-
}
|
|
467
|
-
else {
|
|
468
|
-
this.data.pluginFilters["high-pass"] = {
|
|
469
|
-
boostFactor: boostFactor,
|
|
470
|
-
cutoffFrequency: cutoffFrequency
|
|
471
|
-
};
|
|
472
|
-
}
|
|
473
|
-
this.filters.lavalinkLavaDspxPlugin.highPass = !this.filters.lavalinkLavaDspxPlugin.highPass;
|
|
474
|
-
await this.applyPlayerFilters();
|
|
475
|
-
return this.filters.lavalinkLavaDspxPlugin.highPass;
|
|
476
|
-
},
|
|
477
|
-
toggleNormalization: async (maxAmplitude = 0.75, adaptive = true) => {
|
|
478
|
-
if (this.player.node.info && !this.player.node.info?.plugins?.find(v => v.name === "lavadspx-plugin"))
|
|
479
|
-
throw new Error("Node#Info#plugins does not include the lavadspx plugin");
|
|
480
|
-
if (this.player.node.info && !this.player.node.info?.filters?.includes("normalization"))
|
|
481
|
-
throw new Error("Node#Info#filters does not include the 'normalization' Filter (Node has it not enable)");
|
|
482
|
-
if (!this.data)
|
|
483
|
-
this.data = {};
|
|
484
|
-
if (!this.data.pluginFilters)
|
|
485
|
-
this.data.pluginFilters = {};
|
|
486
|
-
if (!this.data.pluginFilters.normalization)
|
|
487
|
-
this.data.pluginFilters.normalization = {};
|
|
488
|
-
if (this.filters.lavalinkLavaDspxPlugin.normalization) {
|
|
489
|
-
delete this.data.pluginFilters.normalization;
|
|
490
|
-
}
|
|
491
|
-
else {
|
|
492
|
-
this.data.pluginFilters.normalization = {
|
|
493
|
-
adaptive: adaptive,
|
|
494
|
-
maxAmplitude: maxAmplitude
|
|
495
|
-
};
|
|
496
|
-
}
|
|
497
|
-
this.filters.lavalinkLavaDspxPlugin.normalization = !this.filters.lavalinkLavaDspxPlugin.normalization;
|
|
498
|
-
await this.applyPlayerFilters();
|
|
499
|
-
return this.filters.lavalinkLavaDspxPlugin.normalization;
|
|
500
|
-
},
|
|
501
|
-
toggleEcho: async (decay = 0.5, echoLength = 0.5) => {
|
|
502
|
-
if (this.player.node.info && !this.player.node.info?.plugins?.find(v => v.name === "lavadspx-plugin"))
|
|
503
|
-
throw new Error("Node#Info#plugins does not include the lavadspx plugin");
|
|
504
|
-
if (this.player.node.info && !this.player.node.info?.filters?.includes("echo"))
|
|
505
|
-
throw new Error("Node#Info#filters does not include the 'echo' Filter (Node has it not enable)");
|
|
506
|
-
if (!this.data)
|
|
507
|
-
this.data = {};
|
|
508
|
-
if (!this.data.pluginFilters)
|
|
509
|
-
this.data.pluginFilters = {};
|
|
510
|
-
if (!this.data.pluginFilters.echo)
|
|
511
|
-
this.data.pluginFilters.echo = {};
|
|
512
|
-
if (this.filters.lavalinkLavaDspxPlugin.echo) {
|
|
513
|
-
delete this.data.pluginFilters.echo;
|
|
514
|
-
}
|
|
515
|
-
else {
|
|
516
|
-
this.data.pluginFilters.echo = {
|
|
517
|
-
decay: decay,
|
|
518
|
-
echoLength: echoLength
|
|
519
|
-
};
|
|
520
|
-
}
|
|
521
|
-
this.filters.lavalinkLavaDspxPlugin.echo = !this.filters.lavalinkLavaDspxPlugin.echo;
|
|
522
|
-
await this.applyPlayerFilters();
|
|
523
|
-
return this.filters.lavalinkLavaDspxPlugin.echo;
|
|
524
|
-
}
|
|
525
|
-
};
|
|
526
|
-
lavalinkFilterPlugin = {
|
|
527
|
-
/**
|
|
528
|
-
*
|
|
529
|
-
* @param delay
|
|
530
|
-
* @param decay
|
|
531
|
-
* @returns
|
|
532
|
-
*/
|
|
533
|
-
toggleEcho: async (delay = 4, decay = 0.8) => {
|
|
534
|
-
if (this.player.node.info && !this.player.node.info?.plugins?.find(v => v.name === "lavalink-filter-plugin"))
|
|
535
|
-
throw new Error("Node#Info#plugins does not include the lavalink-filter-plugin plugin");
|
|
536
|
-
if (this.player.node.info && !this.player.node.info?.filters?.includes("echo"))
|
|
537
|
-
throw new Error("Node#Info#filters does not include the 'echo' Filter (Node has it not enable aka not installed!)");
|
|
538
|
-
if (!this.data)
|
|
539
|
-
this.data = {};
|
|
540
|
-
if (!this.data.pluginFilters)
|
|
541
|
-
this.data.pluginFilters = {};
|
|
542
|
-
if (!this.data.pluginFilters["lavalink-filter-plugin"])
|
|
543
|
-
this.data.pluginFilters["lavalink-filter-plugin"] = { echo: { decay: 0, delay: 0 }, reverb: { delays: [], gains: [] } };
|
|
544
|
-
if (!this.data.pluginFilters["lavalink-filter-plugin"].echo)
|
|
545
|
-
this.data.pluginFilters["lavalink-filter-plugin"].echo = { decay: 0, delay: 0 };
|
|
546
|
-
this.data.pluginFilters["lavalink-filter-plugin"].echo.delay = this.filters.lavalinkFilterPlugin.echo ? 0 : delay;
|
|
547
|
-
this.data.pluginFilters["lavalink-filter-plugin"].echo.decay = this.filters.lavalinkFilterPlugin.echo ? 0 : decay;
|
|
548
|
-
this.filters.lavalinkFilterPlugin.echo = !this.filters.lavalinkFilterPlugin.echo;
|
|
549
|
-
await this.applyPlayerFilters();
|
|
550
|
-
return this.filters.lavalinkFilterPlugin.echo;
|
|
551
|
-
},
|
|
552
|
-
/**
|
|
553
|
-
*
|
|
554
|
-
* @param delays
|
|
555
|
-
* @param gains
|
|
556
|
-
* @returns
|
|
557
|
-
*/
|
|
558
|
-
toggleReverb: async (delays = [0.037, 0.042, 0.048, 0.053], gains = [0.84, 0.83, 0.82, 0.81]) => {
|
|
559
|
-
if (this.player.node.info && !this.player.node.info?.plugins?.find(v => v.name === "lavalink-filter-plugin"))
|
|
560
|
-
throw new Error("Node#Info#plugins does not include the lavalink-filter-plugin plugin");
|
|
561
|
-
if (this.player.node.info && !this.player.node.info?.filters?.includes("reverb"))
|
|
562
|
-
throw new Error("Node#Info#filters does not include the 'reverb' Filter (Node has it not enable aka not installed!)");
|
|
563
|
-
if (!this.data)
|
|
564
|
-
this.data = {};
|
|
565
|
-
if (!this.data.pluginFilters)
|
|
566
|
-
this.data.pluginFilters = {};
|
|
567
|
-
if (!this.data.pluginFilters["lavalink-filter-plugin"])
|
|
568
|
-
this.data.pluginFilters["lavalink-filter-plugin"] = { echo: { decay: 0, delay: 0 }, reverb: { delays: [], gains: [] } };
|
|
569
|
-
if (!this.data.pluginFilters["lavalink-filter-plugin"].reverb)
|
|
570
|
-
this.data.pluginFilters["lavalink-filter-plugin"].reverb = { delays: [], gains: [] };
|
|
571
|
-
this.data.pluginFilters["lavalink-filter-plugin"].reverb.delays = this.filters.lavalinkFilterPlugin.reverb ? [] : delays;
|
|
572
|
-
this.data.pluginFilters["lavalink-filter-plugin"].reverb.gains = this.filters.lavalinkFilterPlugin.reverb ? [] : gains;
|
|
573
|
-
this.filters.lavalinkFilterPlugin.reverb = !this.filters.lavalinkFilterPlugin.reverb;
|
|
574
|
-
await this.applyPlayerFilters();
|
|
575
|
-
return this.filters.lavalinkFilterPlugin.reverb;
|
|
576
|
-
}
|
|
577
|
-
};
|
|
578
|
-
/**
|
|
579
|
-
* Enables /
|
|
580
|
-
* @param speed
|
|
581
|
-
* @param pitch
|
|
582
|
-
* @param rate
|
|
583
|
-
* @returns
|
|
584
|
-
*/
|
|
585
|
-
async toggleNightcore(speed = 1.289999523162842, pitch = 1.289999523162842, rate = 0.9365999523162842) {
|
|
586
|
-
if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale"))
|
|
587
|
-
throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
|
|
588
|
-
this.data.timescale.speed = this.filters.nightcore ? 1 : speed;
|
|
589
|
-
this.data.timescale.pitch = this.filters.nightcore ? 1 : pitch;
|
|
590
|
-
this.data.timescale.rate = this.filters.nightcore ? 1 : rate;
|
|
591
|
-
this.filters.nightcore = !this.filters.nightcore;
|
|
592
|
-
this.filters.vaporwave = false;
|
|
593
|
-
this.filters.custom = false;
|
|
594
|
-
await this.applyPlayerFilters();
|
|
595
|
-
return this.filters.nightcore;
|
|
596
|
-
}
|
|
597
|
-
/**
|
|
598
|
-
* Enables /
|
|
599
|
-
* @param speed
|
|
600
|
-
* @param pitch
|
|
601
|
-
* @param rate
|
|
602
|
-
* @returns
|
|
603
|
-
*/
|
|
604
|
-
async toggleVaporwave(speed = 0.8500000238418579, pitch = 0.800000011920929, rate = 1) {
|
|
605
|
-
if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale"))
|
|
606
|
-
throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
|
|
607
|
-
this.data.timescale.speed = this.filters.vaporwave ? 1 : speed;
|
|
608
|
-
this.data.timescale.pitch = this.filters.vaporwave ? 1 : pitch;
|
|
609
|
-
this.data.timescale.rate = this.filters.vaporwave ? 1 : rate;
|
|
610
|
-
this.filters.vaporwave = !this.filters.vaporwave;
|
|
611
|
-
this.filters.nightcore = false;
|
|
612
|
-
this.filters.custom = false;
|
|
613
|
-
await this.applyPlayerFilters();
|
|
614
|
-
return this.filters.vaporwave;
|
|
615
|
-
}
|
|
616
|
-
/**
|
|
617
|
-
* Enable / Disables a Karaoke like Filter Effect
|
|
618
|
-
* @param level
|
|
619
|
-
* @param monoLevel
|
|
620
|
-
* @param filterBand
|
|
621
|
-
* @param filterWidth
|
|
622
|
-
* @returns
|
|
623
|
-
*/
|
|
624
|
-
async toggleKaraoke(level = 1, monoLevel = 1, filterBand = 220, filterWidth = 100) {
|
|
625
|
-
if (this.player.node.info && !this.player.node.info?.filters?.includes("karaoke"))
|
|
626
|
-
throw new Error("Node#Info#filters does not include the 'karaoke' Filter (Node has it not enable)");
|
|
627
|
-
this.data.karaoke.level = this.filters.karaoke ? 0 : level;
|
|
628
|
-
this.data.karaoke.monoLevel = this.filters.karaoke ? 0 : monoLevel;
|
|
629
|
-
this.data.karaoke.filterBand = this.filters.karaoke ? 0 : filterBand;
|
|
630
|
-
this.data.karaoke.filterWidth = this.filters.karaoke ? 0 : filterWidth;
|
|
631
|
-
this.filters.karaoke = !this.filters.karaoke;
|
|
632
|
-
await this.applyPlayerFilters();
|
|
633
|
-
return this.filters.karaoke;
|
|
634
|
-
}
|
|
635
|
-
/** Function to find out if currently there is a custom timescamle etc. filter applied */
|
|
636
|
-
isCustomFilterActive() {
|
|
637
|
-
this.filters.custom = !this.filters.nightcore && !this.filters.vaporwave && Object.values(this.data.timescale).some(d => d !== 1);
|
|
638
|
-
return this.filters.custom;
|
|
639
|
-
}
|
|
640
|
-
/**
|
|
641
|
-
* Sets the players equalizer band on-top of the existing ones.
|
|
642
|
-
* @param bands
|
|
643
|
-
*/
|
|
644
|
-
async setEQ(bands) {
|
|
645
|
-
if (!Array.isArray(bands))
|
|
646
|
-
bands = [bands];
|
|
647
|
-
if (!bands.length || !bands.every((band) => JSON.stringify(Object.keys(band).sort()) === '["band","gain"]'))
|
|
648
|
-
throw new TypeError("Bands must be a non-empty object array containing 'band' and 'gain' properties.");
|
|
649
|
-
for (const { band, gain } of bands)
|
|
650
|
-
this.equalizerBands[band] = { band, gain };
|
|
651
|
-
if (!this.player.node.sessionId)
|
|
652
|
-
throw new Error("The Lavalink-Node is either not ready or not up to date");
|
|
653
|
-
const now = performance.now();
|
|
654
|
-
await this.player.node.updatePlayer({
|
|
655
|
-
guildId: this.player.guildId,
|
|
656
|
-
playerOptions: {
|
|
657
|
-
filters: { equalizer: this.equalizerBands }
|
|
658
|
-
}
|
|
659
|
-
});
|
|
660
|
-
this.player.ping.lavalink = Math.round((performance.now() - now) / 10) / 100;
|
|
661
|
-
if (this.player.options.instaUpdateFiltersFix === true)
|
|
662
|
-
this.filterUpdatedState = 1;
|
|
663
|
-
return this;
|
|
664
|
-
}
|
|
665
|
-
/** Clears the equalizer bands. */
|
|
666
|
-
async clearEQ() {
|
|
667
|
-
return this.setEQ(new Array(15).fill(0.0).map((gain, band) => ({ band, gain })));
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
/** The audio Outputs Data map declaration */
|
|
671
|
-
export const audioOutputsData = {
|
|
672
|
-
mono: {
|
|
673
|
-
leftToLeft: 0.5,
|
|
674
|
-
leftToRight: 0.5,
|
|
675
|
-
rightToLeft: 0.5,
|
|
676
|
-
rightToRight: 0.5,
|
|
677
|
-
},
|
|
678
|
-
stereo: {
|
|
679
|
-
leftToLeft: 1,
|
|
680
|
-
leftToRight: 0,
|
|
681
|
-
rightToLeft: 0,
|
|
682
|
-
rightToRight: 1,
|
|
683
|
-
},
|
|
684
|
-
left: {
|
|
685
|
-
leftToLeft: 1,
|
|
686
|
-
leftToRight: 0,
|
|
687
|
-
rightToLeft: 1,
|
|
688
|
-
rightToRight: 0,
|
|
689
|
-
},
|
|
690
|
-
right: {
|
|
691
|
-
leftToLeft: 0,
|
|
692
|
-
leftToRight: 1,
|
|
693
|
-
rightToLeft: 0,
|
|
694
|
-
rightToRight: 1,
|
|
695
|
-
},
|
|
696
|
-
};
|
|
697
|
-
export const EQList = {
|
|
698
|
-
/** A Bassboost Equalizer, so high it distorts the audio */
|
|
699
|
-
BassboostEarrape: [
|
|
700
|
-
{ band: 0, gain: 0.6 * 0.375 },
|
|
701
|
-
{ band: 1, gain: 0.67 * 0.375 },
|
|
702
|
-
{ band: 2, gain: 0.67 * 0.375 },
|
|
703
|
-
{ band: 3, gain: 0.4 * 0.375 },
|
|
704
|
-
{ band: 4, gain: -0.5 * 0.375 },
|
|
705
|
-
{ band: 5, gain: 0.15 * 0.375 },
|
|
706
|
-
{ band: 6, gain: -0.45 * 0.375 },
|
|
707
|
-
{ band: 7, gain: 0.23 * 0.375 },
|
|
708
|
-
{ band: 8, gain: 0.35 * 0.375 },
|
|
709
|
-
{ band: 9, gain: 0.45 * 0.375 },
|
|
710
|
-
{ band: 10, gain: 0.55 * 0.375 },
|
|
711
|
-
{ band: 11, gain: -0.6 * 0.375 },
|
|
712
|
-
{ band: 12, gain: 0.55 * 0.375 },
|
|
713
|
-
{ band: 13, gain: -0.5 * 0.375 },
|
|
714
|
-
{ band: 14, gain: -0.75 * 0.375 },
|
|
715
|
-
],
|
|
716
|
-
/** A High and decent Bassboost Equalizer */
|
|
717
|
-
BassboostHigh: [
|
|
718
|
-
{ band: 0, gain: 0.6 * 0.25 },
|
|
719
|
-
{ band: 1, gain: 0.67 * 0.25 },
|
|
720
|
-
{ band: 2, gain: 0.67 * 0.25 },
|
|
721
|
-
{ band: 3, gain: 0.4 * 0.25 },
|
|
722
|
-
{ band: 4, gain: -0.5 * 0.25 },
|
|
723
|
-
{ band: 5, gain: 0.15 * 0.25 },
|
|
724
|
-
{ band: 6, gain: -0.45 * 0.25 },
|
|
725
|
-
{ band: 7, gain: 0.23 * 0.25 },
|
|
726
|
-
{ band: 8, gain: 0.35 * 0.25 },
|
|
727
|
-
{ band: 9, gain: 0.45 * 0.25 },
|
|
728
|
-
{ band: 10, gain: 0.55 * 0.25 },
|
|
729
|
-
{ band: 11, gain: -0.6 * 0.25 },
|
|
730
|
-
{ band: 12, gain: 0.55 * 0.25 },
|
|
731
|
-
{ band: 13, gain: -0.5 * 0.25 },
|
|
732
|
-
{ band: 14, gain: -0.75 * 0.25 },
|
|
733
|
-
],
|
|
734
|
-
/** A decent Bassboost Equalizer */
|
|
735
|
-
BassboostMedium: [
|
|
736
|
-
{ band: 0, gain: 0.6 * 0.1875 },
|
|
737
|
-
{ band: 1, gain: 0.67 * 0.1875 },
|
|
738
|
-
{ band: 2, gain: 0.67 * 0.1875 },
|
|
739
|
-
{ band: 3, gain: 0.4 * 0.1875 },
|
|
740
|
-
{ band: 4, gain: -0.5 * 0.1875 },
|
|
741
|
-
{ band: 5, gain: 0.15 * 0.1875 },
|
|
742
|
-
{ band: 6, gain: -0.45 * 0.1875 },
|
|
743
|
-
{ band: 7, gain: 0.23 * 0.1875 },
|
|
744
|
-
{ band: 8, gain: 0.35 * 0.1875 },
|
|
745
|
-
{ band: 9, gain: 0.45 * 0.1875 },
|
|
746
|
-
{ band: 10, gain: 0.55 * 0.1875 },
|
|
747
|
-
{ band: 11, gain: -0.6 * 0.1875 },
|
|
748
|
-
{ band: 12, gain: 0.55 * 0.1875 },
|
|
749
|
-
{ band: 13, gain: -0.5 * 0.1875 },
|
|
750
|
-
{ band: 14, gain: -0.75 * 0.1875 },
|
|
751
|
-
],
|
|
752
|
-
/** A slight Bassboost Equalizer */
|
|
753
|
-
BassboostLow: [
|
|
754
|
-
{ band: 0, gain: 0.6 * 0.125 },
|
|
755
|
-
{ band: 1, gain: 0.67 * 0.125 },
|
|
756
|
-
{ band: 2, gain: 0.67 * 0.125 },
|
|
757
|
-
{ band: 3, gain: 0.4 * 0.125 },
|
|
758
|
-
{ band: 4, gain: -0.5 * 0.125 },
|
|
759
|
-
{ band: 5, gain: 0.15 * 0.125 },
|
|
760
|
-
{ band: 6, gain: -0.45 * 0.125 },
|
|
761
|
-
{ band: 7, gain: 0.23 * 0.125 },
|
|
762
|
-
{ band: 8, gain: 0.35 * 0.125 },
|
|
763
|
-
{ band: 9, gain: 0.45 * 0.125 },
|
|
764
|
-
{ band: 10, gain: 0.55 * 0.125 },
|
|
765
|
-
{ band: 11, gain: -0.6 * 0.125 },
|
|
766
|
-
{ band: 12, gain: 0.55 * 0.125 },
|
|
767
|
-
{ band: 13, gain: -0.5 * 0.125 },
|
|
768
|
-
{ band: 14, gain: -0.75 * 0.125 },
|
|
769
|
-
],
|
|
770
|
-
/** Makes the Music slightly "better" */
|
|
771
|
-
BetterMusic: [
|
|
772
|
-
{ band: 0, gain: 0.25 },
|
|
773
|
-
{ band: 1, gain: 0.025 },
|
|
774
|
-
{ band: 2, gain: 0.0125 },
|
|
775
|
-
{ band: 3, gain: 0 },
|
|
776
|
-
{ band: 4, gain: 0 },
|
|
777
|
-
{ band: 5, gain: -0.0125 },
|
|
778
|
-
{ band: 6, gain: -0.025 },
|
|
779
|
-
{ band: 7, gain: -0.0175 },
|
|
780
|
-
{ band: 8, gain: 0 },
|
|
781
|
-
{ band: 9, gain: 0 },
|
|
782
|
-
{ band: 10, gain: 0.0125 },
|
|
783
|
-
{ band: 11, gain: 0.025 },
|
|
784
|
-
{ band: 12, gain: 0.25 },
|
|
785
|
-
{ band: 13, gain: 0.125 },
|
|
786
|
-
{ band: 14, gain: 0.125 },
|
|
787
|
-
],
|
|
788
|
-
/** Makes the Music sound like rock music / sound rock music better */
|
|
789
|
-
Rock: [
|
|
790
|
-
{ band: 0, gain: 0.300 },
|
|
791
|
-
{ band: 1, gain: 0.250 },
|
|
792
|
-
{ band: 2, gain: 0.200 },
|
|
793
|
-
{ band: 3, gain: 0.100 },
|
|
794
|
-
{ band: 4, gain: 0.050 },
|
|
795
|
-
{ band: 5, gain: -0.050 },
|
|
796
|
-
{ band: 6, gain: -0.150 },
|
|
797
|
-
{ band: 7, gain: -0.200 },
|
|
798
|
-
{ band: 8, gain: -0.100 },
|
|
799
|
-
{ band: 9, gain: -0.050 },
|
|
800
|
-
{ band: 10, gain: 0.050 },
|
|
801
|
-
{ band: 11, gain: 0.100 },
|
|
802
|
-
{ band: 12, gain: 0.200 },
|
|
803
|
-
{ band: 13, gain: 0.250 },
|
|
804
|
-
{ band: 14, gain: 0.300 },
|
|
805
|
-
],
|
|
806
|
-
/** Makes the Music sound like Classic music / sound Classic music better */
|
|
807
|
-
Classic: [
|
|
808
|
-
{ band: 0, gain: 0.375 },
|
|
809
|
-
{ band: 1, gain: 0.350 },
|
|
810
|
-
{ band: 2, gain: 0.125 },
|
|
811
|
-
{ band: 3, gain: 0 },
|
|
812
|
-
{ band: 4, gain: 0 },
|
|
813
|
-
{ band: 5, gain: 0.125 },
|
|
814
|
-
{ band: 6, gain: 0.550 },
|
|
815
|
-
{ band: 7, gain: 0.050 },
|
|
816
|
-
{ band: 8, gain: 0.125 },
|
|
817
|
-
{ band: 9, gain: 0.250 },
|
|
818
|
-
{ band: 10, gain: 0.200 },
|
|
819
|
-
{ band: 11, gain: 0.250 },
|
|
820
|
-
{ band: 12, gain: 0.300 },
|
|
821
|
-
{ band: 13, gain: 0.250 },
|
|
822
|
-
{ band: 14, gain: 0.300 },
|
|
823
|
-
],
|
|
824
|
-
/** Makes the Music sound like Pop music / sound Pop music better */
|
|
825
|
-
Pop: [
|
|
826
|
-
{ band: 0, gain: 0.2635 },
|
|
827
|
-
{ band: 1, gain: 0.22141 },
|
|
828
|
-
{ band: 2, gain: -0.21141 },
|
|
829
|
-
{ band: 3, gain: -0.1851 },
|
|
830
|
-
{ band: 4, gain: -0.155 },
|
|
831
|
-
{ band: 5, gain: 0.21141 },
|
|
832
|
-
{ band: 6, gain: 0.22456 },
|
|
833
|
-
{ band: 7, gain: 0.237 },
|
|
834
|
-
{ band: 8, gain: 0.237 },
|
|
835
|
-
{ band: 9, gain: 0.237 },
|
|
836
|
-
{ band: 10, gain: -0.05 },
|
|
837
|
-
{ band: 11, gain: -0.116 },
|
|
838
|
-
{ band: 12, gain: 0.192 },
|
|
839
|
-
{ band: 13, gain: 0 },
|
|
840
|
-
],
|
|
841
|
-
/** Makes the Music sound like Electronic music / sound Electronic music better */
|
|
842
|
-
Electronic: [
|
|
843
|
-
{ band: 0, gain: 0.375 },
|
|
844
|
-
{ band: 1, gain: 0.350 },
|
|
845
|
-
{ band: 2, gain: 0.125 },
|
|
846
|
-
{ band: 3, gain: 0 },
|
|
847
|
-
{ band: 4, gain: 0 },
|
|
848
|
-
{ band: 5, gain: -0.125 },
|
|
849
|
-
{ band: 6, gain: -0.125 },
|
|
850
|
-
{ band: 7, gain: 0 },
|
|
851
|
-
{ band: 8, gain: 0.25 },
|
|
852
|
-
{ band: 9, gain: 0.125 },
|
|
853
|
-
{ band: 10, gain: 0.15 },
|
|
854
|
-
{ band: 11, gain: 0.2 },
|
|
855
|
-
{ band: 12, gain: 0.250 },
|
|
856
|
-
{ band: 13, gain: 0.350 },
|
|
857
|
-
{ band: 14, gain: 0.400 },
|
|
858
|
-
],
|
|
859
|
-
/** Boosts all Bands slightly for louder and fuller sound */
|
|
860
|
-
FullSound: [
|
|
861
|
-
{ band: 0, gain: 0.25 + 0.375 },
|
|
862
|
-
{ band: 1, gain: 0.25 + 0.025 },
|
|
863
|
-
{ band: 2, gain: 0.25 + 0.0125 },
|
|
864
|
-
{ band: 3, gain: 0.25 + 0 },
|
|
865
|
-
{ band: 4, gain: 0.25 + 0 },
|
|
866
|
-
{ band: 5, gain: 0.25 + -0.0125 },
|
|
867
|
-
{ band: 6, gain: 0.25 + -0.025 },
|
|
868
|
-
{ band: 7, gain: 0.25 + -0.0175 },
|
|
869
|
-
{ band: 8, gain: 0.25 + 0 },
|
|
870
|
-
{ band: 9, gain: 0.25 + 0 },
|
|
871
|
-
{ band: 10, gain: 0.25 + 0.0125 },
|
|
872
|
-
{ band: 11, gain: 0.25 + 0.025 },
|
|
873
|
-
{ band: 12, gain: 0.25 + 0.375 },
|
|
874
|
-
{ band: 13, gain: 0.25 + 0.125 },
|
|
875
|
-
{ band: 14, gain: 0.25 + 0.125 },
|
|
876
|
-
],
|
|
877
|
-
/** Boosts basses + lower highs for a pro gaming sound */
|
|
878
|
-
Gaming: [
|
|
879
|
-
{ band: 0, gain: 0.350 },
|
|
880
|
-
{ band: 1, gain: 0.300 },
|
|
881
|
-
{ band: 2, gain: 0.250 },
|
|
882
|
-
{ band: 3, gain: 0.200 },
|
|
883
|
-
{ band: 4, gain: 0.150 },
|
|
884
|
-
{ band: 5, gain: 0.100 },
|
|
885
|
-
{ band: 6, gain: 0.050 },
|
|
886
|
-
{ band: 7, gain: -0.0 },
|
|
887
|
-
{ band: 8, gain: -0.050 },
|
|
888
|
-
{ band: 9, gain: -0.100 },
|
|
889
|
-
{ band: 10, gain: -0.150 },
|
|
890
|
-
{ band: 11, gain: -0.200 },
|
|
891
|
-
{ band: 12, gain: -0.250 },
|
|
892
|
-
{ band: 13, gain: -0.300 },
|
|
893
|
-
{ band: 14, gain: -0.350 },
|
|
894
|
-
],
|
|
895
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* The FilterManager for each player
|
|
3
|
+
*/
|
|
4
|
+
export class FilterManager {
|
|
5
|
+
/** The Equalizer bands currently applied to the Lavalink Server */
|
|
6
|
+
equalizerBands = [];
|
|
7
|
+
/** Private Util for the instaFix Filters option */
|
|
8
|
+
filterUpdatedState = 0;
|
|
9
|
+
/** All "Active" / "disabled" Player Filters */
|
|
10
|
+
filters = {
|
|
11
|
+
volume: false,
|
|
12
|
+
vaporwave: false,
|
|
13
|
+
custom: false,
|
|
14
|
+
nightcore: false,
|
|
15
|
+
rotation: false,
|
|
16
|
+
karaoke: false,
|
|
17
|
+
tremolo: false,
|
|
18
|
+
vibrato: false,
|
|
19
|
+
lowPass: false,
|
|
20
|
+
lavalinkFilterPlugin: {
|
|
21
|
+
echo: false,
|
|
22
|
+
reverb: false,
|
|
23
|
+
},
|
|
24
|
+
lavalinkLavaDspxPlugin: {
|
|
25
|
+
lowPass: false,
|
|
26
|
+
highPass: false,
|
|
27
|
+
normalization: false,
|
|
28
|
+
echo: false,
|
|
29
|
+
},
|
|
30
|
+
audioOutput: "stereo",
|
|
31
|
+
};
|
|
32
|
+
/** The Filter Data sent to Lavalink, only if the filter is enabled (ofc.) */
|
|
33
|
+
data = {
|
|
34
|
+
lowPass: {
|
|
35
|
+
smoothing: 0
|
|
36
|
+
},
|
|
37
|
+
karaoke: {
|
|
38
|
+
level: 0,
|
|
39
|
+
monoLevel: 0,
|
|
40
|
+
filterBand: 0,
|
|
41
|
+
filterWidth: 0
|
|
42
|
+
},
|
|
43
|
+
timescale: {
|
|
44
|
+
speed: 1,
|
|
45
|
+
pitch: 1,
|
|
46
|
+
rate: 1 // 0 = x
|
|
47
|
+
},
|
|
48
|
+
rotation: {
|
|
49
|
+
rotationHz: 0
|
|
50
|
+
},
|
|
51
|
+
tremolo: {
|
|
52
|
+
frequency: 0,
|
|
53
|
+
depth: 0 // 0 < x = 1
|
|
54
|
+
},
|
|
55
|
+
vibrato: {
|
|
56
|
+
frequency: 0,
|
|
57
|
+
depth: 0 // 0 < x <= 1
|
|
58
|
+
},
|
|
59
|
+
pluginFilters: {
|
|
60
|
+
"lavalink-filter-plugin": {
|
|
61
|
+
echo: {
|
|
62
|
+
delay: 0,
|
|
63
|
+
decay: 0 // 0 < 1
|
|
64
|
+
},
|
|
65
|
+
reverb: {
|
|
66
|
+
delays: [],
|
|
67
|
+
gains: [] // [0.84, 0.83, 0.82, 0.81]
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"high-pass": { // Cuts off frequencies lower than the specified {cutoffFrequency}.
|
|
71
|
+
// "cutoffFrequency": 1475, // Integer, higher than zero, in Hz.
|
|
72
|
+
// "boostFactor": 1.0 // Float, higher than 0.0. This alters volume output. A value of 1.0 means no volume change.
|
|
73
|
+
},
|
|
74
|
+
"low-pass": { // Cuts off frequencies higher than the specified {cutoffFrequency}.
|
|
75
|
+
// "cutoffFrequency": 284, // Integer, higher than zero, in Hz.
|
|
76
|
+
// "boostFactor": 1.24389 // Float, higher than 0.0. This alters volume output. A value of 1.0 means no volume change.
|
|
77
|
+
},
|
|
78
|
+
"normalization": { // Attenuates peaking where peaks are defined as having a higher value than {maxAmplitude}.
|
|
79
|
+
// "maxAmplitude": 0.6327, // Float, within the range of 0.0 - 1.0. A value of 0.0 mutes the output.
|
|
80
|
+
// "adaptive": true // false
|
|
81
|
+
},
|
|
82
|
+
"echo": { // Self-explanatory; provides an echo effect.
|
|
83
|
+
// "echoLength": 0.5649, // Float, higher than 0.0, in seconds (1.0 = 1 second).
|
|
84
|
+
// "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
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
channelMix: audioOutputsData.stereo,
|
|
88
|
+
/*distortion: {
|
|
89
|
+
sinOffset: 0,
|
|
90
|
+
sinScale: 1,
|
|
91
|
+
cosOffset: 0,
|
|
92
|
+
cosScale: 1,
|
|
93
|
+
tanOffset: 0,
|
|
94
|
+
tanScale: 1,
|
|
95
|
+
offset: 0,
|
|
96
|
+
scale: 1
|
|
97
|
+
}*/
|
|
98
|
+
};
|
|
99
|
+
/** The Player assigned to this Filter Manager */
|
|
100
|
+
player;
|
|
101
|
+
/** The Constructor for the FilterManager */
|
|
102
|
+
constructor(player) {
|
|
103
|
+
/** Assign the player to the filter manager */
|
|
104
|
+
this.player = player;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Apply Player filters for lavalink filter sending data, if the filter is enabled / not
|
|
108
|
+
*/
|
|
109
|
+
async applyPlayerFilters() {
|
|
110
|
+
const sendData = { ...this.data };
|
|
111
|
+
this.checkFiltersState();
|
|
112
|
+
if (!this.filters.volume)
|
|
113
|
+
delete sendData.volume;
|
|
114
|
+
if (!this.filters.tremolo)
|
|
115
|
+
delete sendData.tremolo;
|
|
116
|
+
if (!this.filters.vibrato)
|
|
117
|
+
delete sendData.vibrato;
|
|
118
|
+
if (!this.filters.lavalinkFilterPlugin.echo)
|
|
119
|
+
delete sendData.pluginFilters?.["lavalink-filter-plugin"]?.echo;
|
|
120
|
+
if (!this.filters.lavalinkFilterPlugin.reverb)
|
|
121
|
+
delete sendData.pluginFilters?.["lavalink-filter-plugin"]?.reverb;
|
|
122
|
+
if (!this.filters.lavalinkLavaDspxPlugin.echo)
|
|
123
|
+
delete sendData.pluginFilters?.echo;
|
|
124
|
+
if (!this.filters.lavalinkLavaDspxPlugin.normalization)
|
|
125
|
+
delete sendData.pluginFilters?.normalization;
|
|
126
|
+
if (!this.filters.lavalinkLavaDspxPlugin.highPass)
|
|
127
|
+
delete sendData.pluginFilters?.["high-pass"];
|
|
128
|
+
if (!this.filters.lavalinkLavaDspxPlugin.lowPass)
|
|
129
|
+
delete sendData.pluginFilters?.["low-pass"];
|
|
130
|
+
if (sendData.pluginFilters?.["lavalink-filter-plugin"] && Object.values(sendData.pluginFilters?.["lavalink-filter-plugin"]).length === 0)
|
|
131
|
+
delete sendData.pluginFilters["lavalink-filter-plugin"];
|
|
132
|
+
if (sendData.pluginFilters && Object.values(sendData.pluginFilters).length === 0)
|
|
133
|
+
delete sendData.pluginFilters;
|
|
134
|
+
if (!this.filters.lowPass)
|
|
135
|
+
delete sendData.lowPass;
|
|
136
|
+
if (!this.filters.karaoke)
|
|
137
|
+
delete sendData.karaoke;
|
|
138
|
+
if (!this.filters.rotation)
|
|
139
|
+
delete sendData.rotation;
|
|
140
|
+
if (this.filters.audioOutput === "stereo")
|
|
141
|
+
delete sendData.channelMix;
|
|
142
|
+
if (Object.values(this.data.timescale).every(v => v === 1))
|
|
143
|
+
delete sendData.timescale;
|
|
144
|
+
if (!this.player.node.sessionId)
|
|
145
|
+
throw new Error("The Lavalink-Node is either not ready or not up to date");
|
|
146
|
+
sendData.equalizer = [...this.equalizerBands];
|
|
147
|
+
if (sendData.equalizer.length === 0)
|
|
148
|
+
delete sendData.equalizer;
|
|
149
|
+
for (const key of [...Object.keys(sendData)]) {
|
|
150
|
+
// delete disabled filters
|
|
151
|
+
if (key === "pluginFilters") {
|
|
152
|
+
// for(const key of [...Object.keys(sendData.pluginFilters)]) {
|
|
153
|
+
// // if (this.player.node.info && !this.player.node.info?.plugins?.find?.(v => v.name === key)) delete sendData[key];
|
|
154
|
+
// }
|
|
155
|
+
}
|
|
156
|
+
else if (this.player.node.info && !this.player.node.info?.filters?.includes?.(key))
|
|
157
|
+
delete sendData[key];
|
|
158
|
+
}
|
|
159
|
+
const now = performance.now();
|
|
160
|
+
await this.player.node.updatePlayer({
|
|
161
|
+
guildId: this.player.guildId,
|
|
162
|
+
playerOptions: {
|
|
163
|
+
filters: sendData,
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
this.player.ping.lavalink = Math.round((performance.now() - now) / 10) / 100;
|
|
167
|
+
if (this.player.options.instaUpdateFiltersFix === true)
|
|
168
|
+
this.filterUpdatedState = 1;
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Checks if the filters are correctly stated (active / not-active)
|
|
173
|
+
* @param oldFilterTimescale
|
|
174
|
+
* @returns
|
|
175
|
+
*/
|
|
176
|
+
checkFiltersState(oldFilterTimescale) {
|
|
177
|
+
this.filters.rotation = this.data.rotation.rotationHz !== 0;
|
|
178
|
+
this.filters.vibrato = this.data.vibrato.frequency !== 0 || this.data.vibrato.depth !== 0;
|
|
179
|
+
this.filters.tremolo = this.data.tremolo.frequency !== 0 || this.data.tremolo.depth !== 0;
|
|
180
|
+
const lavalinkFilterData = (this.data.pluginFilters?.["lavalink-filter-plugin"] || { echo: { decay: this.data.pluginFilters?.echo?.decay && !this.data.pluginFilters?.echo?.echoLength ? this.data.pluginFilters.echo.decay : 0, delay: this.data.pluginFilters?.echo?.delay || 0 }, reverb: { gains: [], delays: [], ...((this.data.pluginFilters.reverb) || {}) } });
|
|
181
|
+
this.filters.lavalinkFilterPlugin.echo = lavalinkFilterData.echo.decay !== 0 || lavalinkFilterData.echo.delay !== 0;
|
|
182
|
+
this.filters.lavalinkFilterPlugin.reverb = lavalinkFilterData.reverb?.delays?.length !== 0 || lavalinkFilterData.reverb?.gains?.length !== 0;
|
|
183
|
+
this.filters.lavalinkLavaDspxPlugin.highPass = Object.values(this.data.pluginFilters["high-pass"] || {}).length > 0;
|
|
184
|
+
this.filters.lavalinkLavaDspxPlugin.lowPass = Object.values(this.data.pluginFilters["low-pass"] || {}).length > 0;
|
|
185
|
+
this.filters.lavalinkLavaDspxPlugin.normalization = Object.values(this.data.pluginFilters.normalization || {}).length > 0;
|
|
186
|
+
this.filters.lavalinkLavaDspxPlugin.echo = Object.values(this.data.pluginFilters.echo || {}).length > 0 && typeof this.data.pluginFilters?.echo?.delay === "undefined";
|
|
187
|
+
this.filters.lowPass = this.data.lowPass.smoothing !== 0;
|
|
188
|
+
this.filters.karaoke = Object.values(this.data.karaoke).some(v => v !== 0);
|
|
189
|
+
if ((this.filters.nightcore || this.filters.vaporwave) && oldFilterTimescale) {
|
|
190
|
+
if (oldFilterTimescale.pitch !== this.data.timescale.pitch || oldFilterTimescale.rate !== this.data.timescale.rate || oldFilterTimescale.speed !== this.data.timescale.speed) {
|
|
191
|
+
this.filters.custom = Object.values(this.data.timescale).some(v => v !== 1);
|
|
192
|
+
this.filters.nightcore = false;
|
|
193
|
+
this.filters.vaporwave = false;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Reset all Filters
|
|
200
|
+
*/
|
|
201
|
+
async resetFilters() {
|
|
202
|
+
this.filters.lavalinkLavaDspxPlugin.echo = false;
|
|
203
|
+
this.filters.lavalinkLavaDspxPlugin.normalization = false;
|
|
204
|
+
this.filters.lavalinkLavaDspxPlugin.highPass = false;
|
|
205
|
+
this.filters.lavalinkLavaDspxPlugin.lowPass = false;
|
|
206
|
+
this.filters.lavalinkFilterPlugin.echo = false;
|
|
207
|
+
this.filters.lavalinkFilterPlugin.reverb = false;
|
|
208
|
+
this.filters.nightcore = false;
|
|
209
|
+
this.filters.lowPass = false;
|
|
210
|
+
this.filters.rotation = false;
|
|
211
|
+
this.filters.tremolo = false;
|
|
212
|
+
this.filters.vibrato = false;
|
|
213
|
+
this.filters.karaoke = false;
|
|
214
|
+
this.filters.karaoke = false;
|
|
215
|
+
this.filters.volume = false;
|
|
216
|
+
this.filters.audioOutput = "stereo";
|
|
217
|
+
// reset all filter datas
|
|
218
|
+
for (const [key, value] of Object.entries({
|
|
219
|
+
volume: 1,
|
|
220
|
+
lowPass: {
|
|
221
|
+
smoothing: 0
|
|
222
|
+
},
|
|
223
|
+
karaoke: {
|
|
224
|
+
level: 0,
|
|
225
|
+
monoLevel: 0,
|
|
226
|
+
filterBand: 0,
|
|
227
|
+
filterWidth: 0
|
|
228
|
+
},
|
|
229
|
+
timescale: {
|
|
230
|
+
speed: 1,
|
|
231
|
+
pitch: 1,
|
|
232
|
+
rate: 1 // 0 = x
|
|
233
|
+
},
|
|
234
|
+
pluginFilters: {
|
|
235
|
+
"lavalink-filter-plugin": {
|
|
236
|
+
echo: {
|
|
237
|
+
// delay: 0, // in seconds
|
|
238
|
+
// decay: 0 // 0 < 1
|
|
239
|
+
},
|
|
240
|
+
reverb: {
|
|
241
|
+
// delays: [], // [0.037, 0.042, 0.048, 0.053]
|
|
242
|
+
// gains: [] // [0.84, 0.83, 0.82, 0.81]
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
"high-pass": { // Cuts off frequencies lower than the specified {cutoffFrequency}.
|
|
246
|
+
// "cutoffFrequency": 1475, // Integer, higher than zero, in Hz.
|
|
247
|
+
// "boostFactor": 1.0 // Float, higher than 0.0. This alters volume output. A value of 1.0 means no volume change.
|
|
248
|
+
},
|
|
249
|
+
"low-pass": { // Cuts off frequencies higher than the specified {cutoffFrequency}.
|
|
250
|
+
// "cutoffFrequency": 284, // Integer, higher than zero, in Hz.
|
|
251
|
+
// "boostFactor": 1.24389 // Float, higher than 0.0. This alters volume output. A value of 1.0 means no volume change.
|
|
252
|
+
},
|
|
253
|
+
"normalization": { // Attenuates peaking where peaks are defined as having a higher value than {maxAmplitude}.
|
|
254
|
+
// "maxAmplitude": 0.6327, // Float, within the range of 0.0 - 1.0. A value of 0.0 mutes the output.
|
|
255
|
+
// "adaptive": true // false
|
|
256
|
+
},
|
|
257
|
+
"echo": { // Self-explanatory; provides an echo effect.
|
|
258
|
+
// "echoLength": 0.5649, // Float, higher than 0.0, in seconds (1.0 = 1 second).
|
|
259
|
+
// "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
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
rotation: {
|
|
263
|
+
rotationHz: 0
|
|
264
|
+
},
|
|
265
|
+
tremolo: {
|
|
266
|
+
frequency: 0,
|
|
267
|
+
depth: 0 // 0 < x = 1
|
|
268
|
+
},
|
|
269
|
+
vibrato: {
|
|
270
|
+
frequency: 0,
|
|
271
|
+
depth: 0 // 0 < x = 1
|
|
272
|
+
},
|
|
273
|
+
channelMix: audioOutputsData.stereo,
|
|
274
|
+
})) {
|
|
275
|
+
this.data[key] = value;
|
|
276
|
+
}
|
|
277
|
+
await this.applyPlayerFilters();
|
|
278
|
+
return this.filters;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Set the Filter Volume
|
|
282
|
+
* @param volume
|
|
283
|
+
* @returns
|
|
284
|
+
*/
|
|
285
|
+
async setVolume(volume) {
|
|
286
|
+
if (volume < 0 || volume > 5)
|
|
287
|
+
throw new SyntaxError("Volume-Filter must be between 0 and 5");
|
|
288
|
+
this.data.volume = volume;
|
|
289
|
+
await this.applyPlayerFilters();
|
|
290
|
+
return this.filters.volume;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Set the AudioOutput Filter
|
|
294
|
+
* @param type
|
|
295
|
+
* @returns
|
|
296
|
+
*/
|
|
297
|
+
async setAudioOutput(type) {
|
|
298
|
+
if (this.player.node.info && !this.player.node.info?.filters?.includes("channelMix"))
|
|
299
|
+
throw new Error("Node#Info#filters does not include the 'channelMix' Filter (Node has it not enable)");
|
|
300
|
+
if (!type || !audioOutputsData[type])
|
|
301
|
+
throw "Invalid audio type added, must be 'mono' / 'stereo' / 'left' / 'right'";
|
|
302
|
+
this.data.channelMix = audioOutputsData[type];
|
|
303
|
+
this.filters.audioOutput = type;
|
|
304
|
+
await this.applyPlayerFilters();
|
|
305
|
+
return this.filters.audioOutput;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Set custom filter.timescale#speed . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
|
|
309
|
+
* @param speed
|
|
310
|
+
* @returns
|
|
311
|
+
*/
|
|
312
|
+
async setSpeed(speed = 1) {
|
|
313
|
+
if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale"))
|
|
314
|
+
throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
|
|
315
|
+
// reset nightcore / vaporwave filter if enabled
|
|
316
|
+
if (this.filters.nightcore || this.filters.vaporwave) {
|
|
317
|
+
this.data.timescale.pitch = 1;
|
|
318
|
+
this.data.timescale.speed = 1;
|
|
319
|
+
this.data.timescale.rate = 1;
|
|
320
|
+
this.filters.nightcore = false;
|
|
321
|
+
this.filters.vaporwave = false;
|
|
322
|
+
}
|
|
323
|
+
this.data.timescale.speed = speed;
|
|
324
|
+
// check if custom filter is active / not
|
|
325
|
+
this.isCustomFilterActive();
|
|
326
|
+
await this.applyPlayerFilters();
|
|
327
|
+
return this.filters.custom;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Set custom filter.timescale#pitch . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
|
|
331
|
+
* @param speed
|
|
332
|
+
* @returns
|
|
333
|
+
*/
|
|
334
|
+
async setPitch(pitch = 1) {
|
|
335
|
+
if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale"))
|
|
336
|
+
throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
|
|
337
|
+
// reset nightcore / vaporwave filter if enabled
|
|
338
|
+
if (this.filters.nightcore || this.filters.vaporwave) {
|
|
339
|
+
this.data.timescale.pitch = 1;
|
|
340
|
+
this.data.timescale.speed = 1;
|
|
341
|
+
this.data.timescale.rate = 1;
|
|
342
|
+
this.filters.nightcore = false;
|
|
343
|
+
this.filters.vaporwave = false;
|
|
344
|
+
}
|
|
345
|
+
this.data.timescale.pitch = pitch;
|
|
346
|
+
// check if custom filter is active / not
|
|
347
|
+
this.isCustomFilterActive();
|
|
348
|
+
await this.applyPlayerFilters();
|
|
349
|
+
return this.filters.custom;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Set custom filter.timescale#rate . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
|
|
353
|
+
* @param speed
|
|
354
|
+
* @returns
|
|
355
|
+
*/
|
|
356
|
+
async setRate(rate = 1) {
|
|
357
|
+
if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale"))
|
|
358
|
+
throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
|
|
359
|
+
// reset nightcore / vaporwave filter if enabled
|
|
360
|
+
if (this.filters.nightcore || this.filters.vaporwave) {
|
|
361
|
+
this.data.timescale.pitch = 1;
|
|
362
|
+
this.data.timescale.speed = 1;
|
|
363
|
+
this.data.timescale.rate = 1;
|
|
364
|
+
this.filters.nightcore = false;
|
|
365
|
+
this.filters.vaporwave = false;
|
|
366
|
+
}
|
|
367
|
+
this.data.timescale.rate = rate;
|
|
368
|
+
// check if custom filter is active / not
|
|
369
|
+
this.isCustomFilterActive();
|
|
370
|
+
await this.applyPlayerFilters();
|
|
371
|
+
return this.filters.custom;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Enables / Disables the rotation effect, (Optional: provide your Own Data)
|
|
375
|
+
* @param rotationHz
|
|
376
|
+
* @returns
|
|
377
|
+
*/
|
|
378
|
+
async toggleRotation(rotationHz = 0.2) {
|
|
379
|
+
if (this.player.node.info && !this.player.node.info?.filters?.includes("rotation"))
|
|
380
|
+
throw new Error("Node#Info#filters does not include the 'rotation' Filter (Node has it not enable)");
|
|
381
|
+
this.data.rotation.rotationHz = this.filters.rotation ? 0 : rotationHz;
|
|
382
|
+
this.filters.rotation = !this.filters.rotation;
|
|
383
|
+
return await this.applyPlayerFilters(), this.filters.rotation;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Enables / Disables the Vibrato effect, (Optional: provide your Own Data)
|
|
387
|
+
* @param frequency
|
|
388
|
+
* @param depth
|
|
389
|
+
* @returns
|
|
390
|
+
*/
|
|
391
|
+
async toggleVibrato(frequency = 10, depth = 1) {
|
|
392
|
+
if (this.player.node.info && !this.player.node.info?.filters?.includes("vibrato"))
|
|
393
|
+
throw new Error("Node#Info#filters does not include the 'vibrato' Filter (Node has it not enable)");
|
|
394
|
+
this.data.vibrato.frequency = this.filters.vibrato ? 0 : frequency;
|
|
395
|
+
this.data.vibrato.depth = this.filters.vibrato ? 0 : depth;
|
|
396
|
+
this.filters.vibrato = !this.filters.vibrato;
|
|
397
|
+
await this.applyPlayerFilters();
|
|
398
|
+
return this.filters.vibrato;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Enables / Disables the Tremolo effect, (Optional: provide your Own Data)
|
|
402
|
+
* @param frequency
|
|
403
|
+
* @param depth
|
|
404
|
+
* @returns
|
|
405
|
+
*/
|
|
406
|
+
async toggleTremolo(frequency = 4, depth = 0.8) {
|
|
407
|
+
if (this.player.node.info && !this.player.node.info?.filters?.includes("tremolo"))
|
|
408
|
+
throw new Error("Node#Info#filters does not include the 'tremolo' Filter (Node has it not enable)");
|
|
409
|
+
this.data.tremolo.frequency = this.filters.tremolo ? 0 : frequency;
|
|
410
|
+
this.data.tremolo.depth = this.filters.tremolo ? 0 : depth;
|
|
411
|
+
this.filters.tremolo = !this.filters.tremolo;
|
|
412
|
+
await this.applyPlayerFilters();
|
|
413
|
+
return this.filters.tremolo;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Enables / Disables the LowPass effect, (Optional: provide your Own Data)
|
|
417
|
+
* @param smoothing
|
|
418
|
+
* @returns
|
|
419
|
+
*/
|
|
420
|
+
async toggleLowPass(smoothing = 20) {
|
|
421
|
+
if (this.player.node.info && !this.player.node.info?.filters?.includes("lowPass"))
|
|
422
|
+
throw new Error("Node#Info#filters does not include the 'lowPass' Filter (Node has it not enable)");
|
|
423
|
+
this.data.lowPass.smoothing = this.filters.lowPass ? 0 : smoothing;
|
|
424
|
+
this.filters.lowPass = !this.filters.lowPass;
|
|
425
|
+
await this.applyPlayerFilters();
|
|
426
|
+
return this.filters.lowPass;
|
|
427
|
+
}
|
|
428
|
+
lavalinkLavaDspxPlugin = {
|
|
429
|
+
toggleLowPass: async (boostFactor = 1.0, cutoffFrequency = 80) => {
|
|
430
|
+
if (this.player.node.info && !this.player.node.info?.plugins?.find(v => v.name === "lavadspx-plugin"))
|
|
431
|
+
throw new Error("Node#Info#plugins does not include the lavadspx plugin");
|
|
432
|
+
if (this.player.node.info && !this.player.node.info?.filters?.includes("low-pass"))
|
|
433
|
+
throw new Error("Node#Info#filters does not include the 'low-pass' Filter (Node has it not enable)");
|
|
434
|
+
if (!this.data)
|
|
435
|
+
this.data = {};
|
|
436
|
+
if (!this.data.pluginFilters)
|
|
437
|
+
this.data.pluginFilters = {};
|
|
438
|
+
if (!this.data.pluginFilters["low-pass"])
|
|
439
|
+
this.data.pluginFilters["low-pass"] = {};
|
|
440
|
+
if (this.filters.lavalinkLavaDspxPlugin.lowPass) {
|
|
441
|
+
delete this.data.pluginFilters["low-pass"];
|
|
442
|
+
}
|
|
443
|
+
else {
|
|
444
|
+
this.data.pluginFilters["low-pass"] = {
|
|
445
|
+
boostFactor: boostFactor,
|
|
446
|
+
cutoffFrequency: cutoffFrequency
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
this.filters.lavalinkLavaDspxPlugin.lowPass = !this.filters.lavalinkLavaDspxPlugin.lowPass;
|
|
450
|
+
await this.applyPlayerFilters();
|
|
451
|
+
return this.filters.lavalinkLavaDspxPlugin.lowPass;
|
|
452
|
+
},
|
|
453
|
+
toggleHighPass: async (boostFactor = 1.0, cutoffFrequency = 80) => {
|
|
454
|
+
if (this.player.node.info && !this.player.node.info?.plugins?.find(v => v.name === "lavadspx-plugin"))
|
|
455
|
+
throw new Error("Node#Info#plugins does not include the lavadspx plugin");
|
|
456
|
+
if (this.player.node.info && !this.player.node.info?.filters?.includes("high-pass"))
|
|
457
|
+
throw new Error("Node#Info#filters does not include the 'high-pass' Filter (Node has it not enable)");
|
|
458
|
+
if (!this.data)
|
|
459
|
+
this.data = {};
|
|
460
|
+
if (!this.data.pluginFilters)
|
|
461
|
+
this.data.pluginFilters = {};
|
|
462
|
+
if (!this.data.pluginFilters["high-pass"])
|
|
463
|
+
this.data.pluginFilters["high-pass"] = {};
|
|
464
|
+
if (this.filters.lavalinkLavaDspxPlugin.highPass) {
|
|
465
|
+
delete this.data.pluginFilters["high-pass"];
|
|
466
|
+
}
|
|
467
|
+
else {
|
|
468
|
+
this.data.pluginFilters["high-pass"] = {
|
|
469
|
+
boostFactor: boostFactor,
|
|
470
|
+
cutoffFrequency: cutoffFrequency
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
this.filters.lavalinkLavaDspxPlugin.highPass = !this.filters.lavalinkLavaDspxPlugin.highPass;
|
|
474
|
+
await this.applyPlayerFilters();
|
|
475
|
+
return this.filters.lavalinkLavaDspxPlugin.highPass;
|
|
476
|
+
},
|
|
477
|
+
toggleNormalization: async (maxAmplitude = 0.75, adaptive = true) => {
|
|
478
|
+
if (this.player.node.info && !this.player.node.info?.plugins?.find(v => v.name === "lavadspx-plugin"))
|
|
479
|
+
throw new Error("Node#Info#plugins does not include the lavadspx plugin");
|
|
480
|
+
if (this.player.node.info && !this.player.node.info?.filters?.includes("normalization"))
|
|
481
|
+
throw new Error("Node#Info#filters does not include the 'normalization' Filter (Node has it not enable)");
|
|
482
|
+
if (!this.data)
|
|
483
|
+
this.data = {};
|
|
484
|
+
if (!this.data.pluginFilters)
|
|
485
|
+
this.data.pluginFilters = {};
|
|
486
|
+
if (!this.data.pluginFilters.normalization)
|
|
487
|
+
this.data.pluginFilters.normalization = {};
|
|
488
|
+
if (this.filters.lavalinkLavaDspxPlugin.normalization) {
|
|
489
|
+
delete this.data.pluginFilters.normalization;
|
|
490
|
+
}
|
|
491
|
+
else {
|
|
492
|
+
this.data.pluginFilters.normalization = {
|
|
493
|
+
adaptive: adaptive,
|
|
494
|
+
maxAmplitude: maxAmplitude
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
this.filters.lavalinkLavaDspxPlugin.normalization = !this.filters.lavalinkLavaDspxPlugin.normalization;
|
|
498
|
+
await this.applyPlayerFilters();
|
|
499
|
+
return this.filters.lavalinkLavaDspxPlugin.normalization;
|
|
500
|
+
},
|
|
501
|
+
toggleEcho: async (decay = 0.5, echoLength = 0.5) => {
|
|
502
|
+
if (this.player.node.info && !this.player.node.info?.plugins?.find(v => v.name === "lavadspx-plugin"))
|
|
503
|
+
throw new Error("Node#Info#plugins does not include the lavadspx plugin");
|
|
504
|
+
if (this.player.node.info && !this.player.node.info?.filters?.includes("echo"))
|
|
505
|
+
throw new Error("Node#Info#filters does not include the 'echo' Filter (Node has it not enable)");
|
|
506
|
+
if (!this.data)
|
|
507
|
+
this.data = {};
|
|
508
|
+
if (!this.data.pluginFilters)
|
|
509
|
+
this.data.pluginFilters = {};
|
|
510
|
+
if (!this.data.pluginFilters.echo)
|
|
511
|
+
this.data.pluginFilters.echo = {};
|
|
512
|
+
if (this.filters.lavalinkLavaDspxPlugin.echo) {
|
|
513
|
+
delete this.data.pluginFilters.echo;
|
|
514
|
+
}
|
|
515
|
+
else {
|
|
516
|
+
this.data.pluginFilters.echo = {
|
|
517
|
+
decay: decay,
|
|
518
|
+
echoLength: echoLength
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
this.filters.lavalinkLavaDspxPlugin.echo = !this.filters.lavalinkLavaDspxPlugin.echo;
|
|
522
|
+
await this.applyPlayerFilters();
|
|
523
|
+
return this.filters.lavalinkLavaDspxPlugin.echo;
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
lavalinkFilterPlugin = {
|
|
527
|
+
/**
|
|
528
|
+
* Enables / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
|
|
529
|
+
* @param delay
|
|
530
|
+
* @param decay
|
|
531
|
+
* @returns
|
|
532
|
+
*/
|
|
533
|
+
toggleEcho: async (delay = 4, decay = 0.8) => {
|
|
534
|
+
if (this.player.node.info && !this.player.node.info?.plugins?.find(v => v.name === "lavalink-filter-plugin"))
|
|
535
|
+
throw new Error("Node#Info#plugins does not include the lavalink-filter-plugin plugin");
|
|
536
|
+
if (this.player.node.info && !this.player.node.info?.filters?.includes("echo"))
|
|
537
|
+
throw new Error("Node#Info#filters does not include the 'echo' Filter (Node has it not enable aka not installed!)");
|
|
538
|
+
if (!this.data)
|
|
539
|
+
this.data = {};
|
|
540
|
+
if (!this.data.pluginFilters)
|
|
541
|
+
this.data.pluginFilters = {};
|
|
542
|
+
if (!this.data.pluginFilters["lavalink-filter-plugin"])
|
|
543
|
+
this.data.pluginFilters["lavalink-filter-plugin"] = { echo: { decay: 0, delay: 0 }, reverb: { delays: [], gains: [] } };
|
|
544
|
+
if (!this.data.pluginFilters["lavalink-filter-plugin"].echo)
|
|
545
|
+
this.data.pluginFilters["lavalink-filter-plugin"].echo = { decay: 0, delay: 0 };
|
|
546
|
+
this.data.pluginFilters["lavalink-filter-plugin"].echo.delay = this.filters.lavalinkFilterPlugin.echo ? 0 : delay;
|
|
547
|
+
this.data.pluginFilters["lavalink-filter-plugin"].echo.decay = this.filters.lavalinkFilterPlugin.echo ? 0 : decay;
|
|
548
|
+
this.filters.lavalinkFilterPlugin.echo = !this.filters.lavalinkFilterPlugin.echo;
|
|
549
|
+
await this.applyPlayerFilters();
|
|
550
|
+
return this.filters.lavalinkFilterPlugin.echo;
|
|
551
|
+
},
|
|
552
|
+
/**
|
|
553
|
+
* Enables / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
|
|
554
|
+
* @param delays
|
|
555
|
+
* @param gains
|
|
556
|
+
* @returns
|
|
557
|
+
*/
|
|
558
|
+
toggleReverb: async (delays = [0.037, 0.042, 0.048, 0.053], gains = [0.84, 0.83, 0.82, 0.81]) => {
|
|
559
|
+
if (this.player.node.info && !this.player.node.info?.plugins?.find(v => v.name === "lavalink-filter-plugin"))
|
|
560
|
+
throw new Error("Node#Info#plugins does not include the lavalink-filter-plugin plugin");
|
|
561
|
+
if (this.player.node.info && !this.player.node.info?.filters?.includes("reverb"))
|
|
562
|
+
throw new Error("Node#Info#filters does not include the 'reverb' Filter (Node has it not enable aka not installed!)");
|
|
563
|
+
if (!this.data)
|
|
564
|
+
this.data = {};
|
|
565
|
+
if (!this.data.pluginFilters)
|
|
566
|
+
this.data.pluginFilters = {};
|
|
567
|
+
if (!this.data.pluginFilters["lavalink-filter-plugin"])
|
|
568
|
+
this.data.pluginFilters["lavalink-filter-plugin"] = { echo: { decay: 0, delay: 0 }, reverb: { delays: [], gains: [] } };
|
|
569
|
+
if (!this.data.pluginFilters["lavalink-filter-plugin"].reverb)
|
|
570
|
+
this.data.pluginFilters["lavalink-filter-plugin"].reverb = { delays: [], gains: [] };
|
|
571
|
+
this.data.pluginFilters["lavalink-filter-plugin"].reverb.delays = this.filters.lavalinkFilterPlugin.reverb ? [] : delays;
|
|
572
|
+
this.data.pluginFilters["lavalink-filter-plugin"].reverb.gains = this.filters.lavalinkFilterPlugin.reverb ? [] : gains;
|
|
573
|
+
this.filters.lavalinkFilterPlugin.reverb = !this.filters.lavalinkFilterPlugin.reverb;
|
|
574
|
+
await this.applyPlayerFilters();
|
|
575
|
+
return this.filters.lavalinkFilterPlugin.reverb;
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
/**
|
|
579
|
+
* Enables / Disables a Nightcore-like filter Effect. Disables/Overrides both: custom and Vaporwave Filter
|
|
580
|
+
* @param speed
|
|
581
|
+
* @param pitch
|
|
582
|
+
* @param rate
|
|
583
|
+
* @returns
|
|
584
|
+
*/
|
|
585
|
+
async toggleNightcore(speed = 1.289999523162842, pitch = 1.289999523162842, rate = 0.9365999523162842) {
|
|
586
|
+
if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale"))
|
|
587
|
+
throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
|
|
588
|
+
this.data.timescale.speed = this.filters.nightcore ? 1 : speed;
|
|
589
|
+
this.data.timescale.pitch = this.filters.nightcore ? 1 : pitch;
|
|
590
|
+
this.data.timescale.rate = this.filters.nightcore ? 1 : rate;
|
|
591
|
+
this.filters.nightcore = !this.filters.nightcore;
|
|
592
|
+
this.filters.vaporwave = false;
|
|
593
|
+
this.filters.custom = false;
|
|
594
|
+
await this.applyPlayerFilters();
|
|
595
|
+
return this.filters.nightcore;
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Enables / Disables a Vaporwave-like filter Effect. Disables/Overrides both: custom and nightcore Filter
|
|
599
|
+
* @param speed
|
|
600
|
+
* @param pitch
|
|
601
|
+
* @param rate
|
|
602
|
+
* @returns
|
|
603
|
+
*/
|
|
604
|
+
async toggleVaporwave(speed = 0.8500000238418579, pitch = 0.800000011920929, rate = 1) {
|
|
605
|
+
if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale"))
|
|
606
|
+
throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
|
|
607
|
+
this.data.timescale.speed = this.filters.vaporwave ? 1 : speed;
|
|
608
|
+
this.data.timescale.pitch = this.filters.vaporwave ? 1 : pitch;
|
|
609
|
+
this.data.timescale.rate = this.filters.vaporwave ? 1 : rate;
|
|
610
|
+
this.filters.vaporwave = !this.filters.vaporwave;
|
|
611
|
+
this.filters.nightcore = false;
|
|
612
|
+
this.filters.custom = false;
|
|
613
|
+
await this.applyPlayerFilters();
|
|
614
|
+
return this.filters.vaporwave;
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* Enable / Disables a Karaoke like Filter Effect
|
|
618
|
+
* @param level
|
|
619
|
+
* @param monoLevel
|
|
620
|
+
* @param filterBand
|
|
621
|
+
* @param filterWidth
|
|
622
|
+
* @returns
|
|
623
|
+
*/
|
|
624
|
+
async toggleKaraoke(level = 1, monoLevel = 1, filterBand = 220, filterWidth = 100) {
|
|
625
|
+
if (this.player.node.info && !this.player.node.info?.filters?.includes("karaoke"))
|
|
626
|
+
throw new Error("Node#Info#filters does not include the 'karaoke' Filter (Node has it not enable)");
|
|
627
|
+
this.data.karaoke.level = this.filters.karaoke ? 0 : level;
|
|
628
|
+
this.data.karaoke.monoLevel = this.filters.karaoke ? 0 : monoLevel;
|
|
629
|
+
this.data.karaoke.filterBand = this.filters.karaoke ? 0 : filterBand;
|
|
630
|
+
this.data.karaoke.filterWidth = this.filters.karaoke ? 0 : filterWidth;
|
|
631
|
+
this.filters.karaoke = !this.filters.karaoke;
|
|
632
|
+
await this.applyPlayerFilters();
|
|
633
|
+
return this.filters.karaoke;
|
|
634
|
+
}
|
|
635
|
+
/** Function to find out if currently there is a custom timescamle etc. filter applied */
|
|
636
|
+
isCustomFilterActive() {
|
|
637
|
+
this.filters.custom = !this.filters.nightcore && !this.filters.vaporwave && Object.values(this.data.timescale).some(d => d !== 1);
|
|
638
|
+
return this.filters.custom;
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Sets the players equalizer band on-top of the existing ones.
|
|
642
|
+
* @param bands
|
|
643
|
+
*/
|
|
644
|
+
async setEQ(bands) {
|
|
645
|
+
if (!Array.isArray(bands))
|
|
646
|
+
bands = [bands];
|
|
647
|
+
if (!bands.length || !bands.every((band) => JSON.stringify(Object.keys(band).sort()) === '["band","gain"]'))
|
|
648
|
+
throw new TypeError("Bands must be a non-empty object array containing 'band' and 'gain' properties.");
|
|
649
|
+
for (const { band, gain } of bands)
|
|
650
|
+
this.equalizerBands[band] = { band, gain };
|
|
651
|
+
if (!this.player.node.sessionId)
|
|
652
|
+
throw new Error("The Lavalink-Node is either not ready or not up to date");
|
|
653
|
+
const now = performance.now();
|
|
654
|
+
await this.player.node.updatePlayer({
|
|
655
|
+
guildId: this.player.guildId,
|
|
656
|
+
playerOptions: {
|
|
657
|
+
filters: { equalizer: this.equalizerBands }
|
|
658
|
+
}
|
|
659
|
+
});
|
|
660
|
+
this.player.ping.lavalink = Math.round((performance.now() - now) / 10) / 100;
|
|
661
|
+
if (this.player.options.instaUpdateFiltersFix === true)
|
|
662
|
+
this.filterUpdatedState = 1;
|
|
663
|
+
return this;
|
|
664
|
+
}
|
|
665
|
+
/** Clears the equalizer bands. */
|
|
666
|
+
async clearEQ() {
|
|
667
|
+
return this.setEQ(new Array(15).fill(0.0).map((gain, band) => ({ band, gain })));
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
/** The audio Outputs Data map declaration */
|
|
671
|
+
export const audioOutputsData = {
|
|
672
|
+
mono: {
|
|
673
|
+
leftToLeft: 0.5,
|
|
674
|
+
leftToRight: 0.5,
|
|
675
|
+
rightToLeft: 0.5,
|
|
676
|
+
rightToRight: 0.5,
|
|
677
|
+
},
|
|
678
|
+
stereo: {
|
|
679
|
+
leftToLeft: 1,
|
|
680
|
+
leftToRight: 0,
|
|
681
|
+
rightToLeft: 0,
|
|
682
|
+
rightToRight: 1,
|
|
683
|
+
},
|
|
684
|
+
left: {
|
|
685
|
+
leftToLeft: 1,
|
|
686
|
+
leftToRight: 0,
|
|
687
|
+
rightToLeft: 1,
|
|
688
|
+
rightToRight: 0,
|
|
689
|
+
},
|
|
690
|
+
right: {
|
|
691
|
+
leftToLeft: 0,
|
|
692
|
+
leftToRight: 1,
|
|
693
|
+
rightToLeft: 0,
|
|
694
|
+
rightToRight: 1,
|
|
695
|
+
},
|
|
696
|
+
};
|
|
697
|
+
export const EQList = {
|
|
698
|
+
/** A Bassboost Equalizer, so high it distorts the audio */
|
|
699
|
+
BassboostEarrape: [
|
|
700
|
+
{ band: 0, gain: 0.6 * 0.375 },
|
|
701
|
+
{ band: 1, gain: 0.67 * 0.375 },
|
|
702
|
+
{ band: 2, gain: 0.67 * 0.375 },
|
|
703
|
+
{ band: 3, gain: 0.4 * 0.375 },
|
|
704
|
+
{ band: 4, gain: -0.5 * 0.375 },
|
|
705
|
+
{ band: 5, gain: 0.15 * 0.375 },
|
|
706
|
+
{ band: 6, gain: -0.45 * 0.375 },
|
|
707
|
+
{ band: 7, gain: 0.23 * 0.375 },
|
|
708
|
+
{ band: 8, gain: 0.35 * 0.375 },
|
|
709
|
+
{ band: 9, gain: 0.45 * 0.375 },
|
|
710
|
+
{ band: 10, gain: 0.55 * 0.375 },
|
|
711
|
+
{ band: 11, gain: -0.6 * 0.375 },
|
|
712
|
+
{ band: 12, gain: 0.55 * 0.375 },
|
|
713
|
+
{ band: 13, gain: -0.5 * 0.375 },
|
|
714
|
+
{ band: 14, gain: -0.75 * 0.375 },
|
|
715
|
+
],
|
|
716
|
+
/** A High and decent Bassboost Equalizer */
|
|
717
|
+
BassboostHigh: [
|
|
718
|
+
{ band: 0, gain: 0.6 * 0.25 },
|
|
719
|
+
{ band: 1, gain: 0.67 * 0.25 },
|
|
720
|
+
{ band: 2, gain: 0.67 * 0.25 },
|
|
721
|
+
{ band: 3, gain: 0.4 * 0.25 },
|
|
722
|
+
{ band: 4, gain: -0.5 * 0.25 },
|
|
723
|
+
{ band: 5, gain: 0.15 * 0.25 },
|
|
724
|
+
{ band: 6, gain: -0.45 * 0.25 },
|
|
725
|
+
{ band: 7, gain: 0.23 * 0.25 },
|
|
726
|
+
{ band: 8, gain: 0.35 * 0.25 },
|
|
727
|
+
{ band: 9, gain: 0.45 * 0.25 },
|
|
728
|
+
{ band: 10, gain: 0.55 * 0.25 },
|
|
729
|
+
{ band: 11, gain: -0.6 * 0.25 },
|
|
730
|
+
{ band: 12, gain: 0.55 * 0.25 },
|
|
731
|
+
{ band: 13, gain: -0.5 * 0.25 },
|
|
732
|
+
{ band: 14, gain: -0.75 * 0.25 },
|
|
733
|
+
],
|
|
734
|
+
/** A decent Bassboost Equalizer */
|
|
735
|
+
BassboostMedium: [
|
|
736
|
+
{ band: 0, gain: 0.6 * 0.1875 },
|
|
737
|
+
{ band: 1, gain: 0.67 * 0.1875 },
|
|
738
|
+
{ band: 2, gain: 0.67 * 0.1875 },
|
|
739
|
+
{ band: 3, gain: 0.4 * 0.1875 },
|
|
740
|
+
{ band: 4, gain: -0.5 * 0.1875 },
|
|
741
|
+
{ band: 5, gain: 0.15 * 0.1875 },
|
|
742
|
+
{ band: 6, gain: -0.45 * 0.1875 },
|
|
743
|
+
{ band: 7, gain: 0.23 * 0.1875 },
|
|
744
|
+
{ band: 8, gain: 0.35 * 0.1875 },
|
|
745
|
+
{ band: 9, gain: 0.45 * 0.1875 },
|
|
746
|
+
{ band: 10, gain: 0.55 * 0.1875 },
|
|
747
|
+
{ band: 11, gain: -0.6 * 0.1875 },
|
|
748
|
+
{ band: 12, gain: 0.55 * 0.1875 },
|
|
749
|
+
{ band: 13, gain: -0.5 * 0.1875 },
|
|
750
|
+
{ band: 14, gain: -0.75 * 0.1875 },
|
|
751
|
+
],
|
|
752
|
+
/** A slight Bassboost Equalizer */
|
|
753
|
+
BassboostLow: [
|
|
754
|
+
{ band: 0, gain: 0.6 * 0.125 },
|
|
755
|
+
{ band: 1, gain: 0.67 * 0.125 },
|
|
756
|
+
{ band: 2, gain: 0.67 * 0.125 },
|
|
757
|
+
{ band: 3, gain: 0.4 * 0.125 },
|
|
758
|
+
{ band: 4, gain: -0.5 * 0.125 },
|
|
759
|
+
{ band: 5, gain: 0.15 * 0.125 },
|
|
760
|
+
{ band: 6, gain: -0.45 * 0.125 },
|
|
761
|
+
{ band: 7, gain: 0.23 * 0.125 },
|
|
762
|
+
{ band: 8, gain: 0.35 * 0.125 },
|
|
763
|
+
{ band: 9, gain: 0.45 * 0.125 },
|
|
764
|
+
{ band: 10, gain: 0.55 * 0.125 },
|
|
765
|
+
{ band: 11, gain: -0.6 * 0.125 },
|
|
766
|
+
{ band: 12, gain: 0.55 * 0.125 },
|
|
767
|
+
{ band: 13, gain: -0.5 * 0.125 },
|
|
768
|
+
{ band: 14, gain: -0.75 * 0.125 },
|
|
769
|
+
],
|
|
770
|
+
/** Makes the Music slightly "better" */
|
|
771
|
+
BetterMusic: [
|
|
772
|
+
{ band: 0, gain: 0.25 },
|
|
773
|
+
{ band: 1, gain: 0.025 },
|
|
774
|
+
{ band: 2, gain: 0.0125 },
|
|
775
|
+
{ band: 3, gain: 0 },
|
|
776
|
+
{ band: 4, gain: 0 },
|
|
777
|
+
{ band: 5, gain: -0.0125 },
|
|
778
|
+
{ band: 6, gain: -0.025 },
|
|
779
|
+
{ band: 7, gain: -0.0175 },
|
|
780
|
+
{ band: 8, gain: 0 },
|
|
781
|
+
{ band: 9, gain: 0 },
|
|
782
|
+
{ band: 10, gain: 0.0125 },
|
|
783
|
+
{ band: 11, gain: 0.025 },
|
|
784
|
+
{ band: 12, gain: 0.25 },
|
|
785
|
+
{ band: 13, gain: 0.125 },
|
|
786
|
+
{ band: 14, gain: 0.125 },
|
|
787
|
+
],
|
|
788
|
+
/** Makes the Music sound like rock music / sound rock music better */
|
|
789
|
+
Rock: [
|
|
790
|
+
{ band: 0, gain: 0.300 },
|
|
791
|
+
{ band: 1, gain: 0.250 },
|
|
792
|
+
{ band: 2, gain: 0.200 },
|
|
793
|
+
{ band: 3, gain: 0.100 },
|
|
794
|
+
{ band: 4, gain: 0.050 },
|
|
795
|
+
{ band: 5, gain: -0.050 },
|
|
796
|
+
{ band: 6, gain: -0.150 },
|
|
797
|
+
{ band: 7, gain: -0.200 },
|
|
798
|
+
{ band: 8, gain: -0.100 },
|
|
799
|
+
{ band: 9, gain: -0.050 },
|
|
800
|
+
{ band: 10, gain: 0.050 },
|
|
801
|
+
{ band: 11, gain: 0.100 },
|
|
802
|
+
{ band: 12, gain: 0.200 },
|
|
803
|
+
{ band: 13, gain: 0.250 },
|
|
804
|
+
{ band: 14, gain: 0.300 },
|
|
805
|
+
],
|
|
806
|
+
/** Makes the Music sound like Classic music / sound Classic music better */
|
|
807
|
+
Classic: [
|
|
808
|
+
{ band: 0, gain: 0.375 },
|
|
809
|
+
{ band: 1, gain: 0.350 },
|
|
810
|
+
{ band: 2, gain: 0.125 },
|
|
811
|
+
{ band: 3, gain: 0 },
|
|
812
|
+
{ band: 4, gain: 0 },
|
|
813
|
+
{ band: 5, gain: 0.125 },
|
|
814
|
+
{ band: 6, gain: 0.550 },
|
|
815
|
+
{ band: 7, gain: 0.050 },
|
|
816
|
+
{ band: 8, gain: 0.125 },
|
|
817
|
+
{ band: 9, gain: 0.250 },
|
|
818
|
+
{ band: 10, gain: 0.200 },
|
|
819
|
+
{ band: 11, gain: 0.250 },
|
|
820
|
+
{ band: 12, gain: 0.300 },
|
|
821
|
+
{ band: 13, gain: 0.250 },
|
|
822
|
+
{ band: 14, gain: 0.300 },
|
|
823
|
+
],
|
|
824
|
+
/** Makes the Music sound like Pop music / sound Pop music better */
|
|
825
|
+
Pop: [
|
|
826
|
+
{ band: 0, gain: 0.2635 },
|
|
827
|
+
{ band: 1, gain: 0.22141 },
|
|
828
|
+
{ band: 2, gain: -0.21141 },
|
|
829
|
+
{ band: 3, gain: -0.1851 },
|
|
830
|
+
{ band: 4, gain: -0.155 },
|
|
831
|
+
{ band: 5, gain: 0.21141 },
|
|
832
|
+
{ band: 6, gain: 0.22456 },
|
|
833
|
+
{ band: 7, gain: 0.237 },
|
|
834
|
+
{ band: 8, gain: 0.237 },
|
|
835
|
+
{ band: 9, gain: 0.237 },
|
|
836
|
+
{ band: 10, gain: -0.05 },
|
|
837
|
+
{ band: 11, gain: -0.116 },
|
|
838
|
+
{ band: 12, gain: 0.192 },
|
|
839
|
+
{ band: 13, gain: 0 },
|
|
840
|
+
],
|
|
841
|
+
/** Makes the Music sound like Electronic music / sound Electronic music better */
|
|
842
|
+
Electronic: [
|
|
843
|
+
{ band: 0, gain: 0.375 },
|
|
844
|
+
{ band: 1, gain: 0.350 },
|
|
845
|
+
{ band: 2, gain: 0.125 },
|
|
846
|
+
{ band: 3, gain: 0 },
|
|
847
|
+
{ band: 4, gain: 0 },
|
|
848
|
+
{ band: 5, gain: -0.125 },
|
|
849
|
+
{ band: 6, gain: -0.125 },
|
|
850
|
+
{ band: 7, gain: 0 },
|
|
851
|
+
{ band: 8, gain: 0.25 },
|
|
852
|
+
{ band: 9, gain: 0.125 },
|
|
853
|
+
{ band: 10, gain: 0.15 },
|
|
854
|
+
{ band: 11, gain: 0.2 },
|
|
855
|
+
{ band: 12, gain: 0.250 },
|
|
856
|
+
{ band: 13, gain: 0.350 },
|
|
857
|
+
{ band: 14, gain: 0.400 },
|
|
858
|
+
],
|
|
859
|
+
/** Boosts all Bands slightly for louder and fuller sound */
|
|
860
|
+
FullSound: [
|
|
861
|
+
{ band: 0, gain: 0.25 + 0.375 },
|
|
862
|
+
{ band: 1, gain: 0.25 + 0.025 },
|
|
863
|
+
{ band: 2, gain: 0.25 + 0.0125 },
|
|
864
|
+
{ band: 3, gain: 0.25 + 0 },
|
|
865
|
+
{ band: 4, gain: 0.25 + 0 },
|
|
866
|
+
{ band: 5, gain: 0.25 + -0.0125 },
|
|
867
|
+
{ band: 6, gain: 0.25 + -0.025 },
|
|
868
|
+
{ band: 7, gain: 0.25 + -0.0175 },
|
|
869
|
+
{ band: 8, gain: 0.25 + 0 },
|
|
870
|
+
{ band: 9, gain: 0.25 + 0 },
|
|
871
|
+
{ band: 10, gain: 0.25 + 0.0125 },
|
|
872
|
+
{ band: 11, gain: 0.25 + 0.025 },
|
|
873
|
+
{ band: 12, gain: 0.25 + 0.375 },
|
|
874
|
+
{ band: 13, gain: 0.25 + 0.125 },
|
|
875
|
+
{ band: 14, gain: 0.25 + 0.125 },
|
|
876
|
+
],
|
|
877
|
+
/** Boosts basses + lower highs for a pro gaming sound */
|
|
878
|
+
Gaming: [
|
|
879
|
+
{ band: 0, gain: 0.350 },
|
|
880
|
+
{ band: 1, gain: 0.300 },
|
|
881
|
+
{ band: 2, gain: 0.250 },
|
|
882
|
+
{ band: 3, gain: 0.200 },
|
|
883
|
+
{ band: 4, gain: 0.150 },
|
|
884
|
+
{ band: 5, gain: 0.100 },
|
|
885
|
+
{ band: 6, gain: 0.050 },
|
|
886
|
+
{ band: 7, gain: -0.0 },
|
|
887
|
+
{ band: 8, gain: -0.050 },
|
|
888
|
+
{ band: 9, gain: -0.100 },
|
|
889
|
+
{ band: 10, gain: -0.150 },
|
|
890
|
+
{ band: 11, gain: -0.200 },
|
|
891
|
+
{ band: 12, gain: -0.250 },
|
|
892
|
+
{ band: 13, gain: -0.300 },
|
|
893
|
+
{ band: 14, gain: -0.350 },
|
|
894
|
+
],
|
|
895
|
+
};
|