Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ Receivers that discard a binary role payload MUST still process Noise messages,

### Binary Message ID Structure

The first byte of every decrypted binary message is its message ID. IDs are assigned from the table below; each role's binary message definitions name the exact IDs it uses.
The first byte of every decrypted binary message is its message ID. A binary message whose AEAD plaintext is empty is a protocol error: the receiver MUST close the connection. So is a message with ID `0` whose body is not a valid UTF-8 JSON object with a `type` string and a `payload` object. IDs are assigned from the table below; each role's binary message definitions name the exact IDs it uses.

| IDs | Assignment |
|---|---|
Expand Down Expand Up @@ -1323,6 +1323,8 @@ During an active stream, unavailable clients SHOULD discard otherwise valid audi
- Bytes 9-12: send_ahead (big-endian uint32) - microseconds from the server's transmission of this message to `timestamp`
- Rest of bytes: encoded audio frame

An audio message shorter than 13 bytes is a protocol error: the client MUST close the connection.

The timestamp indicates when the first audio sample in this chunk should be output. Clients MUST translate this server timestamp to their local clock using the [time filter](#clock-synchronization), subtracting their [`output_delay_ms`](#client--server-clientstate-player-object) from the timestamp. Clients SHOULD compensate for any known processing delays (e.g., DAC latency, audio buffer delays) by accounting for these delays when submitting audio to the hardware.

`send_ahead` reports the lead the server had in hand when it sent the chunk: its transmit time is `timestamp - send_ahead` in the server's clock, taken as described in [Transmit timestamps](#transmit-timestamps). The field saturates rather than wrapping: a server MUST send `0` when it transmits at or after `timestamp`, and `4294967295` when the true lead exceeds what the field can represent (about 71 minutes). Both saturation values report that no lead was measured, not a lead of that length, so a player MUST NOT use a chunk carrying either as a delay sample.
Expand Down Expand Up @@ -1509,6 +1511,8 @@ Clients MUST send `client-stream/start` before the first audio chunk. Sending `c
- Bytes 1-8: timestamp (big-endian int64) - server clock time in microseconds when the first sample was captured
- Rest of bytes: encoded audio frame

A source audio message shorter than 9 bytes is a protocol error: the server MUST close the connection.

The timestamp indicates when the first audio sample in this chunk was captured (in server time domain). It is the best-effort time the audio reached the input (ADC). For codecs with encoder delay, it refers to the capture time of the first sample the decoder will emit for the chunk. The server MAY resample/transcode and then distribute the audio to players with its normal buffering and synchronization strategy.

A source MUST NOT send a chunk longer than 150 ms, and SHOULD NOT send one shorter than 5 ms (the final chunk before a `client-stream/end` MAY be shorter). After a network stall, clients SHOULD drop buffered backlog beyond a small bound and resume from live capture rather than burst stale audio.
Expand Down Expand Up @@ -1808,6 +1812,8 @@ Each visualization `type` has its own binary message type. Every message carries
- Bytes 1-8: timestamp (big-endian int64) - server clock time in microseconds when this data should be displayed. Clients MUST translate this server timestamp to their local clock using the [time filter](#clock-synchronization)
- Remaining bytes: data, layout per type below; all `uint16` fields are big-endian

A visualization message shorter than 9 bytes is a protocol error: the client MUST close the connection.

Data whose timestamp is already in the past on arrival is dropped; stale visualization frames are never rendered.

`loudness`, `spectrum` bins, and the `f_peak` amplitude use the full `uint16` range 0-65535, where 0 = silence and 65535 = full scale. Values are A-weighted and dB-scaled: -60 dB → 0, 0 dB → 65535, mapped linearly across that range.
Expand Down
2 changes: 1 addition & 1 deletion messaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Receivers that discard a binary role payload MUST still process Noise messages,

### Binary Message ID Structure

The first byte of every decrypted binary message is its message ID. IDs are assigned from the table below; each role's binary message definitions name the exact IDs it uses.
The first byte of every decrypted binary message is its message ID. A binary message whose AEAD plaintext is empty is a protocol error: the receiver MUST close the connection. So is a message with ID `0` whose body is not a valid UTF-8 JSON object with a `type` string and a `payload` object. IDs are assigned from the table below; each role's binary message definitions name the exact IDs it uses.

| IDs | Assignment |
|---|---|
Expand Down
2 changes: 2 additions & 0 deletions roles/player/v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ During an active stream, unavailable clients SHOULD discard otherwise valid audi
- Bytes 9-12: send_ahead (big-endian uint32) - microseconds from the server's transmission of this message to `timestamp`
- Rest of bytes: encoded audio frame

An audio message shorter than 13 bytes is a protocol error: the client MUST close the connection.

The timestamp indicates when the first audio sample in this chunk should be output. Clients MUST translate this server timestamp to their local clock using the [time filter](../../messaging.md#clock-synchronization), subtracting their [`output_delay_ms`](#client--server-clientstate-player-object) from the timestamp. Clients SHOULD compensate for any known processing delays (e.g., DAC latency, audio buffer delays) by accounting for these delays when submitting audio to the hardware.

`send_ahead` reports the lead the server had in hand when it sent the chunk: its transmit time is `timestamp - send_ahead` in the server's clock, taken as described in [Transmit timestamps](../../messaging.md#transmit-timestamps). The field saturates rather than wrapping: a server MUST send `0` when it transmits at or after `timestamp`, and `4294967295` when the true lead exceeds what the field can represent (about 71 minutes). Both saturation values report that no lead was measured, not a lead of that length, so a player MUST NOT use a chunk carrying either as a delay sample.
Expand Down
2 changes: 2 additions & 0 deletions roles/source/v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ Clients MUST send `client-stream/start` before the first audio chunk. Sending `c
- Bytes 1-8: timestamp (big-endian int64) - server clock time in microseconds when the first sample was captured
- Rest of bytes: encoded audio frame

A source audio message shorter than 9 bytes is a protocol error: the server MUST close the connection.

The timestamp indicates when the first audio sample in this chunk was captured (in server time domain). It is the best-effort time the audio reached the input (ADC). For codecs with encoder delay, it refers to the capture time of the first sample the decoder will emit for the chunk. The server MAY resample/transcode and then distribute the audio to players with its normal buffering and synchronization strategy.

A source MUST NOT send a chunk longer than 150 ms, and SHOULD NOT send one shorter than 5 ms (the final chunk before a `client-stream/end` MAY be shorter). After a network stall, clients SHOULD drop buffered backlog beyond a small bound and resume from live capture rather than burst stale audio.
Expand Down
2 changes: 2 additions & 0 deletions roles/visualizer/v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ Each visualization `type` has its own binary message type. Every message carries
- Bytes 1-8: timestamp (big-endian int64) - server clock time in microseconds when this data should be displayed. Clients MUST translate this server timestamp to their local clock using the [time filter](../../messaging.md#clock-synchronization)
- Remaining bytes: data, layout per type below; all `uint16` fields are big-endian

A visualization message shorter than 9 bytes is a protocol error: the client MUST close the connection.

Data whose timestamp is already in the past on arrival is dropped; stale visualization frames are never rendered.

`loudness`, `spectrum` bins, and the `f_peak` amplitude use the full `uint16` range 0-65535, where 0 = silence and 65535 = full scale. Values are A-weighted and dB-scaled: -60 dB → 0, 0 dB → 65535, mapped linearly across that range.
Expand Down
Loading