MicrophoneAudio - SocketSVC Docs
SocketSVC Docs

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

ComponentDescription
UUID speakerthe player who spoke. Preserved exactly as the relay knows them, so a consumer can attribute audio without a second lookup
long streamthe sender's stream id; changes when they stop and start talking again
long sequencethe frame's position within stream, counting from zero
boolean startOfStreamwhether this is the first frame of stream - a decoder that keeps per-speaker state should reset on it
byte[] opusone 20 ms, 48 kHz mono Opus frame, exactly as the client encoded it. Never null
short[] pcmthe 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

ConstantDescription
public static final int FRAME_SAMPLES = 960Samples in one 20 ms frame at 48 kHz, mono - the size of #pcm() when present.

本頁內容

以 Markdown 檢視

詢問 AI 這一頁的內容