feat: implement Fairlight Live protocol client crate with CLI example - #1
Merged
Conversation
added 4 commits
April 24, 2026 00:52
- Add complete binary packet codec (tokio-util Decoder/Encoder) with magic framing (0x55667788) - Add ProjectOpen, DataChunk, Ack, MixerControl packet types - Add async FairlightClient with full connection handshake (PROJECT_OPEN, DATA_CHUNK stream, ACK, initial mixer sync) - Add high-level mixer API: set_mute, set_fader, set_bus_fader - Add MixerState tracking (24 strips, 6 buses) - Add clap CLI example with subcommands: connect, mute, fader, raw
MAGIC = 0x55667788 is a big-endian representation of the four wire bytes 55 66 77 88. All encode paths were using to_le_bytes() which produced the reversed sequence [88 77 66 55], and the codec find_magic() likewise searched for the reversed pattern - so the decoder never matched a single incoming packet and framed.next().await blocked forever. - constants.rs: export MAGIC_BYTES = MAGIC.to_be_bytes() = [55 66 77 88] - header.rs: decode uses from_be_bytes; encode uses MAGIC_BYTES - codec.rs: import MAGIC_BYTES from constants (removes local const) - ack.rs / data_chunk.rs / mixer.rs / project_open.rs: replace MAGIC.to_le_bytes() with MAGIC_BYTES in every encode function
clap treats leading '-' as a flag prefix by default. Adding allow_negative_numbers = true to FaderArgs and RawArgs lets users pass values like --level -1000 without quoting workarounds.
- Matrix on ubuntu-latest and windows-latest - dtolnay/rust-toolchain stable with rustfmt + clippy - Swatinem/rust-cache for faster builds - Apply rustfmt so cargo fmt --check passes in CI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tokio-utilcodec using magic number0x55667788Ack,MixerControl,ProjectOpen,DataChunkFairlightClienthandles the full connection lifecycle:PROJECT_OPEN, streams 182DATA_CHUNKpackets with periodic ACKsset_mute(cam, bool),set_fader(cam, level),set_bus_fader(bus, level)MixerStatetracks 24 input strips and 6 output busesexamples/cli.rs— clap CLI with subcommands:connect,mute,fader,rawTest plan
cargo build --examplespasses without warningscargo clippy --examples -- -D warningspasses cleancargo run --example cli -- connectagainst a live Fairlight Live instancecargo run --example cli -- mute --cam 1 --onmutes CAM1cargo run --example cli -- fader --cam 2 --level -500sets CAM2 fadercargo run --example cli -- raw --object-type 0 --index 0 --param 2 --value 1sends raw entry