MicrophoneAudio
One 20 ms slice of a player's microphone, handed to a MicrophoneTap.
這一頁還沒有翻譯,以下顯示英文原文。
Generated from source
Record com.socketsvc.api.MicrophoneAudio — generated from MicrophoneAudio.java. Edit the Javadoc in the Java source, then run pnpm gen:api.
package com.socketsvc.api;
public record MicrophoneAudio(UUID speaker, long stream, long sequence, boolean startOfStream, byte[] opus, short[] pcm) { ... }One 20 ms slice of a player's microphone, handed to a MicrophoneTap.
The arrays belong to SocketSVC, not to the tap. The same instance is passed to every
subscriber and to the relay's own spatial path in turn, so writing into #opus() or
#pcm() corrupts what the next subscriber - and every listening player - receives. Copy
before keeping either beyond the call. For the same reason this type is a carrier rather than a
value: its generated equals and hashCode compare the arrays by identity, and
comparing two of these is not a question worth asking.
Components
| Component | Description |
|---|---|
UUID speaker | the player who spoke. Preserved exactly as the relay knows them, so a consumer can attribute audio without a second lookup |
long stream | the sender's stream id; changes when they stop and start talking again |
long sequence | the frame's position within stream, counting from zero |
boolean startOfStream | whether this is the first frame of stream - a decoder that keeps per-speaker state should reset on it |
byte[] opus | one 20 ms, 48 kHz mono Opus frame, exactly as the client encoded it. Never null |
short[] pcm | the same frame decoded to 960 signed 16-bit samples, or null when this tap subscribed with MicrophoneTap.Format#OPUS. SocketSVC decodes once and shares the result with every PCM subscriber rather than each shipping its own decoder |
Constants
| Constant | Description |
|---|---|
public static final int FRAME_SAMPLES = 960 | Samples in one 20 ms frame at 48 kHz, mono - the size of #pcm() when present. |