@kattowo/distube 6.1.0 → 6.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +186 -2
- package/dist/index.d.ts +186 -2
- package/dist/index.js +419 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +414 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -321,6 +321,29 @@ type PreloadOptions = {
|
|
|
321
321
|
*/
|
|
322
322
|
threshold: number;
|
|
323
323
|
};
|
|
324
|
+
/**
|
|
325
|
+
* The validated {@link DisTubeOptions.crossfade} options of a {@link DisTube}
|
|
326
|
+
* instance.
|
|
327
|
+
*/
|
|
328
|
+
type CrossfadeOptions = {
|
|
329
|
+
/**
|
|
330
|
+
* The default crossfade duration (in seconds) applied to new queues. `0`
|
|
331
|
+
* disables the crossfade. A {@link Queue} can override it at runtime through
|
|
332
|
+
* its `crossfade` property.
|
|
333
|
+
*/
|
|
334
|
+
duration: number;
|
|
335
|
+
/**
|
|
336
|
+
* The FFmpeg `acrossfade` fade curve applied to both sides of the transition.
|
|
337
|
+
* @default "qsin" (equal-power)
|
|
338
|
+
*/
|
|
339
|
+
curve: string;
|
|
340
|
+
/**
|
|
341
|
+
* How long (in seconds) before the fade window begins the merged transition
|
|
342
|
+
* stream is spawned, so its buffers are warm and the fade starts on time.
|
|
343
|
+
* @default 5
|
|
344
|
+
*/
|
|
345
|
+
warmup: number;
|
|
346
|
+
};
|
|
324
347
|
/**
|
|
325
348
|
* DisTube options
|
|
326
349
|
*/
|
|
@@ -407,6 +430,39 @@ type DisTubeOptions = {
|
|
|
407
430
|
*/
|
|
408
431
|
threshold?: number;
|
|
409
432
|
};
|
|
433
|
+
/**
|
|
434
|
+
* Crossfade the end of the current song with the beginning of the next one,
|
|
435
|
+
* instead of a hard switch between two streams.
|
|
436
|
+
*
|
|
437
|
+
* The transition is a single FFmpeg process that mixes both songs with an
|
|
438
|
+
* `acrossfade` filter, so the fade is seamless (no gaps, no extra decode
|
|
439
|
+
* round-trips). Because the fade length must be prepared in advance, the
|
|
440
|
+
* next song's stream is resolved even when preloading is disabled.
|
|
441
|
+
*
|
|
442
|
+
* Can be an object to configure it:
|
|
443
|
+
* - `duration`: the default crossfade duration in seconds for new queues
|
|
444
|
+
* (@default 0). Each {@link Queue} can override it at runtime with its
|
|
445
|
+
* `crossfade` property, which is what bots typically bind to a guild
|
|
446
|
+
* setting.
|
|
447
|
+
* - `curve`: the FFmpeg `acrossfade` fade curve (@default "qsin")
|
|
448
|
+
* - `warmup`: seconds before the fade window when the transition stream is
|
|
449
|
+
* spawned to warm up its buffers (@default 5)
|
|
450
|
+
* @default { duration: 0, curve: "qsin", warmup: 5 }
|
|
451
|
+
*/
|
|
452
|
+
crossfade?: {
|
|
453
|
+
/**
|
|
454
|
+
* The default crossfade duration (in seconds) for new queues (0 disables).
|
|
455
|
+
*/
|
|
456
|
+
duration?: number;
|
|
457
|
+
/**
|
|
458
|
+
* The FFmpeg `acrossfade` fade curve applied to both songs.
|
|
459
|
+
*/
|
|
460
|
+
curve?: string;
|
|
461
|
+
/**
|
|
462
|
+
* Seconds before the fade window when the transition stream is spawned.
|
|
463
|
+
*/
|
|
464
|
+
warmup?: number;
|
|
465
|
+
};
|
|
410
466
|
/**
|
|
411
467
|
* FFmpeg options
|
|
412
468
|
*/
|
|
@@ -849,6 +905,32 @@ declare const defaultFilters: Filters;
|
|
|
849
905
|
* Default number of seconds remaining in the currently playing song before preloading starts.
|
|
850
906
|
*/
|
|
851
907
|
declare const DEFAULT_PRELOAD_THRESHOLD_SECS = 15;
|
|
908
|
+
/**
|
|
909
|
+
* Default crossfade duration in seconds for a {@link Queue} (0 disables the crossfade).
|
|
910
|
+
*/
|
|
911
|
+
declare const DEFAULT_CROSSFADE_DURATION_SECS = 0;
|
|
912
|
+
/**
|
|
913
|
+
* Maximum crossfade duration in seconds a {@link Queue} may request.
|
|
914
|
+
*/
|
|
915
|
+
declare const MAX_CROSSFADE_DURATION_SECS = 12;
|
|
916
|
+
/**
|
|
917
|
+
* Default FFmpeg `acrossfade` fade curve of the crossfade transition.
|
|
918
|
+
*
|
|
919
|
+
* `qsin` is an equal-power curve: the two songs mix without the -3dB dip of a
|
|
920
|
+
* linear (triangular) curve.
|
|
921
|
+
*/
|
|
922
|
+
declare const DEFAULT_CROSSFADE_CURVE = "qsin";
|
|
923
|
+
/**
|
|
924
|
+
* Default number of seconds before the fade window when the merged crossfade
|
|
925
|
+
* transition stream is spawned to warm up its buffers.
|
|
926
|
+
*/
|
|
927
|
+
declare const DEFAULT_CROSSFADE_WARMUP_SECS = 5;
|
|
928
|
+
/**
|
|
929
|
+
* How far (in seconds) the playback position may drift from the expected
|
|
930
|
+
* crossfade boundary before the transition is aborted and the regular
|
|
931
|
+
* song-switch takes over.
|
|
932
|
+
*/
|
|
933
|
+
declare const CROSSFADE_DRIFT_TOLERANCE_SECS = 0.75;
|
|
852
934
|
/**
|
|
853
935
|
* The default options of a {@link DisTube} instance.
|
|
854
936
|
*
|
|
@@ -866,6 +948,11 @@ declare const defaultOptions: {
|
|
|
866
948
|
unhandledError: "log";
|
|
867
949
|
stuckThreshold: number;
|
|
868
950
|
preload: false;
|
|
951
|
+
crossfade: {
|
|
952
|
+
duration: number;
|
|
953
|
+
curve: string;
|
|
954
|
+
warmup: number;
|
|
955
|
+
};
|
|
869
956
|
};
|
|
870
957
|
|
|
871
958
|
/**
|
|
@@ -1253,6 +1340,11 @@ declare class Options {
|
|
|
1253
1340
|
* @default { enabled: false, threshold: 15 }
|
|
1254
1341
|
*/
|
|
1255
1342
|
preload: PreloadOptions;
|
|
1343
|
+
/**
|
|
1344
|
+
* The crossfade options of the DisTube instance.
|
|
1345
|
+
* @default { duration: 0, curve: "qsin", warmup: 5 }
|
|
1346
|
+
*/
|
|
1347
|
+
crossfade: CrossfadeOptions;
|
|
1256
1348
|
/**
|
|
1257
1349
|
* The FFmpeg options of the DisTube instance.
|
|
1258
1350
|
*/
|
|
@@ -1279,6 +1371,43 @@ interface StreamOptions {
|
|
|
1279
1371
|
* @default 0
|
|
1280
1372
|
*/
|
|
1281
1373
|
seek?: number;
|
|
1374
|
+
/**
|
|
1375
|
+
* Crossfade transition options.
|
|
1376
|
+
*
|
|
1377
|
+
* When set, the stream mixes the primary URL (the song that is fading out,
|
|
1378
|
+
* seeked to its final `duration` seconds) and the secondary URL (the song
|
|
1379
|
+
* that is fading in) with an FFmpeg `acrossfade` filter graph, so the two
|
|
1380
|
+
* songs crossfade seamlessly in a single FFmpeg process.
|
|
1381
|
+
*/
|
|
1382
|
+
crossfade?: CrossfadeStreamOptions;
|
|
1383
|
+
}
|
|
1384
|
+
/**
|
|
1385
|
+
* Options describing a crossfade transition stream
|
|
1386
|
+
*/
|
|
1387
|
+
interface CrossfadeStreamOptions {
|
|
1388
|
+
/**
|
|
1389
|
+
* The fade duration in seconds.
|
|
1390
|
+
*/
|
|
1391
|
+
duration: number;
|
|
1392
|
+
/**
|
|
1393
|
+
* The initial seek of the first (fading out) input, in seconds. It must be
|
|
1394
|
+
* the position where the fade window begins (`song duration - duration`).
|
|
1395
|
+
*/
|
|
1396
|
+
primarySeek: number;
|
|
1397
|
+
/**
|
|
1398
|
+
* The stream URL of the second (fading in) input.
|
|
1399
|
+
*/
|
|
1400
|
+
secondaryUrl: string;
|
|
1401
|
+
/**
|
|
1402
|
+
* The FFmpeg `acrossfade` fade curve of the first (fading out) input.
|
|
1403
|
+
* @default "qsin"
|
|
1404
|
+
*/
|
|
1405
|
+
outCurve?: string;
|
|
1406
|
+
/**
|
|
1407
|
+
* The FFmpeg `acrossfade` fade curve of the second (fading in) input.
|
|
1408
|
+
* @default "qsin"
|
|
1409
|
+
*/
|
|
1410
|
+
inCurve?: string;
|
|
1282
1411
|
}
|
|
1283
1412
|
/**
|
|
1284
1413
|
* Check that FFmpeg is installed and can be spawned.
|
|
@@ -1315,6 +1444,15 @@ declare class DisTubeStream extends TypedEmitter<{
|
|
|
1315
1444
|
* The seek time in seconds that this stream started from
|
|
1316
1445
|
*/
|
|
1317
1446
|
readonly seekTime: number;
|
|
1447
|
+
/**
|
|
1448
|
+
* Whether FFmpeg has already produced audio that is waiting to be read.
|
|
1449
|
+
*
|
|
1450
|
+
* The stream is spawned ahead of the playback (crossfade warmup) and the
|
|
1451
|
+
* pipe backs up once its buffers are full, so this is `true` as soon as the
|
|
1452
|
+
* first frame exists. A stream that is still `false` at playback time would
|
|
1453
|
+
* leave the audio player buffering until FFmpeg catches up.
|
|
1454
|
+
*/
|
|
1455
|
+
get hasBufferedAudio(): boolean;
|
|
1318
1456
|
/**
|
|
1319
1457
|
* Create a DisTubeStream to play with {@link DisTubeVoice}
|
|
1320
1458
|
* @param url - Stream URL
|
|
@@ -1628,6 +1766,16 @@ declare class QueueManager extends GuildIdManager<Queue> {
|
|
|
1628
1766
|
* @param queue - The guild queue
|
|
1629
1767
|
*/
|
|
1630
1768
|
preloadNextSong(queue: Queue): Promise<void>;
|
|
1769
|
+
/**
|
|
1770
|
+
* Schedule the crossfade into the next song: a single FFmpeg process mixes
|
|
1771
|
+
* the current song (seeked to its final fade window) with the next song, and
|
|
1772
|
+
* replaces the playback stream exactly when the fade window begins.
|
|
1773
|
+
*
|
|
1774
|
+
* Canceled automatically whenever the preloaded state is invalidated
|
|
1775
|
+
* (pause, seek, stop...), as both schedulers share the same generation.
|
|
1776
|
+
* @param queue - The guild queue
|
|
1777
|
+
*/
|
|
1778
|
+
scheduleCrossfade(queue: Queue): void;
|
|
1631
1779
|
}
|
|
1632
1780
|
|
|
1633
1781
|
/**
|
|
@@ -2401,11 +2549,27 @@ declare class Queue extends DisTubeBase {
|
|
|
2401
2549
|
* @internal
|
|
2402
2550
|
*/
|
|
2403
2551
|
_preloadGeneration: number;
|
|
2552
|
+
/**
|
|
2553
|
+
* Crossfade boundary timer
|
|
2554
|
+
* @internal
|
|
2555
|
+
*/
|
|
2556
|
+
_crossfadeTimeout?: NodeJS.Timeout;
|
|
2557
|
+
/**
|
|
2558
|
+
* The merged transition stream that is warming up before the fade window
|
|
2559
|
+
* starts
|
|
2560
|
+
* @internal
|
|
2561
|
+
*/
|
|
2562
|
+
_crossfadeWarmup?: DisTubeStream;
|
|
2404
2563
|
/**
|
|
2405
2564
|
* Clear any preloaded song and cancel pending preload timer.
|
|
2406
2565
|
* @internal
|
|
2407
2566
|
*/
|
|
2408
2567
|
_clearPreload(): void;
|
|
2568
|
+
/**
|
|
2569
|
+
* Cancel a pending crossfade and kill its warming-up transition stream.
|
|
2570
|
+
* @internal
|
|
2571
|
+
*/
|
|
2572
|
+
_crossfadeCancel(): void;
|
|
2409
2573
|
/**
|
|
2410
2574
|
* Create a queue for the guild
|
|
2411
2575
|
* @param distube - DisTube
|
|
@@ -2440,6 +2604,17 @@ declare class Queue extends DisTubeBase {
|
|
|
2440
2604
|
* What time in the song is playing (in seconds).
|
|
2441
2605
|
*/
|
|
2442
2606
|
get currentTime(): number;
|
|
2607
|
+
/**
|
|
2608
|
+
* The crossfade duration (in seconds) between this song and the next one.
|
|
2609
|
+
*
|
|
2610
|
+
* `0` (the default) disables the crossfade. Changing it takes effect for the
|
|
2611
|
+
* next transition; call {@link Queue#scheduleCrossfade} to re-arm the
|
|
2612
|
+
* transition for the currently playing song immediately.
|
|
2613
|
+
* @throws {@link DisTubeError} When the value is not a number between `0`
|
|
2614
|
+
* and the maximum crossfade duration
|
|
2615
|
+
*/
|
|
2616
|
+
get crossfade(): number;
|
|
2617
|
+
set crossfade(value: number);
|
|
2443
2618
|
/**
|
|
2444
2619
|
* Formatted {@link Queue#currentTime} string.
|
|
2445
2620
|
*/
|
|
@@ -2598,6 +2773,15 @@ declare class Queue extends DisTubeBase {
|
|
|
2598
2773
|
* @throws {@link DisTubeError} When the queue has been stopped
|
|
2599
2774
|
*/
|
|
2600
2775
|
play(emitPlaySong?: boolean): Promise<void>;
|
|
2776
|
+
/**
|
|
2777
|
+
* Re-arm the crossfade into the next song for the currently playing one.
|
|
2778
|
+
*
|
|
2779
|
+
* Useful after changing {@link Queue#crossfade} while a song is playing: the
|
|
2780
|
+
* fade may still fit into the remaining time. This is called automatically
|
|
2781
|
+
* after every song switch.
|
|
2782
|
+
* @returns Nothing
|
|
2783
|
+
*/
|
|
2784
|
+
scheduleCrossfade(): void;
|
|
2601
2785
|
/**
|
|
2602
2786
|
* Restart the current stream with the current FFmpeg arguments, keeping the
|
|
2603
2787
|
* playback position.
|
|
@@ -3438,5 +3622,5 @@ declare function handleUnhandledError(error: Error, behavior?: UnhandledErrorBeh
|
|
|
3438
3622
|
*/
|
|
3439
3623
|
declare const checkEncryptionLibraries: () => Promise<boolean>;
|
|
3440
3624
|
|
|
3441
|
-
export { AUDIO_CHANNELS, AUDIO_SAMPLE_RATE, BaseManager, DEFAULT_PRELOAD_THRESHOLD_SECS, DEFAULT_VOLUME, DisTube, DisTubeBase, DisTubeError, DisTubeHandler, DisTubeStream, DisTubeVoice, DisTubeVoiceManager, Events, ExtractorPlugin, FilterManager, GuildIdManager, HTTP_REDIRECT_CODES, InfoExtractorPlugin, JOIN_TIMEOUT_MS, MAX_REDIRECT_DEPTH, Options, PlayableExtractorPlugin, Playlist, Plugin, PluginError, PluginErrorCode, PluginType, Queue, QueueManager, RECONNECT_MAX_ATTEMPTS, RECONNECT_TIMEOUT_MS, RepeatMode, STUCK_THRESHOLD_MS, SearchResult, SearchResultType, Song, StreamServer, TaskQueue, checkEncryptionLibraries, checkFFmpeg, checkIntents, checkInvalidKey, DisTube as default, defaultFilters, defaultOptions, formatDuration, handleUnhandledError, isClientInstance, isGuildInstance, isMemberInstance, isMessageInstance, isNsfwChannel, isObject, isSnowflake, isSupportedVoiceChannel, isTextChannelInstance, isTruthy, isURL, isVoiceChannelEmpty, objectKeys, resolveGuildId, version };
|
|
3442
|
-
export type { Awaitable, CustomPlaylistOptions, DisTubeEvents, DisTubeOptions, DisTubePlugin, DisTubeVoiceEvents, Disposable, FFmpegArg, FFmpegArgs, FFmpegOptions, Falsy, Filter, FilterResolvable, Filters, GuildIdResolvable, JumpOptions, KeyOf, PlayHandlerOptions, PlayOptions, PlaylistInfo, PreloadOptions, RelatedSong, ResolveOptions, ResolvePlaylistOptions, SearchOptions, SongInfo, StreamHandler, StreamOptions, StreamRequest, StreamResponse, StreamServerOptions, TypedDisTubeEvents, UnhandledErrorBehavior };
|
|
3625
|
+
export { AUDIO_CHANNELS, AUDIO_SAMPLE_RATE, BaseManager, CROSSFADE_DRIFT_TOLERANCE_SECS, DEFAULT_CROSSFADE_CURVE, DEFAULT_CROSSFADE_DURATION_SECS, DEFAULT_CROSSFADE_WARMUP_SECS, DEFAULT_PRELOAD_THRESHOLD_SECS, DEFAULT_VOLUME, DisTube, DisTubeBase, DisTubeError, DisTubeHandler, DisTubeStream, DisTubeVoice, DisTubeVoiceManager, Events, ExtractorPlugin, FilterManager, GuildIdManager, HTTP_REDIRECT_CODES, InfoExtractorPlugin, JOIN_TIMEOUT_MS, MAX_CROSSFADE_DURATION_SECS, MAX_REDIRECT_DEPTH, Options, PlayableExtractorPlugin, Playlist, Plugin, PluginError, PluginErrorCode, PluginType, Queue, QueueManager, RECONNECT_MAX_ATTEMPTS, RECONNECT_TIMEOUT_MS, RepeatMode, STUCK_THRESHOLD_MS, SearchResult, SearchResultType, Song, StreamServer, TaskQueue, checkEncryptionLibraries, checkFFmpeg, checkIntents, checkInvalidKey, DisTube as default, defaultFilters, defaultOptions, formatDuration, handleUnhandledError, isClientInstance, isGuildInstance, isMemberInstance, isMessageInstance, isNsfwChannel, isObject, isSnowflake, isSupportedVoiceChannel, isTextChannelInstance, isTruthy, isURL, isVoiceChannelEmpty, objectKeys, resolveGuildId, version };
|
|
3626
|
+
export type { Awaitable, CrossfadeOptions, CrossfadeStreamOptions, CustomPlaylistOptions, DisTubeEvents, DisTubeOptions, DisTubePlugin, DisTubeVoiceEvents, Disposable, FFmpegArg, FFmpegArgs, FFmpegOptions, Falsy, Filter, FilterResolvable, Filters, GuildIdResolvable, JumpOptions, KeyOf, PlayHandlerOptions, PlayOptions, PlaylistInfo, PreloadOptions, RelatedSong, ResolveOptions, ResolvePlaylistOptions, SearchOptions, SongInfo, StreamHandler, StreamOptions, StreamRequest, StreamResponse, StreamServerOptions, TypedDisTubeEvents, UnhandledErrorBehavior };
|
package/dist/index.d.ts
CHANGED
|
@@ -321,6 +321,29 @@ type PreloadOptions = {
|
|
|
321
321
|
*/
|
|
322
322
|
threshold: number;
|
|
323
323
|
};
|
|
324
|
+
/**
|
|
325
|
+
* The validated {@link DisTubeOptions.crossfade} options of a {@link DisTube}
|
|
326
|
+
* instance.
|
|
327
|
+
*/
|
|
328
|
+
type CrossfadeOptions = {
|
|
329
|
+
/**
|
|
330
|
+
* The default crossfade duration (in seconds) applied to new queues. `0`
|
|
331
|
+
* disables the crossfade. A {@link Queue} can override it at runtime through
|
|
332
|
+
* its `crossfade` property.
|
|
333
|
+
*/
|
|
334
|
+
duration: number;
|
|
335
|
+
/**
|
|
336
|
+
* The FFmpeg `acrossfade` fade curve applied to both sides of the transition.
|
|
337
|
+
* @default "qsin" (equal-power)
|
|
338
|
+
*/
|
|
339
|
+
curve: string;
|
|
340
|
+
/**
|
|
341
|
+
* How long (in seconds) before the fade window begins the merged transition
|
|
342
|
+
* stream is spawned, so its buffers are warm and the fade starts on time.
|
|
343
|
+
* @default 5
|
|
344
|
+
*/
|
|
345
|
+
warmup: number;
|
|
346
|
+
};
|
|
324
347
|
/**
|
|
325
348
|
* DisTube options
|
|
326
349
|
*/
|
|
@@ -407,6 +430,39 @@ type DisTubeOptions = {
|
|
|
407
430
|
*/
|
|
408
431
|
threshold?: number;
|
|
409
432
|
};
|
|
433
|
+
/**
|
|
434
|
+
* Crossfade the end of the current song with the beginning of the next one,
|
|
435
|
+
* instead of a hard switch between two streams.
|
|
436
|
+
*
|
|
437
|
+
* The transition is a single FFmpeg process that mixes both songs with an
|
|
438
|
+
* `acrossfade` filter, so the fade is seamless (no gaps, no extra decode
|
|
439
|
+
* round-trips). Because the fade length must be prepared in advance, the
|
|
440
|
+
* next song's stream is resolved even when preloading is disabled.
|
|
441
|
+
*
|
|
442
|
+
* Can be an object to configure it:
|
|
443
|
+
* - `duration`: the default crossfade duration in seconds for new queues
|
|
444
|
+
* (@default 0). Each {@link Queue} can override it at runtime with its
|
|
445
|
+
* `crossfade` property, which is what bots typically bind to a guild
|
|
446
|
+
* setting.
|
|
447
|
+
* - `curve`: the FFmpeg `acrossfade` fade curve (@default "qsin")
|
|
448
|
+
* - `warmup`: seconds before the fade window when the transition stream is
|
|
449
|
+
* spawned to warm up its buffers (@default 5)
|
|
450
|
+
* @default { duration: 0, curve: "qsin", warmup: 5 }
|
|
451
|
+
*/
|
|
452
|
+
crossfade?: {
|
|
453
|
+
/**
|
|
454
|
+
* The default crossfade duration (in seconds) for new queues (0 disables).
|
|
455
|
+
*/
|
|
456
|
+
duration?: number;
|
|
457
|
+
/**
|
|
458
|
+
* The FFmpeg `acrossfade` fade curve applied to both songs.
|
|
459
|
+
*/
|
|
460
|
+
curve?: string;
|
|
461
|
+
/**
|
|
462
|
+
* Seconds before the fade window when the transition stream is spawned.
|
|
463
|
+
*/
|
|
464
|
+
warmup?: number;
|
|
465
|
+
};
|
|
410
466
|
/**
|
|
411
467
|
* FFmpeg options
|
|
412
468
|
*/
|
|
@@ -849,6 +905,32 @@ declare const defaultFilters: Filters;
|
|
|
849
905
|
* Default number of seconds remaining in the currently playing song before preloading starts.
|
|
850
906
|
*/
|
|
851
907
|
declare const DEFAULT_PRELOAD_THRESHOLD_SECS = 15;
|
|
908
|
+
/**
|
|
909
|
+
* Default crossfade duration in seconds for a {@link Queue} (0 disables the crossfade).
|
|
910
|
+
*/
|
|
911
|
+
declare const DEFAULT_CROSSFADE_DURATION_SECS = 0;
|
|
912
|
+
/**
|
|
913
|
+
* Maximum crossfade duration in seconds a {@link Queue} may request.
|
|
914
|
+
*/
|
|
915
|
+
declare const MAX_CROSSFADE_DURATION_SECS = 12;
|
|
916
|
+
/**
|
|
917
|
+
* Default FFmpeg `acrossfade` fade curve of the crossfade transition.
|
|
918
|
+
*
|
|
919
|
+
* `qsin` is an equal-power curve: the two songs mix without the -3dB dip of a
|
|
920
|
+
* linear (triangular) curve.
|
|
921
|
+
*/
|
|
922
|
+
declare const DEFAULT_CROSSFADE_CURVE = "qsin";
|
|
923
|
+
/**
|
|
924
|
+
* Default number of seconds before the fade window when the merged crossfade
|
|
925
|
+
* transition stream is spawned to warm up its buffers.
|
|
926
|
+
*/
|
|
927
|
+
declare const DEFAULT_CROSSFADE_WARMUP_SECS = 5;
|
|
928
|
+
/**
|
|
929
|
+
* How far (in seconds) the playback position may drift from the expected
|
|
930
|
+
* crossfade boundary before the transition is aborted and the regular
|
|
931
|
+
* song-switch takes over.
|
|
932
|
+
*/
|
|
933
|
+
declare const CROSSFADE_DRIFT_TOLERANCE_SECS = 0.75;
|
|
852
934
|
/**
|
|
853
935
|
* The default options of a {@link DisTube} instance.
|
|
854
936
|
*
|
|
@@ -866,6 +948,11 @@ declare const defaultOptions: {
|
|
|
866
948
|
unhandledError: "log";
|
|
867
949
|
stuckThreshold: number;
|
|
868
950
|
preload: false;
|
|
951
|
+
crossfade: {
|
|
952
|
+
duration: number;
|
|
953
|
+
curve: string;
|
|
954
|
+
warmup: number;
|
|
955
|
+
};
|
|
869
956
|
};
|
|
870
957
|
|
|
871
958
|
/**
|
|
@@ -1253,6 +1340,11 @@ declare class Options {
|
|
|
1253
1340
|
* @default { enabled: false, threshold: 15 }
|
|
1254
1341
|
*/
|
|
1255
1342
|
preload: PreloadOptions;
|
|
1343
|
+
/**
|
|
1344
|
+
* The crossfade options of the DisTube instance.
|
|
1345
|
+
* @default { duration: 0, curve: "qsin", warmup: 5 }
|
|
1346
|
+
*/
|
|
1347
|
+
crossfade: CrossfadeOptions;
|
|
1256
1348
|
/**
|
|
1257
1349
|
* The FFmpeg options of the DisTube instance.
|
|
1258
1350
|
*/
|
|
@@ -1279,6 +1371,43 @@ interface StreamOptions {
|
|
|
1279
1371
|
* @default 0
|
|
1280
1372
|
*/
|
|
1281
1373
|
seek?: number;
|
|
1374
|
+
/**
|
|
1375
|
+
* Crossfade transition options.
|
|
1376
|
+
*
|
|
1377
|
+
* When set, the stream mixes the primary URL (the song that is fading out,
|
|
1378
|
+
* seeked to its final `duration` seconds) and the secondary URL (the song
|
|
1379
|
+
* that is fading in) with an FFmpeg `acrossfade` filter graph, so the two
|
|
1380
|
+
* songs crossfade seamlessly in a single FFmpeg process.
|
|
1381
|
+
*/
|
|
1382
|
+
crossfade?: CrossfadeStreamOptions;
|
|
1383
|
+
}
|
|
1384
|
+
/**
|
|
1385
|
+
* Options describing a crossfade transition stream
|
|
1386
|
+
*/
|
|
1387
|
+
interface CrossfadeStreamOptions {
|
|
1388
|
+
/**
|
|
1389
|
+
* The fade duration in seconds.
|
|
1390
|
+
*/
|
|
1391
|
+
duration: number;
|
|
1392
|
+
/**
|
|
1393
|
+
* The initial seek of the first (fading out) input, in seconds. It must be
|
|
1394
|
+
* the position where the fade window begins (`song duration - duration`).
|
|
1395
|
+
*/
|
|
1396
|
+
primarySeek: number;
|
|
1397
|
+
/**
|
|
1398
|
+
* The stream URL of the second (fading in) input.
|
|
1399
|
+
*/
|
|
1400
|
+
secondaryUrl: string;
|
|
1401
|
+
/**
|
|
1402
|
+
* The FFmpeg `acrossfade` fade curve of the first (fading out) input.
|
|
1403
|
+
* @default "qsin"
|
|
1404
|
+
*/
|
|
1405
|
+
outCurve?: string;
|
|
1406
|
+
/**
|
|
1407
|
+
* The FFmpeg `acrossfade` fade curve of the second (fading in) input.
|
|
1408
|
+
* @default "qsin"
|
|
1409
|
+
*/
|
|
1410
|
+
inCurve?: string;
|
|
1282
1411
|
}
|
|
1283
1412
|
/**
|
|
1284
1413
|
* Check that FFmpeg is installed and can be spawned.
|
|
@@ -1315,6 +1444,15 @@ declare class DisTubeStream extends TypedEmitter<{
|
|
|
1315
1444
|
* The seek time in seconds that this stream started from
|
|
1316
1445
|
*/
|
|
1317
1446
|
readonly seekTime: number;
|
|
1447
|
+
/**
|
|
1448
|
+
* Whether FFmpeg has already produced audio that is waiting to be read.
|
|
1449
|
+
*
|
|
1450
|
+
* The stream is spawned ahead of the playback (crossfade warmup) and the
|
|
1451
|
+
* pipe backs up once its buffers are full, so this is `true` as soon as the
|
|
1452
|
+
* first frame exists. A stream that is still `false` at playback time would
|
|
1453
|
+
* leave the audio player buffering until FFmpeg catches up.
|
|
1454
|
+
*/
|
|
1455
|
+
get hasBufferedAudio(): boolean;
|
|
1318
1456
|
/**
|
|
1319
1457
|
* Create a DisTubeStream to play with {@link DisTubeVoice}
|
|
1320
1458
|
* @param url - Stream URL
|
|
@@ -1628,6 +1766,16 @@ declare class QueueManager extends GuildIdManager<Queue> {
|
|
|
1628
1766
|
* @param queue - The guild queue
|
|
1629
1767
|
*/
|
|
1630
1768
|
preloadNextSong(queue: Queue): Promise<void>;
|
|
1769
|
+
/**
|
|
1770
|
+
* Schedule the crossfade into the next song: a single FFmpeg process mixes
|
|
1771
|
+
* the current song (seeked to its final fade window) with the next song, and
|
|
1772
|
+
* replaces the playback stream exactly when the fade window begins.
|
|
1773
|
+
*
|
|
1774
|
+
* Canceled automatically whenever the preloaded state is invalidated
|
|
1775
|
+
* (pause, seek, stop...), as both schedulers share the same generation.
|
|
1776
|
+
* @param queue - The guild queue
|
|
1777
|
+
*/
|
|
1778
|
+
scheduleCrossfade(queue: Queue): void;
|
|
1631
1779
|
}
|
|
1632
1780
|
|
|
1633
1781
|
/**
|
|
@@ -2401,11 +2549,27 @@ declare class Queue extends DisTubeBase {
|
|
|
2401
2549
|
* @internal
|
|
2402
2550
|
*/
|
|
2403
2551
|
_preloadGeneration: number;
|
|
2552
|
+
/**
|
|
2553
|
+
* Crossfade boundary timer
|
|
2554
|
+
* @internal
|
|
2555
|
+
*/
|
|
2556
|
+
_crossfadeTimeout?: NodeJS.Timeout;
|
|
2557
|
+
/**
|
|
2558
|
+
* The merged transition stream that is warming up before the fade window
|
|
2559
|
+
* starts
|
|
2560
|
+
* @internal
|
|
2561
|
+
*/
|
|
2562
|
+
_crossfadeWarmup?: DisTubeStream;
|
|
2404
2563
|
/**
|
|
2405
2564
|
* Clear any preloaded song and cancel pending preload timer.
|
|
2406
2565
|
* @internal
|
|
2407
2566
|
*/
|
|
2408
2567
|
_clearPreload(): void;
|
|
2568
|
+
/**
|
|
2569
|
+
* Cancel a pending crossfade and kill its warming-up transition stream.
|
|
2570
|
+
* @internal
|
|
2571
|
+
*/
|
|
2572
|
+
_crossfadeCancel(): void;
|
|
2409
2573
|
/**
|
|
2410
2574
|
* Create a queue for the guild
|
|
2411
2575
|
* @param distube - DisTube
|
|
@@ -2440,6 +2604,17 @@ declare class Queue extends DisTubeBase {
|
|
|
2440
2604
|
* What time in the song is playing (in seconds).
|
|
2441
2605
|
*/
|
|
2442
2606
|
get currentTime(): number;
|
|
2607
|
+
/**
|
|
2608
|
+
* The crossfade duration (in seconds) between this song and the next one.
|
|
2609
|
+
*
|
|
2610
|
+
* `0` (the default) disables the crossfade. Changing it takes effect for the
|
|
2611
|
+
* next transition; call {@link Queue#scheduleCrossfade} to re-arm the
|
|
2612
|
+
* transition for the currently playing song immediately.
|
|
2613
|
+
* @throws {@link DisTubeError} When the value is not a number between `0`
|
|
2614
|
+
* and the maximum crossfade duration
|
|
2615
|
+
*/
|
|
2616
|
+
get crossfade(): number;
|
|
2617
|
+
set crossfade(value: number);
|
|
2443
2618
|
/**
|
|
2444
2619
|
* Formatted {@link Queue#currentTime} string.
|
|
2445
2620
|
*/
|
|
@@ -2598,6 +2773,15 @@ declare class Queue extends DisTubeBase {
|
|
|
2598
2773
|
* @throws {@link DisTubeError} When the queue has been stopped
|
|
2599
2774
|
*/
|
|
2600
2775
|
play(emitPlaySong?: boolean): Promise<void>;
|
|
2776
|
+
/**
|
|
2777
|
+
* Re-arm the crossfade into the next song for the currently playing one.
|
|
2778
|
+
*
|
|
2779
|
+
* Useful after changing {@link Queue#crossfade} while a song is playing: the
|
|
2780
|
+
* fade may still fit into the remaining time. This is called automatically
|
|
2781
|
+
* after every song switch.
|
|
2782
|
+
* @returns Nothing
|
|
2783
|
+
*/
|
|
2784
|
+
scheduleCrossfade(): void;
|
|
2601
2785
|
/**
|
|
2602
2786
|
* Restart the current stream with the current FFmpeg arguments, keeping the
|
|
2603
2787
|
* playback position.
|
|
@@ -3440,5 +3624,5 @@ declare const checkEncryptionLibraries: () => Promise<boolean>;
|
|
|
3440
3624
|
|
|
3441
3625
|
// @ts-ignore
|
|
3442
3626
|
export = DisTube;
|
|
3443
|
-
export { AUDIO_CHANNELS, AUDIO_SAMPLE_RATE, BaseManager, DEFAULT_PRELOAD_THRESHOLD_SECS, DEFAULT_VOLUME, DisTube, DisTubeBase, DisTubeError, DisTubeHandler, DisTubeStream, DisTubeVoice, DisTubeVoiceManager, Events, ExtractorPlugin, FilterManager, GuildIdManager, HTTP_REDIRECT_CODES, InfoExtractorPlugin, JOIN_TIMEOUT_MS, MAX_REDIRECT_DEPTH, Options, PlayableExtractorPlugin, Playlist, Plugin, PluginError, PluginErrorCode, PluginType, Queue, QueueManager, RECONNECT_MAX_ATTEMPTS, RECONNECT_TIMEOUT_MS, RepeatMode, STUCK_THRESHOLD_MS, SearchResult, SearchResultType, Song, StreamServer, TaskQueue, checkEncryptionLibraries, checkFFmpeg, checkIntents, checkInvalidKey, defaultFilters, defaultOptions, formatDuration, handleUnhandledError, isClientInstance, isGuildInstance, isMemberInstance, isMessageInstance, isNsfwChannel, isObject, isSnowflake, isSupportedVoiceChannel, isTextChannelInstance, isTruthy, isURL, isVoiceChannelEmpty, objectKeys, resolveGuildId, version };
|
|
3444
|
-
export type { Awaitable, CustomPlaylistOptions, DisTubeEvents, DisTubeOptions, DisTubePlugin, DisTubeVoiceEvents, Disposable, FFmpegArg, FFmpegArgs, FFmpegOptions, Falsy, Filter, FilterResolvable, Filters, GuildIdResolvable, JumpOptions, KeyOf, PlayHandlerOptions, PlayOptions, PlaylistInfo, PreloadOptions, RelatedSong, ResolveOptions, ResolvePlaylistOptions, SearchOptions, SongInfo, StreamHandler, StreamOptions, StreamRequest, StreamResponse, StreamServerOptions, TypedDisTubeEvents, UnhandledErrorBehavior };
|
|
3627
|
+
export { AUDIO_CHANNELS, AUDIO_SAMPLE_RATE, BaseManager, CROSSFADE_DRIFT_TOLERANCE_SECS, DEFAULT_CROSSFADE_CURVE, DEFAULT_CROSSFADE_DURATION_SECS, DEFAULT_CROSSFADE_WARMUP_SECS, DEFAULT_PRELOAD_THRESHOLD_SECS, DEFAULT_VOLUME, DisTube, DisTubeBase, DisTubeError, DisTubeHandler, DisTubeStream, DisTubeVoice, DisTubeVoiceManager, Events, ExtractorPlugin, FilterManager, GuildIdManager, HTTP_REDIRECT_CODES, InfoExtractorPlugin, JOIN_TIMEOUT_MS, MAX_CROSSFADE_DURATION_SECS, MAX_REDIRECT_DEPTH, Options, PlayableExtractorPlugin, Playlist, Plugin, PluginError, PluginErrorCode, PluginType, Queue, QueueManager, RECONNECT_MAX_ATTEMPTS, RECONNECT_TIMEOUT_MS, RepeatMode, STUCK_THRESHOLD_MS, SearchResult, SearchResultType, Song, StreamServer, TaskQueue, checkEncryptionLibraries, checkFFmpeg, checkIntents, checkInvalidKey, defaultFilters, defaultOptions, formatDuration, handleUnhandledError, isClientInstance, isGuildInstance, isMemberInstance, isMessageInstance, isNsfwChannel, isObject, isSnowflake, isSupportedVoiceChannel, isTextChannelInstance, isTruthy, isURL, isVoiceChannelEmpty, objectKeys, resolveGuildId, version };
|
|
3628
|
+
export type { Awaitable, CrossfadeOptions, CrossfadeStreamOptions, CustomPlaylistOptions, DisTubeEvents, DisTubeOptions, DisTubePlugin, DisTubeVoiceEvents, Disposable, FFmpegArg, FFmpegArgs, FFmpegOptions, Falsy, Filter, FilterResolvable, Filters, GuildIdResolvable, JumpOptions, KeyOf, PlayHandlerOptions, PlayOptions, PlaylistInfo, PreloadOptions, RelatedSong, ResolveOptions, ResolvePlaylistOptions, SearchOptions, SongInfo, StreamHandler, StreamOptions, StreamRequest, StreamResponse, StreamServerOptions, TypedDisTubeEvents, UnhandledErrorBehavior };
|