Repository navigation
feat: add audio engine and Web Audio streaming - #50
Merged
Merged
Conversation
I kept the change incremental and backward-compatible: Added the DSP engine abstraction and PCM pipeline in AudioProcessingEngine.ts Hooked it into resource creation in PlaybackController.ts Kept the default behavior on the legacy @discordjs/voice path unless audioProcessing.enabled is explicitly turned on Included a safe fallback to the older stream path if DSP processing throws
I fixed the root cause in AudioProcessingEngine.ts: the resolver now respects the DSP enabled state before deciding the stream type. Behavior now: when DSP is disabled, it preserves the caller fallback type when raw PCM is actually being emitted, it returns StreamType.Raw when encoded output is used, it keeps the original stream type instead of mislabeling the resource
…ining Discord Voice as the default. Architecture and behavior Added the typed backend contract in AudioOutputBackend.ts: explicit encoded/PCM formats, stream ownership, capabilities, readiness, lifecycle, cancellation, events, and unsupported-operation errors. Added DiscordVoiceOutputBackend.ts to adapt Discord resource creation, player lifecycle, volume, and raw-PCM requirements. Float32 PCM is explicitly converted to signed 16-bit little-endian at this boundary. Kept PlaybackController.ts as the Discord-facing compatibility controller; it delegates selected output operations without moving crossfade, recovery, session, or queue policy into the adapter. Decoupled AudioProcessingEngine.ts from Discord runtime resources and declared/enforced processed PCM dimensions. Removed the unsafe fallback that could replay a partially consumed source as encoded bytes; failed or cancelled processing now cleans up owned streams. Propagated cancellation through PlaybackStartController.ts and ResourceRefreshController.ts. Exported the new API through index.ts. Added fake-backend and Discord-adapter coverage in audio_output_backend.test.js, expanded DSP coverage in audio_processing_engine.test.js, and documented current dependencies and future Web-backend requirements in AUDIO_OUTPUT_BACKENDS.md. Compatibility remains Discord-first: existing AudioResource-facing APIs remain available, Discord is still selected by default, and audioProcessing changes DSP options rather than output backend selection. The future Web transport is not implemented. Remaining Discord-coupled surfaces and Web transport concerns are recorded in the architecture document.
- Changed stopPlayback method signatures to return Promise<void> in various controllers. - Updated calls to stopPlayback to use await for proper asynchronous handling. - Modified PreloadController to handle playback state changes asynchronously. - Enhanced error handling in audio output backend tests to ensure proper lifecycle management. - Improved documentation on audio output backend selection and lifecycle management.
- Added error reporting to the PlaybackSkipController, PlaybackStartController, and PlaybackTrackEndController to capture and log stream errors. - Improved error handling in the PlaybackOrchestrator to ensure that errors during track end and playback stop are properly reported. - Updated tests to cover new error handling scenarios, including stop failures and remote stop actions. - Enhanced the FakeAudioOutputBackend to simulate various failure conditions for more robust testing.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…nagement and error handling
- Created a new client package for handling WebSocket PCM streams with AudioWorklet. - Implemented tests for audio configuration validation and PCM frame decoding. - Added a backend example with WebSocket support for audio streaming. - Included HTML and JavaScript files for a web client interface to connect to the audio stream. - Established a gateway for managing publisher and listener connections with authentication. - Implemented tests for the gateway to ensure proper handling of audio configuration and PCM frames.
…up and session management
… session management; enhance gateway and client with session handling
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing |
This change removes the demo token requirement from the browser WebSocket gateway, makes listener auth optional, and enforces loopback-only local deployment. The example backend now supports per-player session IDs, player-state queries, and playback control routing for pause/resume/seek/volume/filter actions. It also updates the browser client and TypeScript types to allow optional `token` values, adds tests for the new gateway and volume behavior, and implements backend-level PCM volume scaling in `WebSocketAudioOutputBackend` while reporting the capability as supported.
This change makes preload requests complete gracefully when no track is ready, adds per-session listener count notifications and idle player cleanup in the backend gateway, and ensures audio pipelines accept Node Readable streams. It also updates websocket backend capability behavior and regression tests covering disabled-preload, listener-count, and volume handling.
Playback now treats search results as a playlist only when the result includes playlist metadata; otherwise it queues just the first match. The public docs and examples were updated to reflect this behavior, and the backend demo client got a richer player UI with track cards, queue counts, and metadata panels. Regression tests cover the playlist-vs-single-track selection logic.
This patch fixes stale pause/resume checks on facade players, keeps custom audio backends reporting the backend status, and makes the backend example push player state over SSE instead of polling. It also adds `preferYoutubei` ordering to YouTube stream fallback selection, updates the docs/example usage, and covers the behavior with regression tests.
This commit hardens the DSP/PCM path by guarding invalid samples, enforcing maxBufferBytes before output chunks escape the pipeline, and cleaning up async iterators safely. It also updates the public documentation to clarify the encoded-input-only DSP contract, browser/WebSocket PCM requirements, and custom backend usage.
Centralize plugin registration in PluginController while keeping player-specific plugins, stream caches, and search state isolated. Route player context through search and stream resolution, add regression coverage, and bump package versions.
Preserve requester objects on tracks while passing requester IDs to search plugins. Add asynchronous, player-scoped extension activation and Bus subscription cleanup, update extensions and documentation, and cover the new behavior with regression tests.
Move controller state into namespaced player.data maps, with cleanup on player teardown. Allow managed players to change their public ID without interrupting playback by preserving their internal routing identity. Wire heartbeat tracking to managed players and document the new APIs.
Support guild objects when changing or destroying players, emit player ID change notifications, and preserve routing aliases for actions and forwarding. Reject ID changes on destroyed players and cover lifecycle and forwarding cleanup.
Add YouTube lookup fallbacks, preserve stream metadata on exports, and make lyrics search resilient to request failures. Update core dependency handling and speed up test builds while improving lifecycle and audio regression coverage.
Update the plugin package's development version and core dependency, use TrackRequester for SoundCloud requests, and route YouTube debug logging through the manager's tracer.
Filter plugins by canHandle, prioritize TTS tracks for tts: queries, and route playback only when the selected track is TTS. Prevent SoundCloud from claiming unsupported queries and add routing regression tests.
Add configurable Web Audio analyser support, frequency-band and bass-energy helpers, and documentation and tests for browser visualizers. Bump the client package to 1.0.3.
Add per-player FIFO TTS playback with skip/stop handling and safe music restoration. Improve the browser client for Electron and Tauri with autoplay recovery, configurable worklet URLs, and socket cleanup; document desktop integration and add regression tests.
Prevent concurrent TTS requests from invalidating each other's results, and preserve an unlocked AudioContext when connecting or reconnecting. Add EventTarget-compatible TypeScript overloads and regression tests.
Remove the general-purpose FFmpeg processing engine and its public configuration and exports. Normal playback now feeds streams directly to audio resources, while FilterController retains FFmpeg for filtering and non-seekable seeks. Update documentation and replace engine-focused tests with playback pipeline and filter lifecycle coverage.
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Verification
main.Review notes