# MicrophoneTap

A consumer of players' inbound microphone audio, registered through subscribeMicrophone.

Source: https://socketsvc.vercel.app/api/shared/MicrophoneTap
<Callout title="Generated from source">
  Interface `com.socketsvc.api.MicrophoneTap` — generated from [MicrophoneTap.java](https://github.com/HippoDev03/SocketSVC/blob/main/common/core/src/main/java/com/socketsvc/api/MicrophoneTap.java). Edit the Javadoc in the Java source, then run `pnpm gen:api`.
</Callout>

```java
package com.socketsvc.api;

public interface MicrophoneTap { ... }
```

A consumer of players' inbound microphone audio, registered through
`subscribeMicrophone`.

**This is the one API SocketSVC has that reads a player rather than writes to one**, and
it is gated accordingly: the `microphone-tap.enabled` switch is off until an operator
turns it on, `socketsvc.bridge` decides whose audio may leave the system at all, and
every subscription is announced in the server log. A tap sees only what the relay was already
willing to send on - a muted player, a player without `socketsvc.speak`, and a player
whose `socketsvc.bridge` was taken away all reach it as silence rather than as frames.

Callbacks run on the voice relay's network thread, once per 20 ms per talking player. Do not
block in them and do not touch the server's world or entity state from them: hand the frame to
your own queue and leave. A tap that throws is closed and the failure logged, rather than
being allowed to take the relay down with it.

## Methods

### onAudio

```java
void onAudio(MicrophoneAudio audio)
```

One frame from one speaker. See [`MicrophoneAudio`](/api/shared/MicrophoneAudio) on why its arrays must not be
written to.

### onSpeakerGone

```java
default void onSpeakerGone(UUID speaker)
```

This speaker has stopped talking, disconnected, or been silenced - whatever was being
accumulated for them can be flushed. Never called without a preceding `#onAudio`.

## Nested types

- `enum Format`