-
Notifications
You must be signed in to change notification settings - Fork 102
feat: Speaker Api #711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
feat: Speaker Api #711
Conversation
Updated XML documentation for the Channel property to include a reference to Channels.
bfb5d97 to
aa481cb
Compare
Update PreloadedPcmSource.cs Update Speaker.cs Create WavUtility.cs Update WavStreamSource.cs Update PreloadedPcmSource.cs Change default stream parameter to false in PlayWav Update PlayWav method to default stream to true Change TargetPlayers from List to HashSet
aa481cb to
052e46d
Compare
Update PreloadedPcmSource.cs Added another constructor for public usages Update PreloadedPcmSource.cs
01439ee to
51298ee
Compare
- Introduced a full Event system to the Speaker class (Started, Finished, Stopped, Paused, Resumed). - Implemented `Seek()` functionality and added `CurrentTime` / `TotalDuration` properties. - Utilized `double` precision for all time related calculations to ensure accuracy. - Updated `WavStreamSource` and `PreloadedPcmSource` to support the new seeking logic.
0c2ba50 to
3f7ce95
Compare
4983722 to
ae9992f
Compare
-Optimized WAV header skipping (string comparisons to direct uint32 hex checks)
0f9357c to
ae2103f
Compare
…into SpeakerToyReborn
…into SpeakerToyReborn
| case SpeakerPlayMode.Global: | ||
| NetworkServer.SendToReady(msg, Channel); | ||
| break; | ||
|
|
||
| case SpeakerPlayMode.Player: | ||
| TargetPlayer?.Connection.Send(msg, Channel); | ||
| break; | ||
|
|
||
| case SpeakerPlayMode.PlayerList: | ||
| using (NetworkWriterPooled writer = NetworkWriterPool.Get()) | ||
| { | ||
| NetworkMessages.Pack(msg, writer); | ||
| ArraySegment<byte> segment = writer.ToArraySegment(); | ||
|
|
||
| foreach (Player ply in TargetPlayers) | ||
| { | ||
| ply?.Connection.Send(segment, Channel); | ||
| } | ||
| } | ||
|
|
||
| break; | ||
|
|
||
| case SpeakerPlayMode.Predicate: | ||
| using (NetworkWriterPooled writer = NetworkWriterPool.Get()) | ||
| { | ||
| NetworkMessages.Pack(msg, writer); | ||
| ArraySegment<byte> segment = writer.ToArraySegment(); | ||
|
|
||
| foreach (Player ply in Player.List) | ||
| { | ||
| if (Predicate(ply)) | ||
| ply.Connection.Send(segment, Channel); | ||
| } | ||
| } | ||
|
|
||
| break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could also make this flags based 😎
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer not to get involved for now; I mean, we can already do things that require flags with predicate or target lists, right?
Description
Describe the changes
This PR restores functional audio playback for the Speaker toy by reintroducing a proper PCM based audio pipeline. The Speaker now actively encodes PCM data using Opus, streams audio in real time, and correctly sends voice packets to clients.
Additionally, this PR introduces a complete Audio API overhaul:
-Seeking Support: Added functionality to jump to specific timestamps in both streamed and preloaded audio.
-Event System: Implemented a full lifecycle event system (OnPlaybackStarted, Paused, Resumed, Stopped, Finished, Looped) for better plugin integration.
High Precision: Switched internal time tracking to double precision to ensure accurate playback timing and seeking.
What is the current behavior? (You can also link to an open issue here)
The current Speaker toy is unable to play any audio. Although audio packets can be sent, no actual playback pipeline exists.
What is the new behavior? (if this is a feature change)
The Speaker can now reliably play audio. It supports streamed and preloaded WAV playback, real-time PCM encoding, looping, targeted or global playback modes, and proper cleanup when playback ends or the toy is removed.
-Playback Pipeline: Real time or Preloaded PCM encoding and streaming.
-WAV Support: Support for both streamed and preloaded WAV playback.
-Advanced Controls: Added Seek(double seconds), CurrentTime, and TotalDuration properties.
-Events: Developers can subscribe to playback events to trigger logic when audio starts, stops, or finishes.
-Flexible Modes: Supports Looping, Targeted (specific players ), Predicate players, or Global playback modes.
-Pitch Support: Dynamic playback speed control with optimized interpolation.
-Cleanup: Proper resource disposal when playback ends or the toy is removed.
Example Videos:
2026-01-04.13-03-42.mp4
2026-01-12_01-55-51.mp4
SPOILER_0121.mp4
Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
No. This change restores and extends existing functionality without requiring changes from users.
Other information:
Types of changes
Submission checklist
Patches (if there are any changes related to Harmony patches)
Other