Rust bindings and a small safe wrapper for ggwave, a library that encodes short payloads into audio waveforms.
- Safe
GgWavewrapper for init/encode/decode - Raw C FFI bindings available under
ggwave_rs::ffi - Build with a vendored upstream copy (default) or a system
libggwave - CLI tool with WAV file support for encode/decode
- Rust toolchain (edition 2021)
- Vendored build: a C++11 toolchain
- System build:
libggwave+pkg-configavailable on your system
This repo tracks ggwave as a submodule under vendor/ggwave:
git submodule update --init --recursiveThis is a Cargo workspace with two crates:
ggwave-rs— the libraryggwave-cli— the command-line tool
Build everything (vendored, default):
cargo buildBuild with system library:
cargo build --no-default-features --features systemNote: the system libggwave must be built with the full protocol set
(i.e. without GGWAVE_CONFIG_FEW_PROTOCOLS / Arduino configs).
The CLI reads and writes standard WAV files:
# Build and install the CLI
cargo install --path ggwave-cli
# Encode a message to a WAV file
ggwave encode "hello" output.wav
ggwave encode "hello" output.wav --volume 30 --protocol ultrasound-fast
# Decode a message from a WAV file
ggwave decode output.wavAvailable protocols: audible-normal, audible-fast, audible-fastest,
ultrasound-normal, ultrasound-fast, ultrasound-fastest,
dt-normal, dt-fast, dt-fastest, mt-normal, mt-fast, mt-fastest
use ggwave_rs::{default_parameters, GgWave, ProtocolId};
let params = default_parameters();
let ggwave = GgWave::new(params)?;
let waveform = ggwave.encode(
b"ping",
ProtocolId::GGWAVE_PROTOCOL_AUDIBLE_FAST,
25,
)?;
if let Some(payload) = ggwave.decode(&waveform)? {
println!("decoded: {}", String::from_utf8_lossy(&payload));
}
# Ok::<(), Box<dyn std::error::Error>>(())git submodule update --remote --mergeThis crate is MIT licensed. Upstream ggwave is also MIT licensed.