Source:
WLEDAudioSyncPacket.h
wled_audio_sync¶
The one place this packet layout lives, built to broadcast our analyzed audio and parsed to drive effects from a peer's.
The contract is fixed upstream, so the bytes must be exact, and a unit test round-trips against a golden vector.
Functions¶
| Return | Name | Description |
|---|---|---|
void |
wledPutFloatLE inline |
Store a float in wire order, which on every target here is the raw bytes. |
float |
wledGetFloatLE inline |
|
uint16_t |
wledFloatToU16 inline |
Truncate a wire float into a frame field, clamped, since a foreign packet may carry anything. |
size_t |
buildWledAudioSync inline |
Build a packet from a frame; peak is the beat flag the caller owns, and it answers the size. |
bool |
parseWledAudioSync inline |
Parse and validate a packet into a frame; true only for a well-formed one of exactly the right size and header. |
wledPutFloatLE¶
inline
Store a float in wire order, which on every target here is the raw bytes.
wledGetFloatLE¶
inline
wledFloatToU16¶
inline
Truncate a wire float into a frame field, clamped, since a foreign packet may carry anything.
buildWledAudioSync¶
inline
Build a packet from a frame; peak is the beat flag the caller owns, and it answers the size.
parseWledAudioSync¶
inline
Parse and validate a packet into a frame; true only for a well-formed one of exactly the right size and header.
Variables¶
| Return | Name | Description |
|---|---|---|
constexpr uint16_t |
WLED_SYNC_PORT constexpr |
|
constexpr size_t |
WLED_SYNC_PACKET_SIZE constexpr |
|
constexpr char |
WLED_SYNC_HEADER constexpr |
|
constexpr size_t |
WLED_SYNC_NUM_BANDS constexpr |
|
constexpr float |
kWledMagScale constexpr |
The divisor the upstream's own effects apply, so a byte of ours matches a native sender's brightness. |
WLED_SYNC_PORT¶
constexpr
WLED_SYNC_PACKET_SIZE¶
constexpr
WLED_SYNC_HEADER¶
constexpr
WLED_SYNC_NUM_BANDS¶
constexpr
kWledMagScale¶
constexpr
The divisor the upstream's own effects apply, so a byte of ours matches a native sender's brightness.
More info¶
The packet¶
Forty-four bytes on a fixed port, broadcast: a header string, two levels as floats and a peak flag. Then the sixteen bands as bytes, and the dominant bin's magnitude and frequency. Two padding runs are real wire bytes and go out as zero, and one reserved byte stays zero because the upstream may claim it later. The offsets are hand-serialized rather than trusted to struct packing, and the floats are little-endian, which every target here and upstream shares.
Units convert at this boundary¶
The wire carries the upstream's magnitude units and the audio frame keeps ours, byte-scaled and conditioned by the same noise floor and gain as the bands. The scale factor is exactly the divisor its own effects apply, so a byte of ours lands on the brightness a native source would produce.