ziplayer 0.2.1 → 0.2.2
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/structures/FilterManager.d.ts.map +1 -1
- package/dist/structures/FilterManager.js +3 -1
- package/dist/structures/FilterManager.js.map +1 -1
- package/dist/structures/Player.d.ts +1 -2
- package/dist/structures/Player.d.ts.map +1 -1
- package/dist/structures/Player.js +29 -22
- package/dist/structures/Player.js.map +1 -1
- package/dist/types/extension.d.ts +114 -0
- package/dist/types/extension.d.ts.map +1 -0
- package/dist/types/extension.js +3 -0
- package/dist/types/extension.js.map +1 -0
- package/dist/types/fillter.d.ts +44 -0
- package/dist/types/fillter.d.ts.map +1 -0
- package/dist/types/fillter.js +226 -0
- package/dist/types/fillter.js.map +1 -0
- package/dist/types/index.d.ts +14 -209
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +17 -223
- package/dist/types/index.js.map +1 -1
- package/dist/types/plugin.d.ts +58 -0
- package/dist/types/plugin.d.ts.map +1 -0
- package/dist/types/plugin.js +21 -0
- package/dist/types/plugin.js.map +1 -0
- package/package.json +7 -2
- package/src/structures/FilterManager.ts +267 -262
- package/src/structures/Player.ts +36 -27
- package/src/types/extension.ts +129 -0
- package/src/types/fillter.ts +264 -0
- package/src/types/index.ts +15 -443
- package/src/types/plugin.ts +57 -0
- package/dist/plugins/SoundCloudPlugin.d.ts +0 -22
- package/dist/plugins/SoundCloudPlugin.d.ts.map +0 -1
- package/dist/plugins/SoundCloudPlugin.js +0 -171
- package/dist/plugins/SoundCloudPlugin.js.map +0 -1
- package/dist/plugins/SpotifyPlugin.d.ts +0 -26
- package/dist/plugins/SpotifyPlugin.d.ts.map +0 -1
- package/dist/plugins/SpotifyPlugin.js +0 -183
- package/dist/plugins/SpotifyPlugin.js.map +0 -1
- package/dist/plugins/YouTubePlugin.d.ts +0 -25
- package/dist/plugins/YouTubePlugin.d.ts.map +0 -1
- package/dist/plugins/YouTubePlugin.js +0 -314
- package/dist/plugins/YouTubePlugin.js.map +0 -1
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { VoiceConnection } from "@discordjs/voice";
|
|
2
|
+
import type { Player } from "../structures/Player";
|
|
3
|
+
import type { PlayerManager } from "../structures/PlayerManager";
|
|
4
|
+
import type { Track, SearchResult, StreamInfo } from ".";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Extension interface
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const extension: SourceExtension = {
|
|
11
|
+
* name: "YouTube",
|
|
12
|
+
* version: "1.0.0"
|
|
13
|
+
* };
|
|
14
|
+
*/
|
|
15
|
+
export interface SourceExtension {
|
|
16
|
+
name: string;
|
|
17
|
+
version: string;
|
|
18
|
+
connection?: VoiceConnection;
|
|
19
|
+
player: Player | null;
|
|
20
|
+
active(alas: any): boolean | Promise<boolean>;
|
|
21
|
+
onRegister?(context: ExtensionContext): void | Promise<void>;
|
|
22
|
+
onDestroy?(context: ExtensionContext): void | Promise<void>;
|
|
23
|
+
beforePlay?(
|
|
24
|
+
context: ExtensionContext,
|
|
25
|
+
payload: ExtensionPlayRequest,
|
|
26
|
+
): Promise<ExtensionPlayResponse | void> | ExtensionPlayResponse | void;
|
|
27
|
+
afterPlay?(context: ExtensionContext, payload: ExtensionAfterPlayPayload): Promise<void> | void;
|
|
28
|
+
provideSearch?(
|
|
29
|
+
context: ExtensionContext,
|
|
30
|
+
payload: ExtensionSearchRequest,
|
|
31
|
+
): Promise<SearchResult | null | undefined> | SearchResult | null | undefined;
|
|
32
|
+
provideStream?(
|
|
33
|
+
context: ExtensionContext,
|
|
34
|
+
payload: ExtensionStreamRequest,
|
|
35
|
+
): Promise<StreamInfo | null | undefined> | StreamInfo | null | undefined;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Context for the extension
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* const context: ExtensionContext = {
|
|
43
|
+
* player: player,
|
|
44
|
+
* manager: manager
|
|
45
|
+
* };
|
|
46
|
+
*/
|
|
47
|
+
export interface ExtensionContext {
|
|
48
|
+
player: Player;
|
|
49
|
+
manager: PlayerManager;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Request for the extension to play a track
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* const request: ExtensionPlayRequest = {
|
|
57
|
+
* query: "Song Name",
|
|
58
|
+
* requestedBy: "user123"
|
|
59
|
+
* };
|
|
60
|
+
*/
|
|
61
|
+
export interface ExtensionPlayRequest {
|
|
62
|
+
query: string | Track;
|
|
63
|
+
requestedBy?: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Response for the extension to play a track
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* const response: ExtensionPlayResponse = {
|
|
71
|
+
* handled: true,
|
|
72
|
+
* query: "Song Name",
|
|
73
|
+
* requestedBy: "user123"
|
|
74
|
+
* };
|
|
75
|
+
*/
|
|
76
|
+
export interface ExtensionPlayResponse {
|
|
77
|
+
handled?: boolean;
|
|
78
|
+
query?: string | Track;
|
|
79
|
+
requestedBy?: string;
|
|
80
|
+
tracks?: Track[];
|
|
81
|
+
isPlaylist?: boolean;
|
|
82
|
+
success?: boolean;
|
|
83
|
+
error?: Error;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Payload for the extension to play a track
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* const payload: ExtensionAfterPlayPayload = {
|
|
91
|
+
* success: true,
|
|
92
|
+
* query: "Song Name",
|
|
93
|
+
* requestedBy: "user123"
|
|
94
|
+
* };
|
|
95
|
+
*/
|
|
96
|
+
export interface ExtensionAfterPlayPayload {
|
|
97
|
+
success: boolean;
|
|
98
|
+
query: string | Track;
|
|
99
|
+
requestedBy?: string;
|
|
100
|
+
tracks?: Track[];
|
|
101
|
+
isPlaylist?: boolean;
|
|
102
|
+
error?: Error;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Request for the extension to stream a track
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* const request: ExtensionStreamRequest = {
|
|
110
|
+
* track: track
|
|
111
|
+
* };
|
|
112
|
+
*/
|
|
113
|
+
export interface ExtensionStreamRequest {
|
|
114
|
+
track: Track;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Request for the extension to search for a track
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* const request: ExtensionSearchRequest = {
|
|
122
|
+
* query: "Song Name",
|
|
123
|
+
* requestedBy: "user123"
|
|
124
|
+
* };
|
|
125
|
+
*/
|
|
126
|
+
export interface ExtensionSearchRequest {
|
|
127
|
+
query: string;
|
|
128
|
+
requestedBy: string;
|
|
129
|
+
}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audio filter configuration for applying effects to audio streams.
|
|
3
|
+
* Based on FFmpeg audio filters for Discord music bots.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* // Bass boost filter
|
|
7
|
+
* const bassFilter: AudioFilter = {
|
|
8
|
+
* name: "bassboost",
|
|
9
|
+
* ffmpegFilter: "bass=g=10:f=110:w=0.5",
|
|
10
|
+
* description: "Tăng âm trầm"
|
|
11
|
+
* };
|
|
12
|
+
*
|
|
13
|
+
* // Nightcore filter (speed + pitch)
|
|
14
|
+
* const nightcoreFilter: AudioFilter = {
|
|
15
|
+
* name: "nightcore",
|
|
16
|
+
* ffmpegFilter: "atempo=1.25,asetrate=44100*1.25",
|
|
17
|
+
* description: "Tăng tốc độ và cao độ"
|
|
18
|
+
* };
|
|
19
|
+
*
|
|
20
|
+
* // Custom filter
|
|
21
|
+
* const customFilter: AudioFilter = {
|
|
22
|
+
* name: "custom",
|
|
23
|
+
* ffmpegFilter: "volume=1.5,treble=g=5",
|
|
24
|
+
* description: "Tăng âm lượng và âm cao"
|
|
25
|
+
* };
|
|
26
|
+
*/
|
|
27
|
+
export interface AudioFilter {
|
|
28
|
+
/** Unique name identifier for the filter */
|
|
29
|
+
name: string;
|
|
30
|
+
/** FFmpeg audio filter string */
|
|
31
|
+
ffmpegFilter: string;
|
|
32
|
+
/** Human-readable description of the filter */
|
|
33
|
+
description: string;
|
|
34
|
+
/** Optional category for grouping filters */
|
|
35
|
+
category?: string;
|
|
36
|
+
/** Optional parameters for dynamic filter generation */
|
|
37
|
+
parameters?: Record<string, any>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Predefined audio filters commonly used in Discord music bots.
|
|
42
|
+
* These filters are based on popular FFmpeg audio filter combinations.
|
|
43
|
+
*/
|
|
44
|
+
export const PREDEFINED_FILTERS: Record<string, AudioFilter> = {
|
|
45
|
+
bassboost: {
|
|
46
|
+
name: "bassboost",
|
|
47
|
+
ffmpegFilter: "bass=g=10:f=110:w=0.5",
|
|
48
|
+
description: "Bass Boost",
|
|
49
|
+
category: "eq",
|
|
50
|
+
},
|
|
51
|
+
nightcore: {
|
|
52
|
+
name: "nightcore",
|
|
53
|
+
ffmpegFilter: "aresample=48000,asetrate=48000*1.5",
|
|
54
|
+
description: "Nightcore",
|
|
55
|
+
category: "speed",
|
|
56
|
+
},
|
|
57
|
+
karaoke: {
|
|
58
|
+
name: "karaoke",
|
|
59
|
+
ffmpegFilter: "stereotools=mlev=0.1",
|
|
60
|
+
description: "Karaoke",
|
|
61
|
+
category: "vocal",
|
|
62
|
+
},
|
|
63
|
+
lofi: {
|
|
64
|
+
name: "lofi",
|
|
65
|
+
ffmpegFilter: "aresample=48000,asetrate=48000*0.9,extrastereo=m=2.5:c=disabled",
|
|
66
|
+
description: "Lo-fi",
|
|
67
|
+
category: "speed",
|
|
68
|
+
},
|
|
69
|
+
"8D": {
|
|
70
|
+
name: "8D",
|
|
71
|
+
ffmpegFilter: "apulsator=hz=0.08",
|
|
72
|
+
description: "8D Effect",
|
|
73
|
+
category: "effect",
|
|
74
|
+
},
|
|
75
|
+
vaporwave: {
|
|
76
|
+
name: "vaporwave",
|
|
77
|
+
ffmpegFilter:
|
|
78
|
+
"highpass=f=50, lowpass=f=2750, aresample=48000, asetrate=48000*0.85,bass=g=5:f=110:w=0.6, compand=attacks=0:points=-80/-169|-54/-80|-49.5/-64.6|-41.1/-41.1|-25.8/-15|-10.8/-4.5|0/0|20/8.3",
|
|
79
|
+
description: "Vaporwave",
|
|
80
|
+
category: "speed",
|
|
81
|
+
},
|
|
82
|
+
bathroom: {
|
|
83
|
+
name: "bathroom",
|
|
84
|
+
ffmpegFilter:
|
|
85
|
+
"highpass=f=10, lowpass=f=400, aresample=44100, asetrate=44100*0.85,bass=g=4:f=110:w=0.6, alimiter=1, compand=attacks=0:points=-80/-169|-54/-80|-49.5/-64.6|-41.1/-41.1|-25.8/-15|-10.8/-4.5|0/0|20/8.3",
|
|
86
|
+
description: "Bathroom",
|
|
87
|
+
category: "speed",
|
|
88
|
+
},
|
|
89
|
+
expander: {
|
|
90
|
+
name: "expander",
|
|
91
|
+
ffmpegFilter: "compand=attacks=0:points=-80/-169|-54/-80|-49.5/-64.6|-41.1/-41.1|-25.8/-15|-10.8/-4.5|0/0|20/8.3",
|
|
92
|
+
description: "Expander",
|
|
93
|
+
category: "speed",
|
|
94
|
+
},
|
|
95
|
+
reverse: {
|
|
96
|
+
name: "reverse",
|
|
97
|
+
ffmpegFilter: "areverse",
|
|
98
|
+
description: "Reverse",
|
|
99
|
+
category: "effect",
|
|
100
|
+
},
|
|
101
|
+
echo: {
|
|
102
|
+
name: "echo",
|
|
103
|
+
ffmpegFilter: "aecho=0.8:0.88:60:0.4",
|
|
104
|
+
description: "Echo",
|
|
105
|
+
category: "effect",
|
|
106
|
+
},
|
|
107
|
+
trebleboost: {
|
|
108
|
+
name: "trebleboost",
|
|
109
|
+
ffmpegFilter: "treble=g=10:f=3000:w=0.5",
|
|
110
|
+
description: "Treble Boost",
|
|
111
|
+
category: "eq",
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
chorus: {
|
|
115
|
+
name: "chorus",
|
|
116
|
+
ffmpegFilter: "chorus=0.5:0.9:50:0.4:0.25:2",
|
|
117
|
+
description: "Chorus",
|
|
118
|
+
category: "effect",
|
|
119
|
+
},
|
|
120
|
+
flanger: {
|
|
121
|
+
name: "flanger",
|
|
122
|
+
ffmpegFilter: "flanger=delay=10:depth=2:regen=0:width=71:speed=0.5",
|
|
123
|
+
description: "Flanger",
|
|
124
|
+
category: "effect",
|
|
125
|
+
},
|
|
126
|
+
phaser: {
|
|
127
|
+
name: "phaser",
|
|
128
|
+
ffmpegFilter: "aphaser=in_gain=0.4:out_gain=0.74:delay=3.0:decay=0.4:speed=0.5",
|
|
129
|
+
description: "Phaser",
|
|
130
|
+
category: "effect",
|
|
131
|
+
},
|
|
132
|
+
tremolo: {
|
|
133
|
+
name: "tremolo",
|
|
134
|
+
ffmpegFilter: "tremolo=f=4.0:d=0.5",
|
|
135
|
+
description: "Tremolo",
|
|
136
|
+
category: "effect",
|
|
137
|
+
},
|
|
138
|
+
vibrato: {
|
|
139
|
+
name: "vibrato",
|
|
140
|
+
ffmpegFilter: "vibrato=f=5.5:d=0.5",
|
|
141
|
+
description: "Vibrato",
|
|
142
|
+
category: "effect",
|
|
143
|
+
},
|
|
144
|
+
normalize: {
|
|
145
|
+
name: "normalize",
|
|
146
|
+
ffmpegFilter: "loudnorm",
|
|
147
|
+
description: "Normalize",
|
|
148
|
+
category: "volume",
|
|
149
|
+
},
|
|
150
|
+
compressor: {
|
|
151
|
+
name: "compressor",
|
|
152
|
+
ffmpegFilter: "compand=points=-80/-105|-62/-80|-15.4/-15.4|0/-12|20/-7.6",
|
|
153
|
+
description: "Compressor",
|
|
154
|
+
category: "dynamics",
|
|
155
|
+
},
|
|
156
|
+
limiter: {
|
|
157
|
+
name: "limiter",
|
|
158
|
+
ffmpegFilter: "alimiter=level_in=1:level_out=0.8:limit=0.9",
|
|
159
|
+
description: "Limiter",
|
|
160
|
+
category: "dynamics",
|
|
161
|
+
},
|
|
162
|
+
gate: {
|
|
163
|
+
name: "gate",
|
|
164
|
+
ffmpegFilter: "agate=threshold=0.01:ratio=2:attack=1:release=100",
|
|
165
|
+
description: "Gate",
|
|
166
|
+
category: "dynamics",
|
|
167
|
+
},
|
|
168
|
+
lowpass: {
|
|
169
|
+
name: "lowpass",
|
|
170
|
+
ffmpegFilter: "lowpass=f=3000",
|
|
171
|
+
description: "Lowpass",
|
|
172
|
+
category: "filter",
|
|
173
|
+
},
|
|
174
|
+
highpass: {
|
|
175
|
+
name: "highpass",
|
|
176
|
+
ffmpegFilter: "highpass=f=200",
|
|
177
|
+
description: "Highpass",
|
|
178
|
+
category: "filter",
|
|
179
|
+
},
|
|
180
|
+
bandpass: {
|
|
181
|
+
name: "bandpass",
|
|
182
|
+
ffmpegFilter: "bandpass=f=1000:csg=1",
|
|
183
|
+
description: "Bandpass",
|
|
184
|
+
category: "filter",
|
|
185
|
+
},
|
|
186
|
+
allpass: {
|
|
187
|
+
name: "allpass",
|
|
188
|
+
ffmpegFilter: "allpass=f=1000:width_type=h:width=200",
|
|
189
|
+
description: "Allpass",
|
|
190
|
+
category: "filter",
|
|
191
|
+
},
|
|
192
|
+
equalizer: {
|
|
193
|
+
name: "equalizer",
|
|
194
|
+
ffmpegFilter: "equalizer=f=1000:width_type=h:width=200:g=5",
|
|
195
|
+
description: "Equalizer",
|
|
196
|
+
category: "eq",
|
|
197
|
+
},
|
|
198
|
+
reverb: {
|
|
199
|
+
name: "reverb",
|
|
200
|
+
ffmpegFilter: "aecho=0.8:0.88:60:0.4",
|
|
201
|
+
description: "Reverb",
|
|
202
|
+
category: "effect",
|
|
203
|
+
},
|
|
204
|
+
delay: {
|
|
205
|
+
name: "delay",
|
|
206
|
+
ffmpegFilter: "aecho=0.8:0.9:1000:0.3",
|
|
207
|
+
description: "Delay",
|
|
208
|
+
category: "effect",
|
|
209
|
+
},
|
|
210
|
+
distortion: {
|
|
211
|
+
name: "distortion",
|
|
212
|
+
ffmpegFilter: "acrusher=bits=8:mode=log:aa=1",
|
|
213
|
+
description: "Distortion",
|
|
214
|
+
category: "effect",
|
|
215
|
+
},
|
|
216
|
+
bitcrusher: {
|
|
217
|
+
name: "bitcrusher",
|
|
218
|
+
ffmpegFilter: "acrusher=bits=8:mode=log:aa=1",
|
|
219
|
+
description: "Bitcrusher",
|
|
220
|
+
category: "effect",
|
|
221
|
+
},
|
|
222
|
+
robot: {
|
|
223
|
+
name: "robot",
|
|
224
|
+
ffmpegFilter: "afftfilt=real='hypot(re,im)*sin(0)':imag='hypot(re,im)*cos(0)':win_size=512:overlap=0.75",
|
|
225
|
+
description: "Robot",
|
|
226
|
+
category: "vocal",
|
|
227
|
+
},
|
|
228
|
+
slow: {
|
|
229
|
+
name: "slow",
|
|
230
|
+
ffmpegFilter: "atempo=0.5",
|
|
231
|
+
description: "Slow",
|
|
232
|
+
category: "speed",
|
|
233
|
+
},
|
|
234
|
+
fast: {
|
|
235
|
+
name: "fast",
|
|
236
|
+
ffmpegFilter: "atempo=2.0",
|
|
237
|
+
description: "Fast",
|
|
238
|
+
category: "speed",
|
|
239
|
+
},
|
|
240
|
+
mono: {
|
|
241
|
+
name: "mono",
|
|
242
|
+
ffmpegFilter: "pan=mono|c0=0.5*c0+0.5*c1",
|
|
243
|
+
description: "Mono",
|
|
244
|
+
category: "channel",
|
|
245
|
+
},
|
|
246
|
+
stereo: {
|
|
247
|
+
name: "stereo",
|
|
248
|
+
ffmpegFilter: "pan=stereo|c0<c0+c1+c2+c3+c4+c5|c1<c0+c1+c2+c3+c4+c5",
|
|
249
|
+
description: "Stereo",
|
|
250
|
+
category: "channel",
|
|
251
|
+
},
|
|
252
|
+
haas: {
|
|
253
|
+
name: "haas",
|
|
254
|
+
ffmpegFilter: "haas",
|
|
255
|
+
description: "Haas",
|
|
256
|
+
category: "dynamics",
|
|
257
|
+
},
|
|
258
|
+
fadein: {
|
|
259
|
+
name: "fadein",
|
|
260
|
+
ffmpegFilter: "afade=t=in:ss=0:d=5",
|
|
261
|
+
description: "Fadein",
|
|
262
|
+
category: "effect",
|
|
263
|
+
},
|
|
264
|
+
};
|