From c0104c0201653e974c3e7a416007c2574300dbe3 Mon Sep 17 00:00:00 2001 From: borosf Date: Tue, 17 Nov 2026 19:40:39 +0000 Subject: [PATCH 01/20] Rust rewrite v1 skeleton: regulator-core DSP crate + ratatui TUI Port of tg's timing algorithm (noise suppression, FFT autocorrelation period detection, waveform folding, beat error, amplitude) to a pure-Rust core crate with unit tests against a synthetic watch generator, plus a clean three-zone terminal UI with cpal capture (optional feature) and a --demo mode. Original C code kept as reference. Co-authored-by: borosf --- .gitignore | 3 + Cargo.lock | 1473 +++++++++++++++++++++++ Cargo.toml | 12 + README.md | 225 +--- crates/regulator-core/Cargo.toml | 10 + crates/regulator-core/examples/debug.rs | 19 + crates/regulator-core/src/analyze.rs | 538 +++++++++ crates/regulator-core/src/filters.rs | 40 + crates/regulator-core/src/lib.rs | 21 + crates/regulator-core/src/signal.rs | 141 +++ crates/regulator-core/src/stats.rs | 132 ++ crates/regulator-tui/Cargo.toml | 24 + crates/regulator-tui/src/audio.rs | 37 + crates/regulator-tui/src/main.rs | 160 +++ crates/regulator-tui/src/ui.rs | 147 +++ docs/original-readme.md | 212 ++++ 16 files changed, 3000 insertions(+), 194 deletions(-) create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 crates/regulator-core/Cargo.toml create mode 100644 crates/regulator-core/examples/debug.rs create mode 100644 crates/regulator-core/src/analyze.rs create mode 100644 crates/regulator-core/src/filters.rs create mode 100644 crates/regulator-core/src/lib.rs create mode 100644 crates/regulator-core/src/signal.rs create mode 100644 crates/regulator-core/src/stats.rs create mode 100644 crates/regulator-tui/Cargo.toml create mode 100644 crates/regulator-tui/src/audio.rs create mode 100644 crates/regulator-tui/src/main.rs create mode 100644 crates/regulator-tui/src/ui.rs create mode 100644 docs/original-readme.md diff --git a/.gitignore b/.gitignore index 0060ccd..16a3015 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,6 @@ Makefile.in # build directories /deb /msi + +# Rust +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..ab3b41f --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1473 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aho-corasick" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" +dependencies = [ + "memchr", +] + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "alsa" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed7572b7ba83a31e20d1b48970ee402d2e3e0537dcfe0a3ff4d6eb7508617d43" +dependencies = [ + "alsa-sys", + "bitflags 2.13.2", + "cfg-if", + "libc", +] + +[[package]] +name = "alsa-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db8fee663d06c4e303404ef5f40488a53e062f89ba8bfed81f42325aafad1527" +dependencies = [ + "libc", + "pkg-config", +] + +[[package]] +name = "anyhow" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "bindgen" +version = "0.72.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895" +dependencies = [ + "bitflags 2.13.2", + "cexpr", + "clang-sys", + "itertools", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex 1.3.0", + "syn 2.0.119", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" + +[[package]] +name = "bumpalo" +version = "3.20.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87a0cf66fd1eb2fb7b822cb78370d82303750809bc6ba855f3f58e517d3238db" + +[[package]] +name = "bytes" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" + +[[package]] +name = "cassowary" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" + +[[package]] +name = "castaway" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dec551ab6e7578819132c713a93c022a05d60159dc86e7a7050223577484c55a" +dependencies = [ + "rustversion", +] + +[[package]] +name = "cc" +version = "1.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ef9e3e8154a45c7a95cff4c1299702106ad94062d7bb85fdc5d3a5afd91d45" +dependencies = [ + "find-msvc-tools", + "jobserver", + "libc", + "shlex 2.0.1", +] + +[[package]] +name = "cesu8" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "clang-sys" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "157a8ba7b480713b56f4c09fd13fc3e0a22a5dfab8097ba61cbc5feef950788a" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "combine" +version = "4.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4356eba6976435498d05a311ee9fc486da3bc81c200d3f0d7dd9703b41913f92" +dependencies = [ + "bytes", + "memchr", +] + +[[package]] +name = "compact_str" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fd622ebbb56a5b2ccb651b32b911cdeb2a9b4b11776b2473bf26a26a286244e" +dependencies = [ + "castaway", + "cfg-if", + "itoa", + "rustversion", + "ryu", + "static_assertions", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "coreaudio-rs" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "321077172d79c662f64f5071a03120748d5bb652f5231570141be24cfcd2bace" +dependencies = [ + "bitflags 1.3.2", + "core-foundation-sys", + "coreaudio-sys", +] + +[[package]] +name = "coreaudio-sys" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9b4739a805a62757a83e5654fa3faabec0442666b263bb2287d5a8185bfd953" +dependencies = [ + "bindgen", +] + +[[package]] +name = "cpal" +version = "0.15.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "873dab07c8f743075e57f524c583985fbaf745602acbe916a01539364369a779" +dependencies = [ + "alsa", + "core-foundation-sys", + "coreaudio-rs", + "dasp_sample", + "jni", + "js-sys", + "libc", + "mach2", + "ndk", + "ndk-context", + "oboe", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "windows", +] + +[[package]] +name = "crossterm" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6" +dependencies = [ + "bitflags 2.13.2", + "crossterm_winapi", + "mio", + "parking_lot", + "rustix", + "signal-hook", + "signal-hook-mio", + "winapi", +] + +[[package]] +name = "crossterm_winapi" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" +dependencies = [ + "winapi", +] + +[[package]] +name = "darling" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed17f5901b6630b993ca003def43f2f8ef4014fc13b047b57aad617ff32bc2ec" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6837e2cf7485aaae18f86181d2f0e9a7ed297a025e220aeabf63fdebd3a2ddff" +dependencies = [ + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 3.0.10", +] + +[[package]] +name = "darling_macro" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ac7135c3ef02b2f7833bbeb1be5ba7f966dcde8a87c6b87f65a778d71a02785" +dependencies = [ + "darling_core", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "dasp_sample" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f" + +[[package]] +name = "either" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" + +[[package]] +name = "equivalent" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" + +[[package]] +name = "errno" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e35d6e78f4cebb90e51d543db8fe41528851d6deeef6ef21ebd4bfdc1e784776" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48" + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "libc", + "r-efi", +] + +[[package]] +name = "glob" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b" + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "indexmap" +version = "2.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +dependencies = [ + "equivalent", + "hashbrown 0.17.1", +] + +[[package]] +name = "indoc" +version = "2.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a37b2691796cffeb8a8cd305ac66e65841559f147f4e63231d0eafa4db5384d1" +dependencies = [ + "rustversion", +] + +[[package]] +name = "instability" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c3b5acc1e2fd9375041a388da33d1eb8aed5f7a8c0dd3543e3ea2805adfbe20" +dependencies = [ + "darling", + "indoc", + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" + +[[package]] +name = "jni" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" +dependencies = [ + "cesu8", + "cfg-if", + "combine", + "jni-sys 0.3.1", + "log", + "thiserror", + "walkdir", + "windows-sys 0.45.0", +] + +[[package]] +name = "jni-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41a652e1f9b6e0275df1f15b32661cf0d4b78d4d87ddec5e0c3c20f097433258" +dependencies = [ + "jni-sys 0.4.1", +] + +[[package]] +name = "jni-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6377a88cb3910bee9b0fa88d4f42e1d2da8e79915598f65fb0c7ee14c878af2" +dependencies = [ + "jni-sys-macros", +] + +[[package]] +name = "jni-sys-macros" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264" +dependencies = [ + "quote", + "syn 2.0.119", +] + +[[package]] +name = "jobserver" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3" +dependencies = [ + "getrandom", + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dc09d2154098bbf4ef54eab6b117a3c24cbbffe94046b16ee6d6d4510584d3a" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "libc" +version = "0.2.191" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" + +[[package]] +name = "libloading" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55" +dependencies = [ + "cfg-if", + "windows-link", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c" + +[[package]] +name = "lru" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" +dependencies = [ + "hashbrown 0.15.5", +] + +[[package]] +name = "mach2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d640282b302c0bb0a2a8e0233ead9035e3bed871f0b7e81fe4a1ec829765db44" +dependencies = [ + "libc", +] + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "mio" +version = "1.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20521a903f02b0a573cd6840e9d0a5a0cc043d361fe924092cd70f8556cc9c4a" +dependencies = [ + "libc", + "log", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "ndk" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2076a31b7010b17a38c01907c45b945e8f11495ee4dd588309718901b1f7a5b7" +dependencies = [ + "bitflags 2.13.2", + "jni-sys 0.3.1", + "log", + "ndk-sys", + "num_enum", + "thiserror", +] + +[[package]] +name = "ndk-context" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" + +[[package]] +name = "ndk-sys" +version = "0.5.0+25.2.9519653" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c196769dd60fd4f363e11d948139556a344e79d451aeb2fa2fd040738ef7691" +dependencies = [ + "jni-sys 0.3.1", +] + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num-complex" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "num-integer" +version = "0.1.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_enum" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0bca838442ec211fa11de3a8b0e0e8f3a4522575b5c4c06ed722e005036f26" +dependencies = [ + "num_enum_derive", + "rustversion", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "680998035259dcfcafe653688bf2aa6d3e2dc05e98be6ab46afb089dc84f1df8" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "oboe" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8b61bebd49e5d43f5f8cc7ee2891c16e0f41ec7954d36bcb6c14c5e0de867fb" +dependencies = [ + "jni", + "ndk", + "ndk-context", + "num-derive", + "num-traits", + "oboe-sys", +] + +[[package]] +name = "oboe-sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8bb09a4a2b1d668170cfe0a7d5bc103f8999fb316c98099b6a9939c9f2e79d" +dependencies = [ + "cc", +] + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "pkg-config" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" + +[[package]] +name = "primal-check" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc0d895b311e3af9902528fbb8f928688abbd95872819320517cc24ca6b2bd08" +dependencies = [ + "num-integer", +] + +[[package]] +name = "proc-macro-crate" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" +dependencies = [ + "toml_edit", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "ratatui" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eabd94c2f37801c20583fc49dd5cd6b0ba68c716787c2dd6ed18571e1e63117b" +dependencies = [ + "bitflags 2.13.2", + "cassowary", + "compact_str", + "crossterm", + "indoc", + "instability", + "itertools", + "lru", + "paste", + "strum", + "unicode-segmentation", + "unicode-truncate", + "unicode-width 0.2.0", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "regex" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" + +[[package]] +name = "regulator-core" +version = "0.1.0" +dependencies = [ + "rustfft", +] + +[[package]] +name = "regulator-tui" +version = "0.1.0" +dependencies = [ + "anyhow", + "cpal", + "crossterm", + "ratatui", + "regulator-core", +] + +[[package]] +name = "rustc-hash" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" + +[[package]] +name = "rustfft" +version = "6.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21db5f9893e91f41798c88680037dba611ca6674703c1a18601b01a72c8adb89" +dependencies = [ + "num-complex", + "num-integer", + "num-traits", + "primal-check", + "strength_reduce", + "transpose", +] + +[[package]] +name = "rustix" +version = "0.38.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +dependencies = [ + "bitflags 2.13.2", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.59.0", +] + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[package]] +name = "ryu" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "signal-hook" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d881a16cf4426aa584979d30bd82cb33429027e42122b169753d6ef1085ed6e2" +dependencies = [ + "libc", + "signal-hook-registry", +] + +[[package]] +name = "signal-hook-mio" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b75a19a7a740b25bc7944bdee6172368f988763b744e3d4dfe753f6b4ece40cc" +dependencies = [ + "libc", + "mio", + "signal-hook", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.16.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "149309498a5f7334b12ddae0cad8aba81ce785fe91755068867e017cf98fee46" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strength_reduce" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe895eb47f22e2ddd4dabc02bce419d2e643c8e3b585c78158b349195bc24d82" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "strum" +version = "0.26.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.119", +] + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "tokio" +version = "1.54.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3" +dependencies = [ + "pin-project-lite", +] + +[[package]] +name = "toml_datetime" +version = "1.1.3+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "173f25c883cd2176a2d8212155638c0a60d484a9d84546d270866f40f56b6e49" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_edit" +version = "0.25.19+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd43688c4858d7264ae1cf9a9f874a67c3feb74a883b1cd7bebd6a4ea8307218" +dependencies = [ + "indexmap", + "toml_datetime", + "toml_parser", + "winnow", +] + +[[package]] +name = "toml_parser" +version = "1.1.5+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baa693a8032d7e1cada7d0041e96126df243179ff061456783ac7f12bda4744c" +dependencies = [ + "winnow", +] + +[[package]] +name = "transpose" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad61aed86bc3faea4300c7aee358b4c6d0c8d6ccc36524c96e4c92ccf26e77e" +dependencies = [ + "num-integer", + "strength_reduce", +] + +[[package]] +name = "unicode-ident" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "unicode-segmentation" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" + +[[package]] +name = "unicode-truncate" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3644627a5af5fa321c95b9b235a72fd24cd29c648c2c379431e6628655627bf" +dependencies = [ + "itertools", + "unicode-segmentation", + "unicode-width 0.1.14", +] + +[[package]] +name = "unicode-width" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" + +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasm-bindgen" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0181c14ddd6c7b8b0b0132a5f1ea2f32be0d893cd3ea97b6e3b28886b8a3d1c" +dependencies = [ + "cfg-if", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e14e0327cb5368ad60ccb22d04a9827a693c95a926d8d125e9fa39e0baec501" +dependencies = [ + "js-sys", + "tokio", + "wasm-bindgen", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e931a02a39abdbf66966fc35902b5ed58344750a70885bed4ebb3d8eaf28ed9" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ca4b54280e455bd831e33a6b8e734baf432fe63fbc35c42ac14ce67a043a53a" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 3.0.10", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b1f9c3798725016c6ee5f2f57869ec0831e8bbc0ab0310a86e787e97f41389e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-sys" +version = "0.3.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7d179596ff5ec0f6de4db64d54011bde6289cc49603d3a6e4ce3f329207ab88" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows" +version = "0.54.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49" +dependencies = [ + "windows-core", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-core" +version = "0.54.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65" +dependencies = [ + "windows-result", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-result" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winnow" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3b93199df0ab874cdf0c6a94f0a0dc3423fe41f1cafb62b8bd7b1deb277aef" +dependencies = [ + "memchr", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..7bf4de5 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,12 @@ +[workspace] +resolver = "2" +members = ["crates/regulator-core", "crates/regulator-tui"] + +[workspace.package] +version = "0.1.0" +edition = "2021" +license = "GPL-2.0" +repository = "https://github.com/borosf/regulator" + +[workspace.dependencies] +rustfft = "6" diff --git a/README.md b/README.md index e668dab..bcd5623 100644 --- a/README.md +++ b/README.md @@ -1,212 +1,49 @@ -# A program for timing mechanical watches +# regulator -The program tg is distributed under the GNU GPL license version 2. The full -source code of tg is available at -[https://github.com/xyzzy42/tg](https://github.com/xyzzy42/tg) and its -copyright belongs to the respective contributors. +A modern fork of [tg](https://github.com/xyzzy42/tg) — open-source watch +timing software for mechanical movements. regulator captures the ticking of +a watch with a microphone, analyzes the tick train, and reports the rate +error (s/day), balance amplitude, and beat error, with a cleaner interface +and a restructured, testable analysis core. -Tg is in development, and there is still no manual. Some info can be found -in this -[thread at WUS](http://forums.watchuseek.com/f6/open-source-timing-software-2542874.html), -in particular the calibration procedure is described at -[this post](http://forums.watchuseek.com/f6/open-source-timing-software-2542874-post29970370.html). +## Status -## Install instructions +Early-stage Rust rewrite. The original C code (GPLv2) is kept at the root of +the repository as the reference implementation and for its build system; see +[docs/original-readme.md](docs/original-readme.md) for the original project's +documentation, including the microphone calibration procedure. -Tg is known to work under Microsoft Windows, OS X, and Linux. Moreover it -should be possible to compile the source code under most modern UNIX-like -systems. See the sub-sections below for the details. +## Layout -### Windows +- `crates/regulator-core` — pure DSP: noise suppression, FFT-based period + detection, waveform folding, rate/amplitude/beat-error computation. No I/O, + fully unit-tested against a synthetic watch signal generator. +- `crates/regulator-tui` — the terminal interface (ratatui), with live + microphone capture (cpal) and a `--demo` mode driven by a synthetic watch. -Binaries can be found at https://tg.ciovil.li +## Build & run -Unfortunately, these packages have not been updated since 2017. Help from -someone who can build the Windows installer version would be appreciated. -You'll need to [build from source](#compiling-on-windows) to get any features -from the last five plus years. - -### Macintosh - -A formula for the Homebrew package manager has been prepared by GitHub user -[dmnc](https://github.com/dmnc) and then updated by -[xyzzy42](https://github.com/xyzzy42). To use it, you need to install Homebrew -first (instructions on http://brew.sh). - -Then run the following command to check everything is set up correctly -and follow any instructions it gives you. - - brew doctor - -To install tg, run: - - brew install --HEAD xyzzy42/horology/tg-timer - -You can now launch tg by typing: - - tg-timer & - -### Debian or Debian-based (e.g. Mint, Ubuntu) - -Binary .deb packages can be downloaded from https://tg.ciovil.li - -Unfortunately, these packages have not been updated since 2017. - -### Fedora, CentOS or other Redhat-based - -Binary RPM packages are available from https://copr.fedorainfracloud.org/coprs/tpiepho/tg-timer/ - -This COPR repository can be added to dnf's list with: ```sh -dnf copr enable tpiepho/tg-timer +cargo run -p regulator-tui # live microphone (needs ALSA/CoreAudio/WASAPI) +cargo run -p regulator-tui -- --demo # synthetic watch, no hardware needed ``` -Then tg-timer can be installed with `dnf install tg-timer`, or with any dnf -based GUI package installer. - -## Compiling from sources - -The source code of tg can probably be built by any C99 compiler, however only -gcc and clang have been tested. You need the following libraries: gtk+3, -portaudio2, fftw3 (all available as open source). - -The optional plotting features for audio filter response graphs and audio -spectrograms require Python. The follow Python modules are needed for all -features: numpy, scipy, matplotlib, libtfr. - -### Normal build -Get source: -```sh -git clone https://github.com/xyzzy42/tg.git -cd tg -# Optional, check out a specific branch other than the default -git checkout new-stuff -``` - -Build it: -```sh -./autogen.sh -./configure -make -``` - -### Debug build -After the steps of a normal build, above, run: -```sh -make tg-timer-dbg -``` - -### Compiling on Windows - -It is suggested to use the MSYS2 platform. First install MSYS2 according -to the instructions at [http://www.msys2.org](http://www.msys2.org). The -[UCRT64 environment](https://www.msys2.org/docs/environments/) appears to work -best. - -From the MSYS2 UCRT64 terminal issue the following commands to install dependencies: - -```sh -pacman -S mingw-w64-ucrt-x86_64-gcc pkg-config mingw-w64-ucrt-x86_64-gtk3 mingw-w64-ucrt-x86_64-portaudio mingw-w64-ucrt-x86_64-fftw make git autoconf automake libtool -pacman -S mingw-w64-ucrt-x86_64-ninja mingw-w64-ucrt-x86_64-python-scipy mingw-w64-ucrt-x86_64-python-matplotlib mingw-w64-ucrt-x86_64-lapack mingw-w64-ucrt-x86_64-cython mingw-w64-ucrt-x86_64-python-pip -``` - -Add the folder "C:\msys64\ucrt64\bin" to the system path variable - -Install the libtfr package with: - -```sh -pip install libtfr -``` +Useful keys: `←/→` beat rate preset (auto, 18000…36000 bph), `+/-` lift +angle, `n` noise suppressor, `q` quit. -If that doesn't work, try building it manually: +To build on a system without an audio stack: ```sh -git clone https://github.com/melizalab/libtfr.git -cd libtfr -python setup.py install +cargo build --no-default-features ``` -Then follow the [normal build](#normal-build) instructions to clone the TG -repository and build it. +## Portability -If the "Signal" or "Filter Chain" dialogs do not work, this appears to be some -sort of [library issue with Python on Windows](https://github.com/xyzzy42/tg/issues/8#issuecomment-2351649260). -Try copying the `tg-timer.exe` file to `C:\msys64\ucrt64\bin` and run it from there. +The core crate has no platform dependencies (pure Rust, no C). The TUI uses +cpal for capture, which works on Linux (ALSA), macOS (CoreAudio) and Windows +(WASAPI); without the `audio` feature the binary builds anywhere Rust does. -### Compiling on Debian - -To compile tg on Debian, install these dependencies: - -```sh -sudo apt-get install libgtk-3-dev libjack-jackd2-dev portaudio19-dev libfftw3-dev git autoconf automake libtool -``` - -Additional software is necessary for the optional Python graphing system, see -Fedora section for more information. Debian specific instructions welcome. - -Then follow the [normal build](#normal-build) instructions to clone the -repository and build it. - -The package libjack-jackd2-dev is not necessary, it only works around a -known bug (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=718221). - -### Compiling on Fedora - -To compile tg on Fedora, install these dependencies: - -```sh -sudo dnf install fftw-devel portaudio-devel gtk3-devel autoconf automake libtool -``` - -To use the Python graphing code (filter response and audio spectrogram) one -should also install: -```sh -sudo dnf install python3-devel python3-numpy python3-scipy python3-matplotlib -pip install --user libtfr -``` - -Then follow the [normal build](#normal-build) instructions to clone the -repository and build it. - -To build an RPM on Fedora or another RPM based distro, install the build -prerequisites and checkout the source as for compiling (above), then run -`rpmbuild` to create the RPM: - -```sh -rpmbuild --build-in-place -bb packaging/tg-timer.spec -``` - - -### Compiling on Macintosh - -To build on MacOS, install the follow dependencies with -[Homebrew](http://brew.sh). If you do not have Homebrew, the link above will -explain the install. - -```sh -brew install pkg-config autoconf automake libtool gtk+3 portaudio fftw gnome-icon-theme -``` - -To use the Python graphing code (filter response and audio spectrogram) one -should also install: - -```sh -brew install python numpy scipy -pip3 install matplotlib libtfr -``` - -If you have multiple versions of python3 installed, you might need to use a -specific version of pip, e.g. `pip3.11` in the above command. - -Then follow the [normal build](#normal-build) instructions to clone the -repository and build it. - -If you have multiple versions of Python installed and the configure script does -not detect the correct one, i.e. the one for which numpy, matplotlib, libtfr, -etc. have been installed for, then run the configure script as: - -```sh -PYTHON=python3.11 ./configure -``` +## License -Where `python3.11` is the correct version to use. +GPLv2, like the original project. regulator is a derivative work of tg, +Copyright 2015 Marcello Mamino and contributors. diff --git a/crates/regulator-core/Cargo.toml b/crates/regulator-core/Cargo.toml new file mode 100644 index 0000000..d4afb70 --- /dev/null +++ b/crates/regulator-core/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "regulator-core" +description = "Watch timing DSP: tick detection, rate, amplitude and beat error" +version.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true + +[dependencies] +rustfft = { workspace = true } diff --git a/crates/regulator-core/examples/debug.rs b/crates/regulator-core/examples/debug.rs new file mode 100644 index 0000000..6d77c69 --- /dev/null +++ b/crates/regulator-core/examples/debug.rs @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0 +use regulator_core::signal::SyntheticWatch; +use regulator_core::Analyzer; + +fn main() { + let sr = 44100u32; + let watch = SyntheticWatch { + bph: 28800, + rate_sday: 12.0, + beat_error_ms: 0.0, + amplitude_deg: 270.0, + }; + let samples = watch.generate(sr, 4.0); + let an = Analyzer::new(sr); + match an.analyze(&samples) { + Some(r) => println!("ok: {r:?}"), + None => println!("analysis failed"), + } +} diff --git a/crates/regulator-core/src/analyze.rs b/crates/regulator-core/src/analyze.rs new file mode 100644 index 0000000..d1c3402 --- /dev/null +++ b/crates/regulator-core/src/analyze.rs @@ -0,0 +1,538 @@ +// SPDX-License-Identifier: GPL-2.0 +//! The timing analysis pipeline, ported from tg's algo.c. + +use crate::filters::Biquad; +use crate::stats::{median, tmean, vmax}; +use rustfft::num_complex::Complex; +use rustfft::FftPlanner; +use std::cell::Cell; + +/// Result of one analysis pass over a block of audio. +#[derive(Clone, Debug)] +pub struct TimingResult { + /// Detected period in samples (time between consecutive ticks). + pub period: f64, + /// Rate error in seconds per day (positive = fast). + pub rate_sday: f64, + /// Beat error in milliseconds (tic-to-toc asymmetry). + pub beat_error_ms: f64, + /// Balance amplitude in degrees, if it could be determined. + pub amplitude_deg: Option, + /// Standard deviation of the period estimate in samples. + pub sigma: f64, + /// Folded average waveform over one period, median-subtracted. + pub waveform: Vec, + /// Beat rate in beats per hour the rate was computed against. + pub bph: u32, +} + +/// Configurable analyzer. Reuse one instance across blocks; it caches the +/// FFT plans and filter state. +/// Snap a detected beats-per-hour value to the nearest standard beat rate. +fn snap_bph(detected: f64) -> f64 { + const STANDARDS: [f64; 7] = [12000.0, 14400.0, 18000.0, 21600.0, 25200.0, 28800.0, 36000.0]; + STANDARDS + .iter() + .copied() + .min_by(|a, b| { + (a - detected).abs().partial_cmp(&(b - detected).abs()).unwrap() + }) + .unwrap_or(28800.0) +} + +pub struct Analyzer { + pub sample_rate: u32, + /// Beats per hour of the movement under test; 0 = auto-detect. + pub bph: u32, + /// Lift angle of the movement in degrees (typically 49-53). + pub lift_angle: f64, + /// Enable the impulsive-noise suppressor. + pub noise_suppressor: bool, + lpf: Biquad, + last_sigma: Cell, +} + +impl Analyzer { + pub fn new(sample_rate: u32) -> Self { + Analyzer { + sample_rate, + bph: 0, + lift_angle: 52.0, + noise_suppressor: true, + lpf: Biquad::low_pass(crate::FILTER_CUTOFF / sample_rate as f64), + last_sigma: Cell::new(0.0), + } + } + + /// Analyze one block of samples. `samples` should be at least one second + /// long; several seconds gives more stable results. Returns None when no + /// plausible tick train was found. + pub fn analyze(&self, samples: &[f32]) -> Option { + if samples.len() < self.sample_rate as usize { + return None; + } + let mut s = samples.to_vec(); + let n = s.len(); + let sr = self.sample_rate as usize; + + self.prepare_data(&mut s); + let period = self.compute_period(&s, n)?; + let waveform = self.compute_waveform(&s, period, n); + let (beat_error_ms, tic, toc) = self.compute_beat_error(&waveform, period)?; + let amplitude_deg = self.compute_amplitude(&waveform, period, tic, toc); + + let detected_bph = 2.0 * 3600.0 * sr as f64 / period; + let bph = if self.bph != 0 { + self.bph as f64 + } else { + snap_bph(detected_bph) + }; + let nominal = 7200.0 * sr as f64 / bph; + let rate_sday = (nominal / period - 1.0) * 86400.0; + + Some(TimingResult { + period, + rate_sday, + beat_error_ms, + amplitude_deg, + sigma: self.last_sigma.get(), + waveform, + bph: bph as u32, + }) + } + + /// Rectify, low-pass, normalize and window the input; then compute the + /// autocorrelation into the second half of `s` (as tg does with + /// samples_sc). + fn prepare_data(&self, s: &mut Vec) { + let n = s.len(); + let sr = self.sample_rate as usize; + if self.noise_suppressor { + Self::noise_suppressor(s, sr); + } + for v in s.iter_mut() { + *v = v.abs(); + } + self.lpf.run(s); + let average: f64 = s.iter().map(|&v| v as f64).sum::() / n as f64; + for v in s.iter_mut() { + *v -= average as f32; + } + let edge = sr / 10; + for i in 0..edge.min(n / 2) { + let k = (1.0 - (i as f64 * std::f64::consts::PI / edge as f64).cos()) / 2.0; + s[i] *= k as f32; + let j = n - i - 1; + s[j] *= k as f32; + } + } + + /// Zero out samples in windows whose energy greatly exceeds the median + /// window energy (impulsive noise gating), ported from tg. + fn noise_suppressor(s: &mut [f32], sr: usize) { + let n = s.len(); + let window = sr / 50; + let sq: Vec = s.iter().map(|v| v * v).collect(); + let mut r_av: f64 = sq[..window].iter().map(|&v| v as f64).sum(); + let mut b = vec![0f32; n]; + for i in 0..n { + b[i] = r_av as f32; + if i + window == n { + break; + } + r_av += sq[i + window] as f64 - sq[i] as f64; + } + let m = n - window + 1; + let step = sr / 2; + let mut a = Vec::with_capacity(m / step + 1); + let mut i = 0; + while i + step <= m { + a.push(vmax(&b, i, i + step).0); + i += step; + } + let k = median(&mut a); + for i in 0..n { + let mut j = i as isize - (window / 2) as isize; + if j < 0 { + j = 0; + } + let upper = n.saturating_sub(window) as isize; + if j > upper { + j = upper; + } + if b[j as usize] > 2.0 * k { + s[i] = 0.0; + } + } + } + + /// Autocorrelation of s (length n) via FFT; result has n points. + fn autocorrelate(&self, s: &[f32], n: usize) -> Vec { + let mut planner = FftPlanner::new(); + let fft = planner.plan_fft_forward(2 * n); + let mut buf: Vec> = s.iter().map(|&v| Complex::new(v, 0.0)).collect(); + buf.resize(2 * n, Complex::default()); + fft.process(&mut buf); + for c in buf.iter_mut() { + *c = *c * c.conj(); + } + let ifft = planner.plan_fft_inverse(2 * n); + ifft.process(&mut buf); + buf[..n].iter().map(|c| c.re).collect() + } + + /// tg's peak_detector: the maximum of buff[a..=b] is accepted only if it + /// is a real peak (rises above the local median, not part of a sustained + /// plateau). Returns the index or None. + fn peak_detector(buff: &[f32], a: usize, b: usize) -> Option { + let (max, i_max) = vmax(buff, a, b + 1); + if max <= 0.0 { + return None; + } + let med = median(&mut buff[a..=b].to_vec()); + if buff[a + 1..i_max].iter().all(|&v| v > med) { + return None; + } + if buff[i_max + 1..=b].iter().all(|&v| v > med) { + return None; + } + let mut cnt = 0; + let mut down = true; + for &v in &buff[a + 1..=b] { + if v > (max + med) / 2.0 { + if down { + cnt += 1; + } + down = false; + } + if v < med { + down = true; + } + } + if cnt > 20 { + return None; + } + Some(i_max) + } + + /// Autocorrelation-based period estimation, ported from tg's + /// estimate_period(): find the first candidate peak, try submultiples, + /// and validate against the 1.5x peak. + fn estimate_period(&self, ac: &[f32], sr: usize) -> Option { + let first = vmax(ac, sr / 12, sr.min(ac.len())).1; + let a = (sr / 12).max(first.saturating_sub(sr / 12)); + let b = (first + sr / 12).min(ac.len() - 1); + let first_estimate = Self::peak_detector(ac, a, b)?; + let mut estimate = first_estimate; + let mut factor = 1; + let mut fct = 2; + while first_estimate / fct > sr / 12 { + let c = first_estimate / fct; + if c > sr / 50 { + if let Some(ne) = + Self::peak_detector(ac, c - sr / 50, (c + sr / 50).min(ac.len() - 1)) + { + if ac[ne] > 0.9 * ac[first_estimate] { + estimate = ne; + factor = fct; + } + } + } + fct += 1; + } + let a = estimate * 3 / 2; + let max = if a < ac.len() { + vmax(ac, a.saturating_sub(sr / 50), (a + sr / 50).min(ac.len())).0 + } else { + 0.0 + }; + if max < 0.2 * ac[estimate] { + let doubled = first_estimate * 2 / factor; + if doubled < sr { + return Self::peak_detector( + ac, + doubled.saturating_sub(sr / 50), + (doubled + sr / 50).min(ac.len() - 1), + ); + } + return None; + } + Some(estimate) + } + + /// Refine the period estimate by locating peaks at successive multiples, + /// averaging the per-cycle estimates, ported from tg's compute_period(). + fn compute_period(&self, s: &[f32], n: usize) -> Option { + let sr = self.sample_rate as usize; + let ac = self.autocorrelate(s, n); + let estimate = if self.bph != 0 { + let c = 7200 * sr / self.bph as usize; + if c <= sr / 50 || c + sr / 50 >= ac.len() { + return None; + } + Self::peak_detector(&ac, c - sr / 50, c + sr / 50)? as f64 + } else { + self.estimate_period(&ac, sr)? as f64 + }; + let delta = sr as f64 * 0.02; + let mut new_estimate = estimate; + let mut sum = 0.0; + let mut sq_sum = 0.0; + let mut count = 0; + let mut cycle = 1usize; + loop { + let inf = (new_estimate * cycle as f64 - delta).floor() as usize; + let sup = (new_estimate * cycle as f64 + delta).ceil() as usize; + if sup > n * 2 / 3 || sup >= ac.len() { + break; + } + new_estimate = Self::peak_detector(&ac, inf, sup)? as f64; + new_estimate /= cycle as f64; + if new_estimate < estimate - delta || new_estimate > estimate + delta { + return None; + } + if inf > n / 3 { + sum += new_estimate; + sq_sum += new_estimate * new_estimate; + count += 1; + } + cycle += 1; + } + let period = if count > 0 { sum / count as f64 } else { estimate }; + self.last_sigma + .set(if count > 1 { + ((sq_sum - count as f64 * period * period) / (count - 1) as f64).sqrt() + } else { + 0.0 + }); + if period >= 1.2 * 3600.0 * 2.0 * sr as f64 / if self.bph != 0 { self.bph } else { 18000 } as f64 { + return None; + } + Some(period) + } + + /// Fold the rectified signal at `period` and average into a one-period + /// waveform, ported from tg's compute_phase()/compute_waveform(). + fn compute_waveform(&self, s: &[f32], period: f64, n: usize) -> Vec { + let count = period as usize; + let mut wf = vec![0f64; count]; + let mut j = 0usize; + let mut i = 0usize; + while (j as f64 * period).round() < n as f64 { + let start = (j as f64 * period).round() as usize; + i = 0; + while i < count && start + i < n { + wf[i] += s[start + i] as f64; + i += 1; + } + j += 1; + } + let lastfull = i; + let mut x = 0.0; + let mut y = 0.0; + for (i, &w) in wf.iter().enumerate() { + let a = i as f64 * (2.0 * std::f64::consts::PI / period); + let w = w / (j as f64 - if i >= lastfull { 1.0 } else { 0.0 }); + x += w * a.cos(); + y += w * a.sin(); + } + let phase = period * (std::f64::consts::PI + y.atan2(x)) / (2.0 * std::f64::consts::PI); + + let wf_size = count; + let binsize = 1 + n / wf_size; + let mut bin = vec![0f32; binsize + 1]; + let mut wf2 = vec![0f32; wf_size]; + let phase = phase.round() as usize; + for i in 0..wf_size { + let k = (i + phase) % wf_size; + let mut j = 0; + loop { + let idx = k + j * wf_size; + if idx >= n { + break; + } + bin[j] = s[idx]; + j += 1; + } + wf2[i] = tmean(&mut bin[..j]); + } + let step = (wf_size / 100).max(1); + let mut sc = Vec::new(); + let mut i = 0; + while i * step < wf_size { + sc.push(wf2[i * step]); + i += 1; + } + let nl = median(&mut sc); + for v in wf2.iter_mut() { + *v -= nl; + } + wf2 + } + + /// Beat error: distance between the tic and toc peaks in the folded + /// waveform, found via the waveform autocorrelation, ported from tg's + /// compute_parameters(). Returns (beat error ms, tic index, toc index). + fn compute_beat_error(&self, wf: &[f32], period: f64) -> Option<(f64, usize, usize)> { + let sr = self.sample_rate as usize; + let n = wf.len(); + let ac = self.autocorrelate(wf, n); + let half = (period / 2.0).floor() as usize; + let a = half.saturating_sub(sr / 50); + let b = (half + sr / 50).min(n - 1); + if b <= a { + return None; + } + let tic_to_toc = Self::peak_detector(&ac, a, b)?; + let be = period / 2.0 - tic_to_toc as f64; + + // Fold tic and toc together and smooth to locate the tic peak. + let m = n - tic_to_toc; + let mut fold = vec![0f32; m]; + for i in 0..m { + fold[i] = wf[i] + wf[i + tic_to_toc]; + } + let window = (sr / 2000).max(1); + if m <= window { + return None; + } + let smooth = Self::smooth(&fold, window); + let (max, max_i) = vmax(&smooth, 0, smooth.len()); + if max <= 0.0 { + return None; + } + let tic = max_i; + let toc = tic + tic_to_toc; + Some((be * 1000.0 / sr as f64, tic, toc)) + } + + /// Amplitude from the tic/toc pulse widths, ported from tg's + /// compute_amplitude(). + fn compute_amplitude(&self, wf: &[f32], period: f64, tic: usize, toc: usize) -> Option { + let sr = self.sample_rate as usize; + let wf_size = wf.len(); + let window = sr / 1000; + let mut ext = wf.to_vec(); + ext.extend_from_within(0..window.min(wf_size)); + let smooth = Self::smooth(&ext, window); + if smooth.is_empty() { + return None; + } + + let glob_max = vmax(&smooth, 0, smooth.len().min(period.ceil() as usize)).0; + if glob_max <= 0.0 { + return None; + } + let mut max = 0.0f32; + for &t in &[tic, toc] { + let mut j = ((t as f64 + period / 8.0) % period) as usize; + for _ in 0..(period / 8.0) as usize { + if smooth[j] > max { + max = smooth[j]; + } + j += 1; + if j as f64 > period { + j = 0; + } + } + } + let mut threshold = (0.01 * glob_max).max(1.4 * max); + + let mut tic_pulse; + let mut toc_pulse; + while threshold < 0.2 * glob_max { + tic_pulse = -1.0; + toc_pulse = -1.0; + let mut ok = true; + for (k, &t) in [toc, tic].iter().enumerate() { + let mut j = ((t as f64 + 7.0 * period / 8.0) % period) as usize; + let mut i = 0; + let eighth = (period / 8.0) as usize; + while i < eighth { + if smooth[j] > threshold { + break; + } + i += 1; + j += 1; + if j as f64 > period { + j = 0; + } + } + let mut max = 0.0f32; + while i < eighth { + let x = smooth[j]; + if x > max { + max = x; + } else { + break; + } + i += 1; + j += 1; + if j as f64 > period { + j = 0; + } + } + if i < eighth { + let pulse = period / 8.0 - i as f64 - 1.0; + if k == 0 { + tic_pulse = pulse; + } else { + toc_pulse = pulse; + } + } else { + ok = false; + break; + } + } + if ok { + let tic_amp_abs = 0.5 / (std::f64::consts::PI * tic_pulse / period).sin(); + let toc_amp_abs = 0.5 / (std::f64::consts::PI * toc_pulse / period).sin(); + let tic_amp = self.lift_angle * tic_amp_abs; + let toc_amp = self.lift_angle * toc_amp_abs; + if (135.0..360.0).contains(&tic_amp) + && (135.0..360.0).contains(&toc_amp) + && (tic_amp - toc_amp).abs() < 60.0 + { + return Some(self.lift_angle * (tic_amp_abs + toc_amp_abs) / 2.0); + } + } + threshold *= 1.4; + } + None + } + + /// Exponential-decay peak smoother, ported from tg's smooth(). + fn smooth(input: &[f32], window: usize) -> Vec { + let size = input.len(); + if window == 0 || window >= size { + return Vec::new(); + } + let k = 1.0 - 1.0 / window as f64; + let mut r_av = 0.0f64; + let mut u = 0.0f64; + for &x in input.iter().take(window) { + u *= k; + if x as f64 > u { + u = x as f64; + } + r_av += u; + } + let mut w = 0.0f64; + let mut out = vec![0f32; size - window]; + for i in 0..size - window { + out[i] = r_av as f32; + u *= k; + w *= k; + let x = input[i + window]; + let y = input[i]; + if x as f64 > u { + u = x as f64; + } + if y as f64 > w { + w = y as f64; + } + r_av += u - w; + } + out + } +} diff --git a/crates/regulator-core/src/filters.rs b/crates/regulator-core/src/filters.rs new file mode 100644 index 0000000..81b8594 --- /dev/null +++ b/crates/regulator-core/src/filters.rs @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0 +//! Biquad filters, ported from tg's algo.c. + +#[derive(Clone, Copy, Debug)] +pub struct Biquad { + pub a0: f64, + pub a1: f64, + pub a2: f64, + pub b1: f64, + pub b2: f64, +} + +impl Biquad { + /// Low-pass filter; `freq` is normalized to the sample rate (cutoff/sr). + pub fn low_pass(freq: f64) -> Self { + let k = (std::f64::consts::PI * freq).tan(); + let norm = 1.0 / (1.0 + k * std::f64::consts::SQRT_2 + k * k); + let a0 = k * k * norm; + Biquad { + a0, + a1: 2.0 * a0, + a2: a0, + b1: 2.0 * (k * k - 1.0) * norm, + b2: (1.0 - k * std::f64::consts::SQRT_2 + k * k) * norm, + } + } + + /// In-place Direct Form 1 filtering, matching tg's run_filter(). + pub fn run(&self, buff: &mut [f32]) { + let mut z1 = 0.0; + let mut z2 = 0.0; + for v in buff.iter_mut() { + let input = *v as f64; + let out = input * self.a0 + z1; + z1 = input * self.a1 + z2 - self.b1 * out; + z2 = input * self.a2 - self.b2 * out; + *v = out as f32; + } + } +} diff --git a/crates/regulator-core/src/lib.rs b/crates/regulator-core/src/lib.rs new file mode 100644 index 0000000..2dc1b01 --- /dev/null +++ b/crates/regulator-core/src/lib.rs @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 +//! regulator-core: the signal-processing heart of regulator. +//! +//! A Rust port of the timing algorithm from tg (Copyright 2015 Marcello +//! Mamino, GPLv2, https://github.com/xyzzy42/tg). The pipeline: +//! +//! 1. optionally suppress impulsive noise (windowed energy gating) +//! 2. rectify and low-pass the microphone signal +//! 3. estimate the tick period via FFT-based autocorrelation +//! 4. fold samples at the detected period into an average waveform +//! 5. locate the tic/toc events, then compute rate, beat error and +//! the balance amplitude from the pulse widths. + +pub mod analyze; +pub mod filters; +pub mod signal; +pub mod stats; + +pub use analyze::{Analyzer, TimingResult}; +pub use signal::SyntheticWatch; +pub const FILTER_CUTOFF: f64 = 3000.0; diff --git a/crates/regulator-core/src/signal.rs b/crates/regulator-core/src/signal.rs new file mode 100644 index 0000000..a19fbbf --- /dev/null +++ b/crates/regulator-core/src/signal.rs @@ -0,0 +1,141 @@ +// SPDX-License-Identifier: GPL-2.0 +//! Synthetic watch signal generator, used by the tests and the TUI demo +//! mode. Produces a train of decaying tick bursts at the requested rate. + +/// Parameters of the synthetic movement. +#[derive(Clone, Copy, Debug)] +pub struct SyntheticWatch { + /// Beats per hour, e.g. 28800. + pub bph: u32, + /// Rate error in seconds per day (positive = fast). + pub rate_sday: f64, + /// Beat error in milliseconds. + pub beat_error_ms: f64, + /// Balance amplitude in degrees (affects pulse width). + pub amplitude_deg: f64, +} + +impl SyntheticWatch { + /// Generate `duration_s` seconds of audio at `sample_rate`. + pub fn generate(&self, sample_rate: u32, duration_s: f64) -> Vec { + // Ticks (tic, toc, tic, ...) occur every 3600/bph seconds; the + // same-type period the analyzer locks onto is twice that. + let nominal_period = 2.0 * 3600.0 / self.bph as f64; + let period = nominal_period * 86400.0 / (86400.0 + self.rate_sday); + let spacing = period / 2.0; + let n = (duration_s * sample_rate as f64) as usize; + let mut out = vec![0f32; n]; + let sr = sample_rate as f64; + let burst_len = (0.004 * sr) as usize; + let mut t = 0.0f64; + let mut flip = false; + let mut rng = 0x1234_5678u64; + while t < duration_s { + let idx = (t * sr) as usize; + let shift = if flip { + self.beat_error_ms / 2000.0 + } else { + -self.beat_error_ms / 2000.0 + }; + let start = idx as isize + (shift * sr) as isize; + if start >= 0 && (start as usize) < n.saturating_sub(burst_len) { + let base = start as usize; + // Pulse width follows the lift-angle/impulse relation the + // analyzer inverts: amp_abs = 0.5 / sin(pi * pulse / period). + // A 52 deg lift angle is assumed here. + let amp_abs = self.amplitude_deg / 52.0; + let width = (period + * (0.5 / amp_abs).asin() + / std::f64::consts::PI + * sr) as usize; + for i in 0..width.min(burst_len) { + let tt = i as f64 / sr; + let env = (-tt * 1500.0).exp(); + let carrier = (2.0 * std::f64::consts::PI * 3500.0 * tt).sin(); + out[base + i] += (env * carrier * 0.8) as f32; + } + } + flip = !flip; + t += spacing; + // A little jitter so the signal is not perfectly periodic. + rng = rng.wrapping_mul(6364136223846793005).wrapping_add(1); + t += ((rng >> 33) as f64 / u32::MAX as f64 - 0.5) * 1e-5; + } + // Background noise. + let mut noise_rng = 0xdead_beefu64; + for v in out.iter_mut() { + noise_rng = noise_rng + .wrapping_mul(6364136223846793005) + .wrapping_add(1442695040888963407); + let r = ((noise_rng >> 11) as i64 % 2000) as f64 / 1000.0 - 1.0; + *v += (r * 0.02) as f32; + } + out + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::analyze::Analyzer; + + const SR: u32 = 44100; + + #[test] + fn detects_rate_error() { + let watch = SyntheticWatch { + bph: 28800, + rate_sday: 12.0, + beat_error_ms: 0.4, + amplitude_deg: 270.0, + }; + let samples = watch.generate(SR, 4.0); + let mut an = Analyzer::new(SR); + an.bph = 28800; + let r = an.analyze(&samples).expect("analysis failed"); + assert!((r.rate_sday - 12.0).abs() < 3.0, "rate: {}", r.rate_sday); + } + + #[test] + fn auto_detects_beat_rate() { + let watch = SyntheticWatch { + bph: 18000, + rate_sday: -5.0, + beat_error_ms: 0.0, + amplitude_deg: 250.0, + }; + let samples = watch.generate(SR, 6.0); + let an = Analyzer::new(SR); + let r = an.analyze(&samples).expect("analysis failed"); + let detected_bph = 2.0 * 3600.0 * SR as f64 / r.period; + assert!( + (detected_bph - 18000.0).abs() < 100.0, + "detected bph: {detected_bph}" + ); + } + + #[test] + fn detects_beat_error() { + let watch = SyntheticWatch { + bph: 21600, + rate_sday: 0.0, + beat_error_ms: 1.2, + amplitude_deg: 260.0, + }; + let samples = watch.generate(SR, 4.0); + let mut an = Analyzer::new(SR); + an.bph = 21600; + let r = an.analyze(&samples).expect("analysis failed"); + assert!( + (r.beat_error_ms - 1.2).abs() < 0.8, + "beat error: {}", + r.beat_error_ms + ); + } + + #[test] + fn rejects_silence() { + let an = Analyzer::new(SR); + assert!(an.analyze(&vec![0.0; SR as usize * 2]).is_none()); + } +} diff --git a/crates/regulator-core/src/stats.rs b/crates/regulator-core/src/stats.rs new file mode 100644 index 0000000..2c523d1 --- /dev/null +++ b/crates/regulator-core/src/stats.rs @@ -0,0 +1,132 @@ +// SPDX-License-Identifier: GPL-2.0 +//! Order statistics helpers ported from tg's algo.c: quickselect with a +//! median-of-three pivot, trimmed means, and running max. + +/// Max of `v[a..b]` (exclusive end), also returning the argmax index. +pub fn vmax(v: &[f32], a: usize, b: usize) -> (f32, usize) { + let mut max = v[a]; + let mut i_max = a; + for (i, &x) in v.iter().enumerate().take(b).skip(a + 1) { + if x > max { + max = x; + i_max = i; + } + } + (max, i_max) +} + +fn pivot(x: &[f32], l: usize, r: usize) -> usize { + let m = (l + r) / 2; + if x[l] < x[r] { + if x[m] <= x[l] { + l + } else if x[m] >= x[r] { + r + } else { + m + } + } else if x[m] <= x[r] { + r + } else if x[m] >= x[l] { + l + } else { + m + } +} + +/// Partition `x` in descending order at rank `k`: afterwards +/// `x[0..k] >= x[k] >= x[k+1..]`. Average case O(n). +pub fn quickselect(x: &mut [f32], k: usize) { + let n = x.len(); + let mut l = 0usize; + let mut r = n - 1; + loop { + if l == r { + return; + } + if r - l == 1 { + if x[l] < x[r] { + x.swap(l, r); + } + return; + } + let p = pivot(x, l, r); + let pv = x[p]; + x[p] = x[r]; + let mut p = l; + for i in l..r { + if x[i] > pv { + x.swap(i, p); + p += 1; + } + } + x[r] = x[p]; + x[p] = pv; + if k == p { + return; + } + if k < p { + if p == 0 { + return; + } + r = p - 1; + } else { + l = p + 1; + } + } +} + +/// Median of a slice, via quickselect; O(n) on average. +pub fn median(x: &mut [f32]) -> f32 { + if x.is_empty() { + return 0.0; + } + let k = x.len() / 2; + quickselect(x, k); + x[k] +} + +fn mean_less_greatest(x: &[f32]) -> f32 { + let mut greatest = x[0]; + let mut sum = x[0]; + for &v in &x[1..] { + sum += v; + if v > greatest { + greatest = v; + } + } + (sum - greatest) / (x.len() - 1) as f32 +} + +fn mean_less_two_greatest(x: &[f32]) -> f32 { + let mut sum = x[0]; + let mut greatest = [x[0], f32::MIN]; + for &v in &x[1..] { + sum += v; + if v > greatest[0] { + greatest[1] = greatest[0]; + greatest[0] = v; + } else if v > greatest[1] { + greatest[1] = v; + } + } + (sum - greatest[0] - greatest[1]) / (x.len() - 2) as f32 +} + +/// Mean of the lower four quintiles: the largest 20% of values are excluded. +/// May reorder `x`. +pub fn tmean(x: &mut [f32]) -> f32 { + let n = x.len(); + if n == 0 { + return 0.0; + } + if n <= 5 { + mean_less_greatest(x) + } else if n <= 10 { + mean_less_two_greatest(x) + } else { + let k = (n + 4) / 5; + quickselect(x, k); + x[k..].iter().sum::() / (n - k) as f32 + } +} diff --git a/crates/regulator-tui/Cargo.toml b/crates/regulator-tui/Cargo.toml new file mode 100644 index 0000000..a464aaf --- /dev/null +++ b/crates/regulator-tui/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "regulator-tui" +description = "Terminal UI for the regulator watch timing machine" +version.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true + +[[bin]] +name = "regulator" +path = "src/main.rs" + +[features] +default = ["audio"] +# Live microphone capture via cpal. Requires ALSA/WinAudio/CoreAudio at build +# time; disable with --no-default-features to build everywhere else. +audio = ["dep:cpal"] + +[dependencies] +regulator-core = { path = "../regulator-core" } +ratatui = "0.29" +crossterm = "0.28" +anyhow = "1" +cpal = { version = "0.15", optional = true } diff --git a/crates/regulator-tui/src/audio.rs b/crates/regulator-tui/src/audio.rs new file mode 100644 index 0000000..683802c --- /dev/null +++ b/crates/regulator-tui/src/audio.rs @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0 +//! Live audio capture via cpal. Compiled only with the `audio` feature. + +use anyhow::{Context, Result}; +use std::sync::mpsc::Sender; + +/// Spawn the default input device at 44.1 kHz mono and stream f32 samples +/// to `tx`. +pub fn spawn_capture(tx: Sender) -> Result<()> { + let host = cpal::default_host(); + let device = host + .default_input_device() + .context("no audio input device found")?; + let supported = device + .build_input_stream_config() + .or_else(|_| Ok::({ + device.default_input_config() + })?)?; + let config = cpal::StreamConfig { + channels: 1, + sample_rate: cpal::SampleRate(44100), + buffer_size: supported.buffer_size.clone(), + }; + let stream = device.build_input_stream( + &config, + move |data: &[f32], _| { + for &s in data { + let _ = tx.send(s); + } + }, + |err| eprintln!("audio error: {err}"), + None, + )?; + stream.play()?; + std::mem::forget(stream); + Ok(()) +} diff --git a/crates/regulator-tui/src/main.rs b/crates/regulator-tui/src/main.rs new file mode 100644 index 0000000..0a7d7b5 --- /dev/null +++ b/crates/regulator-tui/src/main.rs @@ -0,0 +1,160 @@ +// SPDX-License-Identifier: GPL-2.0 +//! regulator: a watch timing machine for the terminal. + +mod ui; +#[cfg(feature = "audio")] +mod audio; + +use anyhow::Result; +use crossterm::event::{self, Event, KeyCode, KeyEventKind}; +use crossterm::terminal::{ + disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen, +}; +use ratatui::backend::CrosstermBackend; +use ratatui::Terminal; +use regulator_core::{Analyzer, SyntheticWatch, TimingResult}; +use std::sync::mpsc; +use std::sync::{Arc, Mutex}; +use std::time::{Duration, Instant}; +use ui::Settings; + +const SAMPLE_RATE: u32 = 44100; +const BLOCK_SECONDS: f64 = 4.0; + +fn main() -> Result<()> { + let demo = std::env::args().any(|a| a == "--demo"); + let settings = Arc::new(Mutex::new(Settings::default())); + settings.lock().unwrap().source = if demo { "demo" } else { "mic" }.into(); + + let (result_tx, result_rx) = mpsc::channel::>(); + + if demo { + spawn_demo_worker(result_tx, settings.clone()); + } else { + #[cfg(feature = "audio")] + { + let (sample_tx, sample_rx) = mpsc::channel::(); + audio::spawn_capture(sample_tx)?; + spawn_live_worker(sample_rx, result_tx, settings.clone()); + } + #[cfg(not(feature = "audio"))] + { + anyhow::bail!("built without the `audio` feature; run with --demo"); + } + } + + run_tui(result_rx, settings) +} + +fn build_analyzer(settings: &Settings) -> Analyzer { + let mut an = Analyzer::new(SAMPLE_RATE); + an.bph = settings.bph; + an.lift_angle = settings.lift_angle; + an.noise_suppressor = settings.noise_suppressor; + an +} + +fn analyze_block(samples: &[f32], settings: &Settings) -> Option { + build_analyzer(settings).analyze(samples) +} + +fn spawn_demo_worker(tx: mpsc::Sender>, settings: Arc>) { + std::thread::spawn(move || { + let watch = SyntheticWatch { + bph: 28800, + rate_sday: 9.0, + beat_error_ms: 0.6, + amplitude_deg: 275.0, + }; + let samples = watch.generate(SAMPLE_RATE, 60.0); + let mut start = 0usize; + let block = (BLOCK_SECONDS * SAMPLE_RATE as f64) as usize; + loop { + let end = (start + block).min(samples.len()); + let res = analyze_block(&samples[start..end], &settings.lock().unwrap().clone()); + let _ = tx.send(res); + if end == samples.len() { + start = 0; + } else { + start = end; + } + std::thread::sleep(Duration::from_millis(500)); + } + }); +} + +#[cfg(feature = "audio")] +fn spawn_live_worker( + rx: mpsc::Receiver, + tx: mpsc::Sender>, + settings: Arc>, +) { + std::thread::spawn(move || { + let block = (BLOCK_SECONDS * SAMPLE_RATE as f64) as usize; + let mut buf: Vec = Vec::with_capacity(block * 2); + loop { + while let Ok(s) = rx.try_recv() { + buf.push(s); + if buf.len() > block * 2 { + buf.drain(..block); + } + } + if buf.len() >= block { + let res = analyze_block(&buf[buf.len() - block..], &settings.lock().unwrap().clone()); + let _ = tx.send(res); + } + std::thread::sleep(Duration::from_millis(100)); + } + }); +} + +fn run_tui( + rx: mpsc::Receiver>, + settings: Arc>, +) -> Result<()> { + enable_raw_mode()?; + let mut stdout = std::io::stdout(); + crossterm::execute!(stdout, EnterAlternateScreen)?; + let mut terminal = Terminal::new(CrosstermBackend::new(stdout))?; + let mut result: Option = None; + let mut last_draw = Instant::now(); + + loop { + if event::poll(Duration::from_millis(50))? { + if let Event::Key(key) = event::read()? { + if key.kind == KeyEventKind::Press { + let mut s = settings.lock().unwrap(); + match key.code { + KeyCode::Char('q') | KeyCode::Esc => break, + KeyCode::Left | KeyCode::Right => { + const BPH: [u32; 6] = [0, 18000, 21600, 25200, 28800, 36000]; + let idx = BPH.iter().position(|&b| b == s.bph).unwrap_or(0); + let next = if key.code == KeyCode::Right { + (idx + 1) % BPH.len() + } else { + (idx + BPH.len() - 1) % BPH.len() + }; + s.bph = BPH[next]; + } + KeyCode::Char('+') | KeyCode::Char('=') => s.lift_angle += 1.0, + KeyCode::Char('-') => s.lift_angle -= 1.0, + KeyCode::Char('n') => s.noise_suppressor = !s.noise_suppressor, + _ => {} + } + } + } + } + while let Ok(r) = rx.try_recv() { + result = r; + } + if last_draw.elapsed() > Duration::from_millis(100) { + let s = settings.lock().unwrap().clone(); + terminal.draw(|f| ui::draw(f, &result, &s))?; + last_draw = Instant::now(); + } + } + + disable_raw_mode()?; + crossterm::execute!(terminal.backend_mut(), LeaveAlternateScreen)?; + Ok(()) +} diff --git a/crates/regulator-tui/src/ui.rs b/crates/regulator-tui/src/ui.rs new file mode 100644 index 0000000..9b90fec --- /dev/null +++ b/crates/regulator-tui/src/ui.rs @@ -0,0 +1,147 @@ +// SPDX-License-Identifier: GPL-2.0 +//! The ratatui interface: a clean three-zone layout. + +use ratatui::layout::{Alignment, Constraint, Direction, Layout, Margin, Rect}; +use ratatui::style::{Color, Modifier, Style}; +use ratatui::text::{Line, Span}; +use ratatui::widgets::{Block, Borders, Paragraph}; +use regulator_core::TimingResult; + +/// UI-level state shown in the status bar. +#[derive(Clone)] +pub struct Settings { + pub bph: u32, + pub lift_angle: f64, + pub noise_suppressor: bool, + pub source: String, +} + +impl Default for Settings { + fn default() -> Self { + Settings { + bph: 0, + lift_angle: 52.0, + noise_suppressor: true, + source: String::new(), + } + } +} + +pub fn draw(f: &mut ratatui::Frame, res: &Option, s: &Settings) { + let chunks = Layout::default() + .direction(Direction::Vertical) + .constraints([ + Constraint::Length(5), + Constraint::Min(10), + Constraint::Length(1), + ]) + .split(f.area()); + + draw_readout(f, chunks[0], res); + draw_waveform(f, chunks[1], res); + draw_status(f, chunks[2], s); +} + +fn draw_readout(f: &mut ratatui::Frame, area: Rect, res: &Option) { + let cols = Layout::default() + .direction(Direction::Horizontal) + .constraints([Constraint::Ratio(1, 3); 3]) + .split(area); + + let (rate, amp, be) = match res { + Some(r) => ( + ( + format!("{:+.1}", r.rate_sday), + " s/day", + rate_color(r.rate_sday), + ), + ( + match r.amplitude_deg { + Some(a) => format!("{a:.0}"), + None => "---".into(), + }, + " deg", + Color::Cyan, + ), + (format!("{:+.2}", r.beat_error_ms), " ms", Color::Magenta), + ), + None => ( + ("---".into(), " s/day", Color::DarkGray), + ("---".into(), " deg", Color::DarkGray), + ("---".into(), " ms", Color::DarkGray), + ), + }; + for (col, (title, (val, unit, color))) in ["Rate", "Amplitude", "Beat error"] + .into_iter() + .zip([rate, amp, be]) + .enumerate() + { + let block = Block::default().borders(Borders::ALL).title(format!(" {title} ")); + f.render_widget(block, cols[col]); + let a = cols[col].inner(Margin::new(2, 1)); + let p = Paragraph::new(Line::from(vec![ + Span::styled(val, Style::default().fg(color).add_modifier(Modifier::BOLD)), + Span::styled(unit, Style::default().fg(Color::Gray)), + ])) + .alignment(Alignment::Center); + f.render_widget(p, a); + } +} + +fn rate_color(rate: f64) -> Color { + if rate.abs() < 5.0 { + Color::Green + } else if rate.abs() < 15.0 { + Color::Yellow + } else { + Color::Red + } +} + +fn draw_waveform(f: &mut ratatui::Frame, area: Rect, res: &Option) { + let block = Block::default().borders(Borders::ALL).title(" Waveform "); + f.render_widget(block, area); + let inner = area.inner(Margin::new(1, 1)); + if inner.width < 2 || inner.height < 2 { + return; + } + let Some(r) = res else { return }; + let wf = &r.waveform; + if wf.is_empty() { + return; + } + let max = wf.iter().cloned().fold(0f32, f32::max).max(1e-9); + let mid = inner.height as f32 / 2.0; + for x in 0..inner.width { + let i = x as usize * wf.len() / inner.width as usize; + let v = wf[i.min(wf.len() - 1)] / max; + let h = ((v.abs() * mid).ceil() as u16).clamp(1, inner.height); + let y = if v >= 0.0 { + mid as u16 - h + } else { + mid as u16 + }; + let style = Style::default().fg(if v >= 0.0 { Color::Green } else { Color::Red }); + for dy in 0..h { + let py = (inner.y + y + dy).min(inner.y + inner.height - 1); + f.buffer_mut()[(inner.x + x, py)].set_char('█').set_style(style); + } + } +} + +fn draw_status(f: &mut ratatui::Frame, area: Rect, s: &Settings) { + let bph = if s.bph == 0 { "auto".into() } else { s.bph.to_string() }; + let line = Line::from(vec![ + Span::styled(format!(" {} ", s.source), Style::default().bg(Color::DarkGray)), + Span::raw(format!( + " bph:{bph} lift:{:.0}° noise:{} ", + s.lift_angle, + if s.noise_suppressor { "on" } else { "off" } + )), + Span::styled( + "←→ bph +/- lift n noise q quit", + Style::default().fg(Color::DarkGray), + ), + ]); + f.render_widget(Paragraph::new(line), area); +} diff --git a/docs/original-readme.md b/docs/original-readme.md new file mode 100644 index 0000000..e668dab --- /dev/null +++ b/docs/original-readme.md @@ -0,0 +1,212 @@ +# A program for timing mechanical watches + +The program tg is distributed under the GNU GPL license version 2. The full +source code of tg is available at +[https://github.com/xyzzy42/tg](https://github.com/xyzzy42/tg) and its +copyright belongs to the respective contributors. + +Tg is in development, and there is still no manual. Some info can be found +in this +[thread at WUS](http://forums.watchuseek.com/f6/open-source-timing-software-2542874.html), +in particular the calibration procedure is described at +[this post](http://forums.watchuseek.com/f6/open-source-timing-software-2542874-post29970370.html). + +## Install instructions + +Tg is known to work under Microsoft Windows, OS X, and Linux. Moreover it +should be possible to compile the source code under most modern UNIX-like +systems. See the sub-sections below for the details. + +### Windows + +Binaries can be found at https://tg.ciovil.li + +Unfortunately, these packages have not been updated since 2017. Help from +someone who can build the Windows installer version would be appreciated. +You'll need to [build from source](#compiling-on-windows) to get any features +from the last five plus years. + +### Macintosh + +A formula for the Homebrew package manager has been prepared by GitHub user +[dmnc](https://github.com/dmnc) and then updated by +[xyzzy42](https://github.com/xyzzy42). To use it, you need to install Homebrew +first (instructions on http://brew.sh). + +Then run the following command to check everything is set up correctly +and follow any instructions it gives you. + + brew doctor + +To install tg, run: + + brew install --HEAD xyzzy42/horology/tg-timer + +You can now launch tg by typing: + + tg-timer & + +### Debian or Debian-based (e.g. Mint, Ubuntu) + +Binary .deb packages can be downloaded from https://tg.ciovil.li + +Unfortunately, these packages have not been updated since 2017. + +### Fedora, CentOS or other Redhat-based + +Binary RPM packages are available from https://copr.fedorainfracloud.org/coprs/tpiepho/tg-timer/ + +This COPR repository can be added to dnf's list with: +```sh +dnf copr enable tpiepho/tg-timer +``` +Then tg-timer can be installed with `dnf install tg-timer`, or with any dnf +based GUI package installer. + +## Compiling from sources + +The source code of tg can probably be built by any C99 compiler, however only +gcc and clang have been tested. You need the following libraries: gtk+3, +portaudio2, fftw3 (all available as open source). + +The optional plotting features for audio filter response graphs and audio +spectrograms require Python. The follow Python modules are needed for all +features: numpy, scipy, matplotlib, libtfr. + +### Normal build +Get source: +```sh +git clone https://github.com/xyzzy42/tg.git +cd tg + +# Optional, check out a specific branch other than the default +git checkout new-stuff +``` + +Build it: +```sh +./autogen.sh +./configure +make +``` + +### Debug build +After the steps of a normal build, above, run: +```sh +make tg-timer-dbg +``` + +### Compiling on Windows + +It is suggested to use the MSYS2 platform. First install MSYS2 according +to the instructions at [http://www.msys2.org](http://www.msys2.org). The +[UCRT64 environment](https://www.msys2.org/docs/environments/) appears to work +best. + +From the MSYS2 UCRT64 terminal issue the following commands to install dependencies: + +```sh +pacman -S mingw-w64-ucrt-x86_64-gcc pkg-config mingw-w64-ucrt-x86_64-gtk3 mingw-w64-ucrt-x86_64-portaudio mingw-w64-ucrt-x86_64-fftw make git autoconf automake libtool +pacman -S mingw-w64-ucrt-x86_64-ninja mingw-w64-ucrt-x86_64-python-scipy mingw-w64-ucrt-x86_64-python-matplotlib mingw-w64-ucrt-x86_64-lapack mingw-w64-ucrt-x86_64-cython mingw-w64-ucrt-x86_64-python-pip +``` + +Add the folder "C:\msys64\ucrt64\bin" to the system path variable + +Install the libtfr package with: + +```sh +pip install libtfr +``` + +If that doesn't work, try building it manually: + +```sh +git clone https://github.com/melizalab/libtfr.git +cd libtfr +python setup.py install +``` + +Then follow the [normal build](#normal-build) instructions to clone the TG +repository and build it. + +If the "Signal" or "Filter Chain" dialogs do not work, this appears to be some +sort of [library issue with Python on Windows](https://github.com/xyzzy42/tg/issues/8#issuecomment-2351649260). +Try copying the `tg-timer.exe` file to `C:\msys64\ucrt64\bin` and run it from there. + +### Compiling on Debian + +To compile tg on Debian, install these dependencies: + +```sh +sudo apt-get install libgtk-3-dev libjack-jackd2-dev portaudio19-dev libfftw3-dev git autoconf automake libtool +``` + +Additional software is necessary for the optional Python graphing system, see +Fedora section for more information. Debian specific instructions welcome. + +Then follow the [normal build](#normal-build) instructions to clone the +repository and build it. + +The package libjack-jackd2-dev is not necessary, it only works around a +known bug (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=718221). + +### Compiling on Fedora + +To compile tg on Fedora, install these dependencies: + +```sh +sudo dnf install fftw-devel portaudio-devel gtk3-devel autoconf automake libtool +``` + +To use the Python graphing code (filter response and audio spectrogram) one +should also install: +```sh +sudo dnf install python3-devel python3-numpy python3-scipy python3-matplotlib +pip install --user libtfr +``` + +Then follow the [normal build](#normal-build) instructions to clone the +repository and build it. + +To build an RPM on Fedora or another RPM based distro, install the build +prerequisites and checkout the source as for compiling (above), then run +`rpmbuild` to create the RPM: + +```sh +rpmbuild --build-in-place -bb packaging/tg-timer.spec +``` + + +### Compiling on Macintosh + +To build on MacOS, install the follow dependencies with +[Homebrew](http://brew.sh). If you do not have Homebrew, the link above will +explain the install. + +```sh +brew install pkg-config autoconf automake libtool gtk+3 portaudio fftw gnome-icon-theme +``` + +To use the Python graphing code (filter response and audio spectrogram) one +should also install: + +```sh +brew install python numpy scipy +pip3 install matplotlib libtfr +``` + +If you have multiple versions of python3 installed, you might need to use a +specific version of pip, e.g. `pip3.11` in the above command. + +Then follow the [normal build](#normal-build) instructions to clone the +repository and build it. + +If you have multiple versions of Python installed and the configure script does +not detect the correct one, i.e. the one for which numpy, matplotlib, libtfr, +etc. have been installed for, then run the configure script as: + +```sh +PYTHON=python3.11 ./configure +``` + +Where `python3.11` is the correct version to use. From d10adade79721c4cf21653e153a72b852b849d48 Mon Sep 17 00:00:00 2001 From: borosf Date: Tue, 17 Nov 2026 19:46:09 +0000 Subject: [PATCH 02/20] Fix cpal capture: import Host/Device traits, handle sample formats, resample to 44.1 kHz mono Co-authored-by: borosf --- crates/regulator-tui/src/audio.rs | 111 ++++++++++++++++++++++++------ 1 file changed, 91 insertions(+), 20 deletions(-) diff --git a/crates/regulator-tui/src/audio.rs b/crates/regulator-tui/src/audio.rs index 683802c..bae97b6 100644 --- a/crates/regulator-tui/src/audio.rs +++ b/crates/regulator-tui/src/audio.rs @@ -2,36 +2,107 @@ //! Live audio capture via cpal. Compiled only with the `audio` feature. use anyhow::{Context, Result}; +use cpal::traits::{DeviceTrait, HostTrait, StreamTrait}; use std::sync::mpsc::Sender; -/// Spawn the default input device at 44.1 kHz mono and stream f32 samples -/// to `tx`. +const TARGET_RATE: f64 = 44100.0; + +/// Naive linear resampler state: converts the device's sample rate to the +/// 44.1 kHz mono stream the analyzer expects. +struct Resampler { + step: f64, + frac: f64, +} + +impl Resampler { + fn new(input_rate: f64) -> Self { + Resampler { + step: input_rate / TARGET_RATE, + frac: 0.0, + } + } + + fn push(&mut self, mono: &[f32], tx: &Sender) { + while self.frac < mono.len() as f64 { + let x = self.frac as usize; + let next = mono[(x + 1).min(mono.len() - 1)]; + let t = (self.frac - x as f64) as f32; + let s = mono[x] * (1.0 - t) + next * t; + let _ = tx.send(s); + self.frac += self.step; + } + self.frac -= mono.len() as f64; + } +} + +/// Spawn the default input device and stream mono 44.1 kHz f32 samples to +/// `tx`. pub fn spawn_capture(tx: Sender) -> Result<()> { let host = cpal::default_host(); let device = host .default_input_device() .context("no audio input device found")?; let supported = device - .build_input_stream_config() - .or_else(|_| Ok::({ - device.default_input_config() - })?)?; - let config = cpal::StreamConfig { - channels: 1, - sample_rate: cpal::SampleRate(44100), - buffer_size: supported.buffer_size.clone(), + .default_input_config() + .context("no supported input configuration")?; + let channels = supported.channels() as usize; + let config: cpal::StreamConfig = supported.into(); + let mut resampler = Resampler::new(config.sample_rate.0 as f64); + let tx_f32 = tx.clone(); + + let stream = match supported.sample_format() { + cpal::SampleFormat::F32 => device.build_input_stream( + &config, + move |data: &[f32], _| { + let mono = mix_mono(data, channels); + resampler.push(&mono, &tx_f32); + }, + err_cb, + None, + )?, + cpal::SampleFormat::I16 => device.build_input_stream( + &config, + move |data: &[i16], _| { + let mono = mix_mono( + &data.iter().map(|&v| v as f32 / i16::MAX as f32).collect::>(), + channels, + ); + resampler.push(&mono, &tx_f32); + }, + err_cb, + None, + )?, + cpal::SampleFormat::U16 => device.build_input_stream( + &config, + move |data: &[u16], _| { + let mono = mix_mono( + &data + .iter() + .map(|&v| (v as f32 - u16::MAX as f32 / 2.0) / (u16::MAX as f32 / 2.0)) + .collect::>(), + channels, + ); + resampler.push(&mono, &tx_f32); + }, + err_cb, + None, + )?, + other => anyhow::bail!("unsupported sample format: {other:?}"), }; - let stream = device.build_input_stream( - &config, - move |data: &[f32], _| { - for &s in data { - let _ = tx.send(s); - } - }, - |err| eprintln!("audio error: {err}"), - None, - )?; stream.play()?; std::mem::forget(stream); Ok(()) } + +fn err_cb(err: cpal::StreamError) { + eprintln!("audio error: {err}"); +} + +fn mix_mono(data: &[f32], channels: usize) -> Vec { + if channels <= 1 { + return data.to_vec(); + } + data.chunks(channels) + .map(|c| c.iter().sum::() / c.len() as f32) + .collect() +} From 3b385384329654490902ff8d50a4ecb40b7ce629 Mon Sep 17 00:00:00 2001 From: borosf Date: Tue, 17 Nov 2026 19:47:15 +0000 Subject: [PATCH 03/20] Fix use-after-move of SupportedStreamConfig in audio capture Co-authored-by: borosf --- crates/regulator-tui/src/audio.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/regulator-tui/src/audio.rs b/crates/regulator-tui/src/audio.rs index bae97b6..bf0706f 100644 --- a/crates/regulator-tui/src/audio.rs +++ b/crates/regulator-tui/src/audio.rs @@ -46,11 +46,12 @@ pub fn spawn_capture(tx: Sender) -> Result<()> { .default_input_config() .context("no supported input configuration")?; let channels = supported.channels() as usize; + let sample_format = supported.sample_format(); let config: cpal::StreamConfig = supported.into(); let mut resampler = Resampler::new(config.sample_rate.0 as f64); let tx_f32 = tx.clone(); - let stream = match supported.sample_format() { + let stream = match sample_format { cpal::SampleFormat::F32 => device.build_input_stream( &config, move |data: &[f32], _| { From 5d930688ceae8f8c965ad94d4d69fbf9ff08a2c1 Mon Sep 17 00:00:00 2001 From: borosf Date: Tue, 17 Nov 2026 19:48:13 +0000 Subject: [PATCH 04/20] Fix u16 underflow panic in waveform rendering Co-authored-by: borosf --- crates/regulator-tui/src/ui.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/regulator-tui/src/ui.rs b/crates/regulator-tui/src/ui.rs index 9b90fec..96b4415 100644 --- a/crates/regulator-tui/src/ui.rs +++ b/crates/regulator-tui/src/ui.rs @@ -117,7 +117,7 @@ fn draw_waveform(f: &mut ratatui::Frame, area: Rect, res: &Option) let v = wf[i.min(wf.len() - 1)] / max; let h = ((v.abs() * mid).ceil() as u16).clamp(1, inner.height); let y = if v >= 0.0 { - mid as u16 - h + (mid as u16).saturating_sub(h) } else { mid as u16 }; From 1ecf55342604aecb22fb3a50afee8a021f506849 Mon Sep 17 00:00:00 2001 From: borosf Date: Tue, 17 Nov 2026 19:56:13 +0000 Subject: [PATCH 05/20] Partial results, robust amplitude estimator, sub-sample period, FFT caching, egui GUI - TimingResult fields are now Option: rate/amplitude/beat error report independently and blank out when not found - Amplitude: direct impulse-duration measurement (region above 20% of the tic/toc peak) replacing tg's fragile escalating-threshold heuristic; validated at 264 deg vs 270 deg injected on the synthetic watch - Period: parabolic interpolation of the autocorrelation peak for sub-sample resolution - Analyzer caches FFT plans per length and reuses scratch buffers - New regulator-gui crate: egui frontend with live plot, settings panel, demo/mic sources shared with the TUI - TUI waveform renderer: proper scaling and tic/toc marker Co-authored-by: borosf --- Cargo.lock | 4713 ++++++++++++++++++++++---- Cargo.toml | 2 +- README.md | 24 +- crates/regulator-core/src/analyze.rs | 283 +- crates/regulator-core/src/signal.rs | 38 +- crates/regulator-gui/Cargo.toml | 21 + crates/regulator-gui/src/audio.rs | 109 + crates/regulator-gui/src/main.rs | 258 ++ crates/regulator-tui/src/ui.rs | 71 +- 9 files changed, 4680 insertions(+), 839 deletions(-) create mode 100644 crates/regulator-gui/Cargo.toml create mode 100644 crates/regulator-gui/src/audio.rs create mode 100644 crates/regulator-gui/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index ab3b41f..3ec32a8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,131 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "ab_glyph" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01c0457472c38ea5bd1c3b5ada5e368271cb550be7a4ca4a0b4634e9913f6cc2" +dependencies = [ + "ab_glyph_rasterizer", + "owned_ttf_parser", +] + +[[package]] +name = "ab_glyph_rasterizer" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "366ffbaa4442f4684d91e2cd7c5ea7c4ed8add41959a31447066e279e432b618" + +[[package]] +name = "accesskit" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf203f9d3bd8f29f98833d1fbef628df18f759248a547e7e01cfbf63cda36a99" + +[[package]] +name = "accesskit_atspi_common" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "890d241cf51fc784f0ac5ac34dfc847421f8d39da6c7c91a0fcc987db62a8267" +dependencies = [ + "accesskit", + "accesskit_consumer", + "atspi-common", + "serde", + "thiserror 1.0.69", + "zvariant", +] + +[[package]] +name = "accesskit_consumer" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db81010a6895d8707f9072e6ce98070579b43b717193d2614014abd5cb17dd43" +dependencies = [ + "accesskit", + "hashbrown 0.15.5", +] + +[[package]] +name = "accesskit_macos" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0089e5c0ac0ca281e13ea374773898d9354cc28d15af9f0f7394d44a495b575" +dependencies = [ + "accesskit", + "accesskit_consumer", + "hashbrown 0.15.5", + "objc2 0.5.3", + "objc2-app-kit 0.2.2", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "accesskit_unix" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "301e55b39cfc15d9c48943ce5f572204a551646700d0e8efa424585f94fec528" +dependencies = [ + "accesskit", + "accesskit_atspi_common", + "async-channel", + "async-executor", + "async-task", + "atspi", + "futures-lite", + "futures-util", + "serde", + "zbus", +] + +[[package]] +name = "accesskit_windows" +version = "0.29.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2d63dd5041e49c363d83f5419a896ecb074d309c414036f616dc0b04faca971" +dependencies = [ + "accesskit", + "accesskit_consumer", + "hashbrown 0.15.5", + "static_assertions", + "windows 0.61.3", + "windows-core 0.61.2", +] + +[[package]] +name = "accesskit_winit" +version = "0.29.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8cfabe59d0eaca7412bfb1f70198dd31e3b0496fee7e15b066f9c36a1a140a0" +dependencies = [ + "accesskit", + "accesskit_macos", + "accesskit_unix", + "accesskit_windows", + "raw-window-handle", + "winit", +] + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "ahash" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" +dependencies = [ + "cfg-if", + "getrandom 0.3.4", + "once_cell", + "version_check", + "zerocopy", +] + [[package]] name = "aho-corasick" version = "1.1.5" @@ -40,1281 +165,4099 @@ dependencies = [ ] [[package]] -name = "anyhow" -version = "1.0.104" +name = "android-activity" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" +checksum = "0f2a1bb052857d5dd49572219344a7332b31b76405648eabac5bc68978251bcd" +dependencies = [ + "android-properties", + "bitflags 2.13.2", + "cc", + "jni 0.22.4", + "libc", + "log", + "ndk 0.9.0", + "ndk-context", + "ndk-sys 0.6.0+11769913", + "num_enum", + "thiserror 2.0.21", +] [[package]] -name = "autocfg" -version = "1.5.1" +name = "android-properties" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" +checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04" [[package]] -name = "bindgen" -version = "0.72.1" +name = "android_system_properties" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895" +checksum = "ae221649c9976a6f6c56ae1facf410f3ddb33cc661c4b7b61020a912d4237fbc" dependencies = [ - "bitflags 2.13.2", - "cexpr", - "clang-sys", - "itertools", - "proc-macro2", - "quote", - "regex", - "rustc-hash", - "shlex 1.3.0", - "syn 2.0.119", + "libc", ] [[package]] -name = "bitflags" -version = "1.3.2" +name = "anyhow" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" [[package]] -name = "bitflags" -version = "2.13.2" +name = "arboard" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" +checksum = "aeb9553e62312c8756a5979254fc6d7da8bbeb5986a1e17037fab932f7037917" +dependencies = [ + "clipboard-win", + "image", + "log", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation 0.3.2", + "parking_lot", + "percent-encoding", + "windows-sys 0.61.2", + "x11rb", +] [[package]] -name = "bumpalo" -version = "3.20.4" +name = "arrayref" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87a0cf66fd1eb2fb7b822cb78370d82303750809bc6ba855f3f58e517d3238db" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" [[package]] -name = "bytes" -version = "1.12.1" +name = "arrayvec" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" +checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56" [[package]] -name = "cassowary" -version = "0.3.0" +name = "as-raw-xcb-connection" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" +checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b" [[package]] -name = "castaway" -version = "0.2.4" +name = "ash" +version = "0.38.0+1.3.281" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dec551ab6e7578819132c713a93c022a05d60159dc86e7a7050223577484c55a" +checksum = "0bb44936d800fea8f016d7f2311c6a4f97aebd5dc86f09906139ec848cf3a46f" dependencies = [ - "rustversion", + "libloading", ] [[package]] -name = "cc" -version = "1.11.2" +name = "async-broadcast" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ef9e3e8154a45c7a95cff4c1299702106ad94062d7bb85fdc5d3a5afd91d45" +checksum = "435a87a52755b8f27fcf321ac4f04b2802e337c8c4872923137471ec39c37532" dependencies = [ - "find-msvc-tools", - "jobserver", - "libc", - "shlex 2.0.1", + "event-listener", + "event-listener-strategy", + "futures-core", + "pin-project-lite", ] [[package]] -name = "cesu8" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" - -[[package]] -name = "cexpr" -version = "0.6.0" +name = "async-channel" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +checksum = "924ed96dd52d1b75e9c1a3e6275715fd320f5f9439fb5a4a11fa51f4221158d2" dependencies = [ - "nom", + "concurrent-queue", + "event-listener-strategy", + "futures-core", + "pin-project-lite", ] [[package]] -name = "cfg-if" -version = "1.0.5" +name = "async-executor" +version = "1.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" +checksum = "f426a31126c735126297bc5ea7a521263c9faff4f63ca415267ee625651c4f37" +dependencies = [ + "async-task", + "concurrent-queue", + "fastrand", + "futures-lite", + "pin-project-lite", + "slab", +] [[package]] -name = "clang-sys" -version = "1.9.1" +name = "async-io" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "157a8ba7b480713b56f4c09fd13fc3e0a22a5dfab8097ba61cbc5feef950788a" +checksum = "456b8a8feb6f42d237746d4b3e9a178494627745c3c56c6ea55d92ba50d026fc" dependencies = [ - "glob", - "libc", - "libloading", + "autocfg", + "cfg-if", + "concurrent-queue", + "futures-io", + "futures-lite", + "parking", + "polling", + "rustix 1.1.6", + "slab", + "windows-sys 0.61.2", ] [[package]] -name = "combine" -version = "4.6.9" +name = "async-lock" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4356eba6976435498d05a311ee9fc486da3bc81c200d3f0d7dd9703b41913f92" +checksum = "0876700b0d007ad25d5508865a4259c3af9af6d296bf663a0d586d0bc3369f6f" dependencies = [ - "bytes", - "memchr", + "event-listener", + "event-listener-strategy", + "pin-project-lite", ] [[package]] -name = "compact_str" -version = "0.8.2" +name = "async-process" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fd622ebbb56a5b2ccb651b32b911cdeb2a9b4b11776b2473bf26a26a286244e" +checksum = "fc50921ec0055cdd8a16de48773bfeec5c972598674347252c0399676be7da75" dependencies = [ - "castaway", + "async-channel", + "async-io", + "async-lock", + "async-signal", + "async-task", + "blocking", "cfg-if", - "itoa", - "rustversion", - "ryu", - "static_assertions", + "event-listener", + "futures-lite", + "rustix 1.1.6", ] [[package]] -name = "core-foundation-sys" -version = "0.8.7" +name = "async-recursion" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" +checksum = "4f8abc12baad266b1c8cec146854c195b5864b4221d4b2ca7296a7ae82d9e451" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] [[package]] -name = "coreaudio-rs" -version = "0.11.3" +name = "async-signal" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "321077172d79c662f64f5071a03120748d5bb652f5231570141be24cfcd2bace" +checksum = "52b5aaafa020cf5053a01f2a60e8ff5dccf550f0f77ec54a4e47285ac2bab485" dependencies = [ - "bitflags 1.3.2", - "core-foundation-sys", - "coreaudio-sys", + "async-io", + "async-lock", + "atomic-waker", + "cfg-if", + "futures-core", + "futures-io", + "rustix 1.1.6", + "signal-hook-registry", + "slab", + "windows-sys 0.61.2", ] [[package]] -name = "coreaudio-sys" -version = "0.2.18" +name = "async-task" +version = "4.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9b4739a805a62757a83e5654fa3faabec0442666b263bb2287d5a8185bfd953" -dependencies = [ - "bindgen", -] +checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" [[package]] -name = "cpal" -version = "0.15.3" +name = "async-trait" +version = "0.1.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "873dab07c8f743075e57f524c583985fbaf745602acbe916a01539364369a779" +checksum = "82f6aeea286b8eb4dd3431a1be1b59d290ace00f5bfd8e2a159bc2a05e2c1667" dependencies = [ - "alsa", - "core-foundation-sys", - "coreaudio-rs", - "dasp_sample", - "jni", - "js-sys", - "libc", - "mach2", - "ndk", - "ndk-context", - "oboe", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "windows", + "proc-macro2", + "quote", + "syn 3.0.10", ] [[package]] -name = "crossterm" -version = "0.28.1" +name = "atomic-waker" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6" -dependencies = [ - "bitflags 2.13.2", - "crossterm_winapi", - "mio", - "parking_lot", - "rustix", - "signal-hook", - "signal-hook-mio", - "winapi", -] +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] -name = "crossterm_winapi" -version = "0.9.1" +name = "atspi" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" +checksum = "c83247582e7508838caf5f316c00791eee0e15c0bf743e6880585b867e16815c" dependencies = [ - "winapi", + "atspi-common", + "atspi-connection", + "atspi-proxies", ] [[package]] -name = "darling" -version = "0.24.1" +name = "atspi-common" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed17f5901b6630b993ca003def43f2f8ef4014fc13b047b57aad617ff32bc2ec" +checksum = "33dfc05e7cdf90988a197803bf24f5788f94f7c94a69efa95683e8ffe76cfdfb" dependencies = [ - "darling_core", - "darling_macro", + "enumflags2", + "serde", + "static_assertions", + "zbus", + "zbus-lockstep", + "zbus-lockstep-macros", + "zbus_names", + "zvariant", ] [[package]] -name = "darling_core" -version = "0.24.1" +name = "atspi-connection" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6837e2cf7485aaae18f86181d2f0e9a7ed297a025e220aeabf63fdebd3a2ddff" +checksum = "4193d51303d8332304056ae0004714256b46b6635a5c556109b319c0d3784938" dependencies = [ - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn 3.0.10", + "atspi-common", + "atspi-proxies", + "futures-lite", + "zbus", ] [[package]] -name = "darling_macro" -version = "0.24.1" +name = "atspi-proxies" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ac7135c3ef02b2f7833bbeb1be5ba7f966dcde8a87c6b87f65a778d71a02785" +checksum = "d2eebcb9e7e76f26d0bcfd6f0295e1cd1e6f33bedbc5698a971db8dc43d7751c" dependencies = [ - "darling_core", - "quote", - "syn 3.0.10", + "atspi-common", + "serde", + "zbus", ] [[package]] -name = "dasp_sample" -version = "0.11.0" +name = "autocfg" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" [[package]] -name = "either" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" - -[[package]] -name = "equivalent" -version = "1.0.3" +name = "bindgen" +version = "0.72.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" +checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895" +dependencies = [ + "bitflags 2.13.2", + "cexpr", + "clang-sys", + "itertools", + "proc-macro2", + "quote", + "regex", + "rustc-hash 2.1.3", + "shlex 1.3.0", + "syn 2.0.119", +] [[package]] -name = "errno" -version = "0.3.15" +name = "bit-set" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e35d6e78f4cebb90e51d543db8fe41528851d6deeef6ef21ebd4bfdc1e784776" +checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3" dependencies = [ - "libc", - "windows-sys 0.61.2", + "bit-vec", ] [[package]] -name = "find-msvc-tools" -version = "0.1.15" +name = "bit-vec" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48" +checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" [[package]] -name = "foldhash" -version = "0.1.5" +name = "bitflags" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] -name = "futures-core" -version = "0.3.34" +name = "bitflags" +version = "2.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" [[package]] -name = "futures-task" -version = "0.3.34" +name = "block" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" +checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" [[package]] -name = "futures-util" -version = "0.3.34" +name = "block2" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f" dependencies = [ - "futures-core", - "futures-task", - "pin-project-lite", - "slab", + "objc2 0.5.3", ] [[package]] -name = "getrandom" -version = "0.4.3" +name = "blocking" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +checksum = "a70e4329df6cb94385eed412ec92375c3cdd8a6e502493d1229b6414e4036dfa" dependencies = [ - "cfg-if", - "libc", - "r-efi", + "async-channel", + "async-task", + "futures-io", + "futures-lite", + "piper", ] [[package]] -name = "glob" -version = "0.3.4" +name = "bumpalo" +version = "3.20.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b" +checksum = "87a0cf66fd1eb2fb7b822cb78370d82303750809bc6ba855f3f58e517d3238db" [[package]] -name = "hashbrown" -version = "0.15.5" +name = "bytemuck" +version = "1.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +checksum = "95832e849adfb21180ccb6826a99da14e5d266ae5c2e668e1602cf234f153797" dependencies = [ - "allocator-api2", - "equivalent", - "foldhash", + "bytemuck_derive", ] [[package]] -name = "hashbrown" -version = "0.17.1" +name = "bytemuck_derive" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" +checksum = "6a1f896587b6f2c069c73d2f0913e2d590c3990285cd2f0b6aa02b786b4c679c" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] [[package]] -name = "heck" -version = "0.5.0" +name = "byteorder-lite" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" [[package]] -name = "ident_case" -version = "1.0.1" +name = "bytes" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" +checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" [[package]] -name = "indexmap" -version = "2.14.2" +name = "calloop" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +checksum = "b99da2f8558ca23c71f4fd15dc57c906239752dd27ff3c00a1d56b685b7cbfec" dependencies = [ - "equivalent", - "hashbrown 0.17.1", + "bitflags 2.13.2", + "log", + "polling", + "rustix 0.38.44", + "slab", + "thiserror 1.0.69", ] [[package]] -name = "indoc" -version = "2.0.8" +name = "calloop" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a37b2691796cffeb8a8cd305ac66e65841559f147f4e63231d0eafa4db5384d1" +checksum = "43b32313e937c8721c9d17ee9bf60699a6402b4b7c2cb6ac1bee0ffcaa4b4e5e" dependencies = [ - "rustversion", + "bitflags 2.13.2", + "polling", + "rustix 1.1.6", + "tracing", ] [[package]] -name = "instability" -version = "0.3.14" +name = "calloop-wayland-source" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c3b5acc1e2fd9375041a388da33d1eb8aed5f7a8c0dd3543e3ea2805adfbe20" +checksum = "95a66a987056935f7efce4ab5668920b5d0dac4a7c99991a67395f13702ddd20" dependencies = [ - "darling", - "indoc", - "proc-macro2", - "quote", - "syn 3.0.10", + "calloop 0.13.0", + "rustix 0.38.44", + "wayland-backend", + "wayland-client", ] [[package]] -name = "itertools" -version = "0.13.0" +name = "calloop-wayland-source" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +checksum = "138efcf0940a02ebf0cc8d1eff41a1682a46b431630f4c52450d6265876021fa" dependencies = [ - "either", + "calloop 0.14.5", + "rustix 1.1.6", + "wayland-backend", + "wayland-client", ] [[package]] -name = "itoa" -version = "1.0.19" +name = "cassowary" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" +checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" [[package]] -name = "jni" -version = "0.21.1" +name = "castaway" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" +checksum = "dec551ab6e7578819132c713a93c022a05d60159dc86e7a7050223577484c55a" dependencies = [ - "cesu8", - "cfg-if", - "combine", - "jni-sys 0.3.1", - "log", - "thiserror", - "walkdir", - "windows-sys 0.45.0", + "rustversion", ] [[package]] -name = "jni-sys" -version = "0.3.1" +name = "cc" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41a652e1f9b6e0275df1f15b32661cf0d4b78d4d87ddec5e0c3c20f097433258" +checksum = "33ef9e3e8154a45c7a95cff4c1299702106ad94062d7bb85fdc5d3a5afd91d45" dependencies = [ - "jni-sys 0.4.1", + "find-msvc-tools", + "jobserver", + "libc", + "shlex 2.0.1", ] [[package]] -name = "jni-sys" -version = "0.4.1" +name = "cesu8" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6377a88cb3910bee9b0fa88d4f42e1d2da8e79915598f65fb0c7ee14c878af2" -dependencies = [ - "jni-sys-macros", -] +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" [[package]] -name = "jni-sys-macros" -version = "0.4.1" +name = "cexpr" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" dependencies = [ - "quote", - "syn 2.0.119", + "nom", ] [[package]] -name = "jobserver" -version = "0.1.35" +name = "cfg-if" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "cfg_aliases" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" + +[[package]] +name = "cgl" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ced0551234e87afee12411d535648dd89d2e7f34c78b753395567aff3d447ff" dependencies = [ - "getrandom", "libc", ] [[package]] -name = "js-sys" -version = "0.3.107" +name = "clang-sys" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dc09d2154098bbf4ef54eab6b117a3c24cbbffe94046b16ee6d6d4510584d3a" +checksum = "157a8ba7b480713b56f4c09fd13fc3e0a22a5dfab8097ba61cbc5feef950788a" dependencies = [ - "cfg-if", - "futures-util", - "wasm-bindgen", + "glob", + "libc", + "libloading", ] [[package]] -name = "libc" -version = "0.2.191" +name = "clipboard-win" +version = "5.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" +checksum = "052af7878466feccda12ba7a6a67d019d712f296809559b47c12c8cc196d3a9a" +dependencies = [ + "error-code", +] [[package]] -name = "libloading" -version = "0.8.9" +name = "codespan-reporting" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55" +checksum = "fe6d2e5af09e8c8ad56c969f2157a3d4238cebc7c55f0a517728c38f7b200f81" dependencies = [ - "cfg-if", - "windows-link", + "serde", + "termcolor", + "unicode-width 0.2.0", ] [[package]] -name = "linux-raw-sys" -version = "0.4.15" +name = "combine" +version = "4.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" +checksum = "4356eba6976435498d05a311ee9fc486da3bc81c200d3f0d7dd9703b41913f92" +dependencies = [ + "bytes", + "memchr", +] [[package]] -name = "lock_api" -version = "0.4.14" +name = "compact_str" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +checksum = "7fd622ebbb56a5b2ccb651b32b911cdeb2a9b4b11776b2473bf26a26a286244e" dependencies = [ - "scopeguard", + "castaway", + "cfg-if", + "itoa", + "rustversion", + "ryu", + "static_assertions", ] [[package]] -name = "log" -version = "0.4.35" +name = "concurrent-queue" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", +] [[package]] -name = "lru" -version = "0.12.5" +name = "core-foundation" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" dependencies = [ - "hashbrown 0.15.5", + "core-foundation-sys", + "libc", ] [[package]] -name = "mach2" -version = "0.4.3" +name = "core-foundation" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d640282b302c0bb0a2a8e0233ead9035e3bed871f0b7e81fe4a1ec829765db44" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" dependencies = [ + "core-foundation-sys", "libc", ] [[package]] -name = "memchr" -version = "2.8.3" +name = "core-foundation-sys" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] -name = "minimal-lexical" -version = "0.2.1" +name = "core-graphics" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" +checksum = "c07782be35f9e1140080c6b96f0d44b739e2278479f64e02fdab4e32dfd8b081" +dependencies = [ + "bitflags 1.3.2", + "core-foundation 0.9.4", + "core-graphics-types 0.1.3", + "foreign-types", + "libc", +] [[package]] -name = "mio" -version = "1.2.5" +name = "core-graphics-types" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20521a903f02b0a573cd6840e9d0a5a0cc043d361fe924092cd70f8556cc9c4a" +checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf" dependencies = [ + "bitflags 1.3.2", + "core-foundation 0.9.4", "libc", - "log", - "wasi", - "windows-sys 0.61.2", ] [[package]] -name = "ndk" -version = "0.8.0" +name = "core-graphics-types" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2076a31b7010b17a38c01907c45b945e8f11495ee4dd588309718901b1f7a5b7" +checksum = "3d44a101f213f6c4cdc1853d4b78aef6db6bdfa3468798cc1d9912f4735013eb" dependencies = [ "bitflags 2.13.2", - "jni-sys 0.3.1", - "log", - "ndk-sys", - "num_enum", - "thiserror", + "core-foundation 0.10.1", + "libc", ] [[package]] -name = "ndk-context" -version = "0.1.1" +name = "coreaudio-rs" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" +checksum = "321077172d79c662f64f5071a03120748d5bb652f5231570141be24cfcd2bace" +dependencies = [ + "bitflags 1.3.2", + "core-foundation-sys", + "coreaudio-sys", +] [[package]] -name = "ndk-sys" -version = "0.5.0+25.2.9519653" +name = "coreaudio-sys" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c196769dd60fd4f363e11d948139556a344e79d451aeb2fa2fd040738ef7691" +checksum = "b9b4739a805a62757a83e5654fa3faabec0442666b263bb2287d5a8185bfd953" dependencies = [ - "jni-sys 0.3.1", + "bindgen", ] [[package]] -name = "nom" -version = "7.1.3" +name = "cpal" +version = "0.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +checksum = "873dab07c8f743075e57f524c583985fbaf745602acbe916a01539364369a779" dependencies = [ - "memchr", - "minimal-lexical", + "alsa", + "core-foundation-sys", + "coreaudio-rs", + "dasp_sample", + "jni 0.21.1", + "js-sys", + "libc", + "mach2", + "ndk 0.8.0", + "ndk-context", + "oboe", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "windows 0.54.0", ] [[package]] -name = "num-complex" -version = "0.4.6" +name = "crc32fast" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" +checksum = "2b929dd2a135771f40afabd1073f85eed59c800b7c61901e5c254270497dad64" dependencies = [ - "num-traits", + "cfg-if", ] [[package]] -name = "num-derive" -version = "0.4.2" +name = "crossbeam-utils" +version = "0.8.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] +checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6" [[package]] -name = "num-integer" -version = "0.1.47" +name = "crossterm" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b" +checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6" dependencies = [ - "num-traits", + "bitflags 2.13.2", + "crossterm_winapi", + "mio", + "parking_lot", + "rustix 0.38.44", + "signal-hook", + "signal-hook-mio", + "winapi", ] [[package]] -name = "num-traits" -version = "0.2.19" +name = "crossterm_winapi" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" dependencies = [ - "autocfg", + "winapi", ] [[package]] -name = "num_enum" -version = "0.7.6" +name = "crunchy" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d0bca838442ec211fa11de3a8b0e0e8f3a4522575b5c4c06ed722e005036f26" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" + +[[package]] +name = "cursor-icon" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27ae1dd37df86211c42e150270f82743308803d90a6f6e6651cd730d5e1732f" + +[[package]] +name = "darling" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed17f5901b6630b993ca003def43f2f8ef4014fc13b047b57aad617ff32bc2ec" dependencies = [ - "num_enum_derive", - "rustversion", + "darling_core", + "darling_macro", ] [[package]] -name = "num_enum_derive" -version = "0.7.6" +name = "darling_core" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "680998035259dcfcafe653688bf2aa6d3e2dc05e98be6ab46afb089dc84f1df8" +checksum = "6837e2cf7485aaae18f86181d2f0e9a7ed297a025e220aeabf63fdebd3a2ddff" dependencies = [ - "proc-macro-crate", + "ident_case", "proc-macro2", "quote", - "syn 2.0.119", + "strsim", + "syn 3.0.10", ] [[package]] -name = "oboe" -version = "0.6.1" +name = "darling_macro" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8b61bebd49e5d43f5f8cc7ee2891c16e0f41ec7954d36bcb6c14c5e0de867fb" +checksum = "2ac7135c3ef02b2f7833bbeb1be5ba7f966dcde8a87c6b87f65a778d71a02785" dependencies = [ - "jni", - "ndk", - "ndk-context", - "num-derive", - "num-traits", - "oboe-sys", + "darling_core", + "quote", + "syn 3.0.10", ] [[package]] -name = "oboe-sys" -version = "0.6.1" +name = "dasp_sample" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8bb09a4a2b1d668170cfe0a7d5bc103f8999fb316c98099b6a9939c9f2e79d" +checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f" + +[[package]] +name = "dispatch" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" + +[[package]] +name = "dispatch2" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38" dependencies = [ - "cc", + "bitflags 2.13.2", + "objc2 0.6.5", ] [[package]] -name = "parking_lot" -version = "0.12.5" +name = "displaydoc" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" dependencies = [ - "lock_api", - "parking_lot_core", + "proc-macro2", + "quote", + "syn 3.0.10", ] [[package]] -name = "parking_lot_core" -version = "0.9.12" +name = "dlib" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +checksum = "ab8ecd87370524b461f8557c119c405552c396ed91fc0a8eec68679eab26f94a" dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-link", + "libloading", ] [[package]] -name = "paste" -version = "1.0.15" +name = "document-features" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" +checksum = "d4b8a88685455ed29a21542a33abd9cb6510b6b129abadabdcef0f4c55bc8f61" +dependencies = [ + "litrs", +] [[package]] -name = "pin-project-lite" -version = "0.2.17" +name = "downcast-rs" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" +checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" [[package]] -name = "pkg-config" -version = "0.3.34" +name = "dpi" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" +checksum = "d8b14ccef22fc6f5a8f4d7d768562a182c04ce9a3b3157b91390b52ddfdf1a76" [[package]] -name = "primal-check" -version = "0.3.4" +name = "ecolor" +version = "0.33.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc0d895b311e3af9902528fbb8f928688abbd95872819320517cc24ca6b2bd08" +checksum = "71ddb8ac7643d1dba1bb02110e804406dd459a838efcb14011ced10556711a8e" dependencies = [ - "num-integer", + "bytemuck", + "emath", ] [[package]] -name = "proc-macro-crate" -version = "3.5.0" +name = "eframe" +version = "0.33.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" +checksum = "457481173e6db5ca9fa2be93a58df8f4c7be639587aeb4853b526c6cf87db4e6" dependencies = [ - "toml_edit", + "ahash", + "bytemuck", + "document-features", + "egui", + "egui-wgpu", + "egui-winit", + "egui_glow", + "glow", + "glutin", + "glutin-winit", + "image", + "js-sys", + "log", + "objc2 0.5.3", + "objc2-app-kit 0.2.2", + "objc2-foundation 0.2.2", + "parking_lot", + "percent-encoding", + "profiling", + "raw-window-handle", + "static_assertions", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "web-time", + "windows-sys 0.61.2", + "winit", ] [[package]] -name = "proc-macro2" -version = "1.0.107" +name = "egui" +version = "0.33.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +checksum = "6a9b567d356674e9a5121ed3fedfb0a7c31e059fe71f6972b691bcd0bfc284e3" dependencies = [ - "unicode-ident", + "accesskit", + "ahash", + "bitflags 2.13.2", + "emath", + "epaint", + "log", + "nohash-hasher", + "profiling", + "smallvec", + "unicode-segmentation", ] [[package]] -name = "quote" -version = "1.0.47" +name = "egui-wgpu" +version = "0.33.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +checksum = "5e4d209971c84b2352a06174abdba701af1e552ce56b144d96f2bd50a3c91236" dependencies = [ - "proc-macro2", + "ahash", + "bytemuck", + "document-features", + "egui", + "epaint", + "log", + "profiling", + "thiserror 2.0.21", + "type-map", + "web-time", + "wgpu", + "winit", ] [[package]] -name = "r-efi" -version = "6.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" - -[[package]] -name = "ratatui" -version = "0.29.0" +name = "egui-winit" +version = "0.33.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eabd94c2f37801c20583fc49dd5cd6b0ba68c716787c2dd6ed18571e1e63117b" +checksum = "ec6687e5bb551702f4ad10ac428bab12acf9d53047ebb1082d4a0ed8c6251a29" dependencies = [ - "bitflags 2.13.2", - "cassowary", - "compact_str", - "crossterm", - "indoc", - "instability", - "itertools", - "lru", - "paste", - "strum", - "unicode-segmentation", - "unicode-truncate", - "unicode-width 0.2.0", + "accesskit_winit", + "arboard", + "bytemuck", + "egui", + "log", + "objc2 0.5.3", + "objc2-foundation 0.2.2", + "objc2-ui-kit", + "profiling", + "raw-window-handle", + "smithay-clipboard", + "web-time", + "webbrowser", + "winit", ] [[package]] -name = "redox_syscall" -version = "0.5.18" +name = "egui_glow" +version = "0.33.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +checksum = "6420863ea1d90e750f75075231a260030ad8a9f30a7cef82cdc966492dc4c4eb" dependencies = [ - "bitflags 2.13.2", + "bytemuck", + "egui", + "glow", + "log", + "memoffset", + "profiling", + "wasm-bindgen", + "web-sys", + "winit", ] [[package]] -name = "regex" -version = "1.13.1" +name = "either" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] +checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" [[package]] -name = "regex-automata" -version = "0.4.18" +name = "emath" +version = "0.33.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" +checksum = "491bdf728bf25ddd9ad60d4cf1c48588fa82c013a2440b91aa7fc43e34a07c32" dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", + "bytemuck", ] [[package]] -name = "regex-syntax" -version = "0.8.11" +name = "endi" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" +checksum = "66b7e2430c6dff6a955451e2cfc438f09cea1965a9d6f87f7e3b90decc014099" [[package]] -name = "regulator-core" -version = "0.1.0" +name = "enumflags2" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1027f7680c853e056ebcec683615fb6fbbc07dbaa13b4d5d9442b146ded4ecef" dependencies = [ - "rustfft", + "enumflags2_derive", + "serde", ] [[package]] -name = "regulator-tui" +name = "enumflags2_derive" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67c78a4d8fdf9953a5c9d458f9efe940fd97a0cab0941c075a813ac594733827" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "epaint" +version = "0.33.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "009d0dd3c2163823a0abdb899451ecbc78798dec545ee91b43aff1fa790bab62" +dependencies = [ + "ab_glyph", + "ahash", + "bytemuck", + "ecolor", + "emath", + "epaint_default_fonts", + "log", + "nohash-hasher", + "parking_lot", + "profiling", +] + +[[package]] +name = "epaint_default_fonts" +version = "0.33.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c4fbe202b6578d3d56428fa185cdf114a05e49da05f477b3c7f0fbb221f1862" + +[[package]] +name = "equivalent" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" + +[[package]] +name = "errno" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e35d6e78f4cebb90e51d543db8fe41528851d6deeef6ef21ebd4bfdc1e784776" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "error-code" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5343afd4a8365a643ac588dab4cf234a190c7f6c88c9f6dd6ffe00837661b7" + +[[package]] +name = "event-listener" +version = "5.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a23add41df1562121a9393cb065eab5146a1242410f23a644851e90cfd669d2" +dependencies = [ + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93" +dependencies = [ + "event-listener", + "pin-project-lite", +] + +[[package]] +name = "fastrand" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" + +[[package]] +name = "fax" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caf1079563223d5d59d83c85886a56e586cfd5c1a26292e971a0fa266531ac5a" + +[[package]] +name = "fdeflate" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c" +dependencies = [ + "simd-adler32", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48" + +[[package]] +name = "flate2" +version = "1.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "626d4928326b646e70f65ed36fc7cf9f206bdb68a0019ee7c6b4709da4e084c4" +dependencies = [ + "crc32fast", + "miniz_oxide 0.9.1", + "zlib-rs", +] + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "foreign-types" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" +dependencies = [ + "foreign-types-macros", + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-macros" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea5190182e6915eb873ddbc16e23b711b6eb1f9c00a0d0a3a91b5f6228475225" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "foreign-types-shared" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-io" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed" + +[[package]] +name = "futures-lite" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f78e10609fe0e0b3f4157ffab1876319b5b0db102a2c60dc4626306dc46b44ad" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "parking", + "pin-project-lite", +] + +[[package]] +name = "futures-macro" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-core", + "futures-macro", + "futures-task", + "pin-project-lite", + "slab", +] + +[[package]] +name = "gethostname" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8" +dependencies = [ + "rustix 1.1.6", + "windows-link 0.2.1", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi 5.3.0", + "wasip2", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "libc", + "r-efi 6.0.0", +] + +[[package]] +name = "gl_generator" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d" +dependencies = [ + "khronos_api", + "log", + "xml-rs", +] + +[[package]] +name = "glob" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b" + +[[package]] +name = "glow" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5e5ea60d70410161c8bf5da3fdfeaa1c72ed2c15f8bbb9d19fe3a4fad085f08" +dependencies = [ + "js-sys", + "slotmap", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "glutin" +version = "0.32.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12124de845cacfebedff80e877bb37b5b75c34c5a4c89e47e1cdd67fb6041325" +dependencies = [ + "bitflags 2.13.2", + "cfg_aliases", + "cgl", + "dispatch2", + "glutin_egl_sys", + "glutin_glx_sys", + "glutin_wgl_sys", + "libloading", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "once_cell", + "raw-window-handle", + "wayland-sys", + "windows-sys 0.52.0", + "x11-dl", +] + +[[package]] +name = "glutin-winit" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85edca7075f8fc728f28cb8fbb111a96c3b89e930574369e3e9c27eb75d3788f" +dependencies = [ + "cfg_aliases", + "glutin", + "raw-window-handle", + "winit", +] + +[[package]] +name = "glutin_egl_sys" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c4680ba6195f424febdc3ba46e7a42a0e58743f2edb115297b86d7f8ecc02d2" +dependencies = [ + "gl_generator", + "windows-sys 0.52.0", +] + +[[package]] +name = "glutin_glx_sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7bb2938045a88b612499fbcba375a77198e01306f52272e692f8c1f3751185" +dependencies = [ + "gl_generator", + "x11-dl", +] + +[[package]] +name = "glutin_wgl_sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c4ee00b289aba7a9e5306d57c2d05499b2e5dc427f84ac708bd2c090212cf3e" +dependencies = [ + "gl_generator", +] + +[[package]] +name = "gpu-alloc" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45cf04b2726f02df5508c6de726acdc90cdf97ac771a9a0ffd8ba10a6e696bf9" +dependencies = [ + "bitflags 2.13.2", + "gpu-alloc-types", +] + +[[package]] +name = "gpu-alloc-types" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2bbed164dd10ed526c2e4fe3e721ca4a71c61730e5aafac6844b417b3227058" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "gpu-allocator" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c151a2a5ef800297b4e79efa4f4bec035c5f51d5ae587287c9b952bdf734cacd" +dependencies = [ + "log", + "presser", + "thiserror 1.0.69", + "windows 0.54.0", +] + +[[package]] +name = "gpu-descriptor" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b89c83349105e3732062a895becfc71a8f921bb71ecbbdd8ff99263e3b53a0ca" +dependencies = [ + "bitflags 2.13.2", + "gpu-descriptor-types", + "hashbrown 0.15.5", +] + +[[package]] +name = "gpu-descriptor-types" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdf242682df893b86f33a73828fb09ca4b2d3bb6cc95249707fc684d27484b91" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "half" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" +dependencies = [ + "cfg-if", + "crunchy", + "num-traits", + "zerocopy", +] + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash 0.1.5", +] + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" +dependencies = [ + "foldhash 0.2.0", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17592d60ebacc7d5e169f4663c5f84f9161cc90328abcfe8456f41e4dfcb284" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hexf-parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df" + +[[package]] +name = "icu_collections" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe090a42a0d3140fed8c63263ed1fecc02422cb2f4bfe55cd8de2de1b8e105dd" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25d29b57c17c6528d0dc4c2141cfa2d08200465acb537a3909c8b9b8a4a984c0" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "404a3b8c486f205c87fe7f23ab6894d84a4ad76d6e4671ae1981ba7def87c599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20f0088bfb7441f7a37fa0c9e20cb1e9cba1cac6b9ce8cd2a6dc44294f8e8cbc" + +[[package]] +name = "icu_properties" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ea83d991c56158f7cf898bf86436c1dfe7c07ee82fe88951f2695c9f37a379f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98f29af82d02b163fe50161388350e743bb3107cc8e8c2f7314cb505faddfcf" + +[[package]] +name = "icu_provider" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413099315636c588ee8f011190b329b971a09a8fae9d157e01dcae8379468514" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "image" +version = "0.25.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85ab80394333c02fe689eaf900ab500fbd0c2213da414687ebf995a65d5a6104" +dependencies = [ + "bytemuck", + "byteorder-lite", + "moxcms", + "num-traits", + "png", + "tiff", +] + +[[package]] +name = "indexmap" +version = "2.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +dependencies = [ + "equivalent", + "hashbrown 0.17.1", +] + +[[package]] +name = "indoc" +version = "2.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a37b2691796cffeb8a8cd305ac66e65841559f147f4e63231d0eafa4db5384d1" +dependencies = [ + "rustversion", +] + +[[package]] +name = "instability" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c3b5acc1e2fd9375041a388da33d1eb8aed5f7a8c0dd3543e3ea2805adfbe20" +dependencies = [ + "darling", + "indoc", + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" + +[[package]] +name = "jni" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" +dependencies = [ + "cesu8", + "cfg-if", + "combine", + "jni-sys 0.3.1", + "log", + "thiserror 1.0.69", + "walkdir", + "windows-sys 0.45.0", +] + +[[package]] +name = "jni" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5efd9a482cf3a427f00d6b35f14332adc7902ce91efb778580e180ff90fa3498" +dependencies = [ + "cfg-if", + "combine", + "jni-macros", + "jni-sys 0.4.1", + "log", + "simd_cesu8", + "thiserror 2.0.21", + "walkdir", + "windows-link 0.2.1", +] + +[[package]] +name = "jni-macros" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00109accc170f0bdb141fed3e393c565b6f5e072365c3bd58f5b062591560a3" +dependencies = [ + "proc-macro2", + "quote", + "rustc_version", + "simd_cesu8", + "syn 2.0.119", +] + +[[package]] +name = "jni-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41a652e1f9b6e0275df1f15b32661cf0d4b78d4d87ddec5e0c3c20f097433258" +dependencies = [ + "jni-sys 0.4.1", +] + +[[package]] +name = "jni-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6377a88cb3910bee9b0fa88d4f42e1d2da8e79915598f65fb0c7ee14c878af2" +dependencies = [ + "jni-sys-macros", +] + +[[package]] +name = "jni-sys-macros" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264" +dependencies = [ + "quote", + "syn 2.0.119", +] + +[[package]] +name = "jobserver" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3" +dependencies = [ + "getrandom 0.4.3", + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dc09d2154098bbf4ef54eab6b117a3c24cbbffe94046b16ee6d6d4510584d3a" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "khronos-egl" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6aae1df220ece3c0ada96b8153459b67eebe9ae9212258bb0134ae60416fdf76" +dependencies = [ + "libc", + "libloading", + "pkg-config", +] + +[[package]] +name = "khronos_api" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" + +[[package]] +name = "libc" +version = "0.2.191" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" + +[[package]] +name = "libloading" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55" +dependencies = [ + "cfg-if", + "windows-link 0.2.1", +] + +[[package]] +name = "libm" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" + +[[package]] +name = "libredox" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61ff90caf6077a803a240f62fdbe88645a890bbca49ef8174c3cb0404362171d" +dependencies = [ + "bitflags 2.13.2", + "libc", + "plain", + "redox_syscall 0.9.5", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "litemap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" + +[[package]] +name = "litrs" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4744e383959f0db86ede514b809b1c53251889093803c05267acc7d4e7030d70" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c" + +[[package]] +name = "lru" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" +dependencies = [ + "hashbrown 0.15.5", +] + +[[package]] +name = "mach2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d640282b302c0bb0a2a8e0233ead9035e3bed871f0b7e81fe4a1ec829765db44" +dependencies = [ + "libc", +] + +[[package]] +name = "malloc_buf" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" +dependencies = [ + "libc", +] + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "memmap2" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b0ca1155a9ecc25aa12e8313a119f32edf0255fea2f44839c4ac0a12b2ac157" +dependencies = [ + "libc", +] + +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +dependencies = [ + "autocfg", +] + +[[package]] +name = "metal" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00c15a6f673ff72ddcc22394663290f870fb224c1bfce55734a75c414150e605" +dependencies = [ + "bitflags 2.13.2", + "block", + "core-graphics-types 0.2.0", + "foreign-types", + "log", + "objc", + "paste", +] + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "miniz_oxide" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "mio" +version = "1.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20521a903f02b0a573cd6840e9d0a5a0cc043d361fe924092cd70f8556cc9c4a" +dependencies = [ + "libc", + "log", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "moxcms" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb85c154ba489f01b25c0d36ae69a87e4a1c73a72631fc6c0eb6dde34a73e44b" +dependencies = [ + "num-traits", + "pxfm", +] + +[[package]] +name = "naga" +version = "27.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "066cf25f0e8b11ee0df221219010f213ad429855f57c494f995590c861a9a7d8" +dependencies = [ + "arrayvec", + "bit-set", + "bitflags 2.13.2", + "cfg-if", + "cfg_aliases", + "codespan-reporting", + "half", + "hashbrown 0.16.1", + "hexf-parse", + "indexmap", + "libm", + "log", + "num-traits", + "once_cell", + "rustc-hash 1.1.0", + "spirv", + "thiserror 2.0.21", + "unicode-ident", +] + +[[package]] +name = "ndk" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2076a31b7010b17a38c01907c45b945e8f11495ee4dd588309718901b1f7a5b7" +dependencies = [ + "bitflags 2.13.2", + "jni-sys 0.3.1", + "log", + "ndk-sys 0.5.0+25.2.9519653", + "num_enum", + "thiserror 1.0.69", +] + +[[package]] +name = "ndk" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" +dependencies = [ + "bitflags 2.13.2", + "jni-sys 0.3.1", + "log", + "ndk-sys 0.6.0+11769913", + "num_enum", + "raw-window-handle", + "thiserror 1.0.69", +] + +[[package]] +name = "ndk-context" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" + +[[package]] +name = "ndk-sys" +version = "0.5.0+25.2.9519653" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c196769dd60fd4f363e11d948139556a344e79d451aeb2fa2fd040738ef7691" +dependencies = [ + "jni-sys 0.3.1", +] + +[[package]] +name = "ndk-sys" +version = "0.6.0+11769913" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee6cda3051665f1fb8d9e08fc35c96d5a244fb1be711a03b71118828afc9a873" +dependencies = [ + "jni-sys 0.3.1", +] + +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num-complex" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "num-integer" +version = "0.1.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", + "libm", +] + +[[package]] +name = "num_enum" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0bca838442ec211fa11de3a8b0e0e8f3a4522575b5c4c06ed722e005036f26" +dependencies = [ + "num_enum_derive", + "rustversion", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "680998035259dcfcafe653688bf2aa6d3e2dc05e98be6ab46afb089dc84f1df8" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "objc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" +dependencies = [ + "malloc_buf", +] + +[[package]] +name = "objc-sys" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310" + +[[package]] +name = "objc2" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d5490aaf8f1d7cf7688dfa9b0ce07900e168852c45cd2c03f534dfd27cfd0b" +dependencies = [ + "objc-sys", + "objc2-encode", +] + +[[package]] +name = "objc2" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08849bbd4767dfae9457696856ae1c84fe4e0281bbe4a7abff2d0e06fb7981f8" +dependencies = [ + "objc2-encode", +] + +[[package]] +name = "objc2-app-kit" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4e89ad9e3d7d297152b17d39ed92cd50ca8063a89a9fa569046d41568891eff" +dependencies = [ + "bitflags 2.13.2", + "block2", + "libc", + "objc2 0.5.3", + "objc2-core-data", + "objc2-core-image", + "objc2-foundation 0.2.2", + "objc2-quartz-core", +] + +[[package]] +name = "objc2-app-kit" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c" +dependencies = [ + "bitflags 2.13.2", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation 0.3.2", +] + +[[package]] +name = "objc2-cloud-kit" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74dd3b56391c7a0596a295029734d3c1c5e7e510a4cb30245f8221ccea96b009" +dependencies = [ + "bitflags 2.13.2", + "block2", + "objc2 0.5.3", + "objc2-core-location", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-contacts" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5ff520e9c33812fd374d8deecef01d4a840e7b41862d849513de77e44aa4889" +dependencies = [ + "block2", + "objc2 0.5.3", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-core-data" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef" +dependencies = [ + "bitflags 2.13.2", + "block2", + "objc2 0.5.3", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-core-foundation" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" +dependencies = [ + "bitflags 2.13.2", + "dispatch2", + "objc2 0.6.5", +] + +[[package]] +name = "objc2-core-graphics" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807" +dependencies = [ + "bitflags 2.13.2", + "dispatch2", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-io-surface", +] + +[[package]] +name = "objc2-core-image" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55260963a527c99f1819c4f8e3b47fe04f9650694ef348ffd2227e8196d34c80" +dependencies = [ + "block2", + "objc2 0.5.3", + "objc2-foundation 0.2.2", + "objc2-metal", +] + +[[package]] +name = "objc2-core-location" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "000cfee34e683244f284252ee206a27953279d370e309649dc3ee317b37e5781" +dependencies = [ + "block2", + "objc2 0.5.3", + "objc2-contacts", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-encode" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33" + +[[package]] +name = "objc2-foundation" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" +dependencies = [ + "bitflags 2.13.2", + "block2", + "dispatch", + "libc", + "objc2 0.5.3", +] + +[[package]] +name = "objc2-foundation" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" +dependencies = [ + "bitflags 2.13.2", + "objc2 0.6.5", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-io-surface" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180788110936d59bab6bd83b6060ffdfffb3b922ba1396b312ae795e1de9d81d" +dependencies = [ + "bitflags 2.13.2", + "objc2 0.6.5", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-link-presentation" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1a1ae721c5e35be65f01a03b6d2ac13a54cb4fa70d8a5da293d7b0020261398" +dependencies = [ + "block2", + "objc2 0.5.3", + "objc2-app-kit 0.2.2", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-metal" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" +dependencies = [ + "bitflags 2.13.2", + "block2", + "objc2 0.5.3", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-quartz-core" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" +dependencies = [ + "bitflags 2.13.2", + "block2", + "objc2 0.5.3", + "objc2-foundation 0.2.2", + "objc2-metal", +] + +[[package]] +name = "objc2-symbols" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a684efe3dec1b305badae1a28f6555f6ddd3bb2c2267896782858d5a78404dc" +dependencies = [ + "objc2 0.5.3", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-ui-kit" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8bb46798b20cd6b91cbd113524c490f1686f4c4e8f49502431415f3512e2b6f" +dependencies = [ + "bitflags 2.13.2", + "block2", + "objc2 0.5.3", + "objc2-cloud-kit", + "objc2-core-data", + "objc2-core-image", + "objc2-core-location", + "objc2-foundation 0.2.2", + "objc2-link-presentation", + "objc2-quartz-core", + "objc2-symbols", + "objc2-uniform-type-identifiers", + "objc2-user-notifications", +] + +[[package]] +name = "objc2-uniform-type-identifiers" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44fa5f9748dbfe1ca6c0b79ad20725a11eca7c2218bceb4b005cb1be26273bfe" +dependencies = [ + "block2", + "objc2 0.5.3", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-user-notifications" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76cfcbf642358e8689af64cee815d139339f3ed8ad05103ed5eaf73db8d84cb3" +dependencies = [ + "bitflags 2.13.2", + "block2", + "objc2 0.5.3", + "objc2-core-location", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "oboe" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8b61bebd49e5d43f5f8cc7ee2891c16e0f41ec7954d36bcb6c14c5e0de867fb" +dependencies = [ + "jni 0.21.1", + "ndk 0.8.0", + "ndk-context", + "num-derive", + "num-traits", + "oboe-sys", +] + +[[package]] +name = "oboe-sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8bb09a4a2b1d668170cfe0a7d5bc103f8999fb316c98099b6a9939c9f2e79d" +dependencies = [ + "cc", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "orbclient" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5df339f526ea9a60e371768d50efc2f2508c7203290731565d1f7a6f71d21747" +dependencies = [ + "libc", + "libredox", +] + +[[package]] +name = "ordered-float" +version = "5.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f59006ce1e204c30956638535b74d317bca99477b9356dfaec54c37f6f600ab" +dependencies = [ + "num-traits", +] + +[[package]] +name = "ordered-stream" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50" +dependencies = [ + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "owned_ttf_parser" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36820e9051aca1014ddc75770aab4d68bc1e9e632f0f5627c4086bc216fb583b" +dependencies = [ + "ttf-parser", +] + +[[package]] +name = "parking" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.5.18", + "smallvec", + "windows-link 0.2.1", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project" +version = "1.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2466b2336ed02bcdca6b294417127b90ec92038d1d5c4fbeac971a922e0e0924" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c96395f0a926bc13b1c17622aaddda1ecb55d49c8f1bf9777e4d877800a43f8b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "piper" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c835479a4443ded371d6c535cbfd8d31ad92c5d23ae9770a61bc155e4992a3c1" +dependencies = [ + "atomic-waker", + "fastrand", + "futures-io", +] + +[[package]] +name = "pkg-config" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" + +[[package]] +name = "plain" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" + +[[package]] +name = "png" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61" +dependencies = [ + "bitflags 2.13.2", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide 0.8.9", +] + +[[package]] +name = "polling" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0e4f59085d47d8241c88ead0f274e8a0cb551f3625263c05eb8dd897c34218" +dependencies = [ + "cfg-if", + "concurrent-queue", + "hermit-abi", + "pin-project-lite", + "rustix 1.1.6", + "windows-sys 0.61.2", +] + +[[package]] +name = "portable-atomic" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85" + +[[package]] +name = "portable-atomic-util" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10ab3eb7f3becc3a1cbc4f2c6f20267996cfc1a6467a873763411b136a122715" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "potential_utf" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" +dependencies = [ + "zerovec", +] + +[[package]] +name = "presser" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa" + +[[package]] +name = "primal-check" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc0d895b311e3af9902528fbb8f928688abbd95872819320517cc24ca6b2bd08" +dependencies = [ + "num-integer", +] + +[[package]] +name = "proc-macro-crate" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" +dependencies = [ + "toml_edit", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "profiling" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d595e54a326bc53c1c197b32d295e14b169e3cfeaa8dc82b529f947fba6bcf5" + +[[package]] +name = "pxfm" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d55d956fa96f5ec02be2e13af0e20391a5aa83d6a074e3ad368959d0fab299ea" + +[[package]] +name = "quick-error" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" + +[[package]] +name = "quick-xml" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e660451e55124f798a69a5af3f49ccfbefbd41910eefd25caf2393e1f3473ec1" +dependencies = [ + "memchr", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "range-alloc" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca45419789ae5a7899559e9512e58ca889e41f04f1f2445e9f4b290ceccd1d08" + +[[package]] +name = "ratatui" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eabd94c2f37801c20583fc49dd5cd6b0ba68c716787c2dd6ed18571e1e63117b" +dependencies = [ + "bitflags 2.13.2", + "cassowary", + "compact_str", + "crossterm", + "indoc", + "instability", + "itertools", + "lru", + "paste", + "strum", + "unicode-segmentation", + "unicode-truncate", + "unicode-width 0.2.0", +] + +[[package]] +name = "raw-window-handle" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" + +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "redox_syscall" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "580c875845b41ecb1564ad1ae4703044cef774145e3d7a94dc2b3fa7c97868fd" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "regex" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" + +[[package]] +name = "regulator-core" +version = "0.1.0" +dependencies = [ + "rustfft", +] + +[[package]] +name = "regulator-gui" +version = "0.1.0" +dependencies = [ + "anyhow", + "cpal", + "eframe", + "regulator-core", +] + +[[package]] +name = "regulator-tui" version = "0.1.0" dependencies = [ - "anyhow", - "cpal", - "crossterm", - "ratatui", - "regulator-core", + "anyhow", + "cpal", + "crossterm", + "ratatui", + "regulator-core", +] + +[[package]] +name = "renderdoc-sys" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc-hash" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rustfft" +version = "6.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21db5f9893e91f41798c88680037dba611ca6674703c1a18601b01a72c8adb89" +dependencies = [ + "num-complex", + "num-integer", + "num-traits", + "primal-check", + "strength_reduce", + "transpose", +] + +[[package]] +name = "rustix" +version = "0.38.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +dependencies = [ + "bitflags 2.13.2", + "errno", + "libc", + "linux-raw-sys 0.4.15", + "windows-sys 0.59.0", +] + +[[package]] +name = "rustix" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa" +dependencies = [ + "bitflags 2.13.2", + "errno", + "libc", + "linux-raw-sys 0.12.1", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[package]] +name = "ryu" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "sctk-adwaita" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6277f0217056f77f1d8f49f2950ac6c278c0d607c45f5ee99328d792ede24ec" +dependencies = [ + "ab_glyph", + "log", + "memmap2", + "smithay-client-toolkit 0.19.2", + "tiny-skia", +] + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "serde_repr" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d3b1629de253c70a0508c3899572da79ca359fdab27c7920ff00406df418906" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "signal-hook" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d881a16cf4426aa584979d30bd82cb33429027e42122b169753d6ef1085ed6e2" +dependencies = [ + "libc", + "signal-hook-registry", +] + +[[package]] +name = "signal-hook-mio" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b75a19a7a740b25bc7944bdee6172368f988763b744e3d4dfe753f6b4ece40cc" +dependencies = [ + "libc", + "mio", + "signal-hook", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + +[[package]] +name = "simd-adler32" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" + +[[package]] +name = "simd_cesu8" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11031e251abf8611c80f460e19dbdeb54a66db918e49c65a7065b46ac7aec520" +dependencies = [ + "rustc_version", + "simdutf8", +] + +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "slotmap" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdd58c3c93c3d278ca835519292445cb4b0d4dc59ccfdf7ceadaab3f8aeb4038" +dependencies = [ + "version_check", +] + +[[package]] +name = "smallvec" +version = "1.16.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "149309498a5f7334b12ddae0cad8aba81ce785fe91755068867e017cf98fee46" + +[[package]] +name = "smithay-client-toolkit" +version = "0.19.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3457dea1f0eb631b4034d61d4d8c32074caa6cd1ab2d59f2327bd8461e2c0016" +dependencies = [ + "bitflags 2.13.2", + "calloop 0.13.0", + "calloop-wayland-source 0.3.0", + "cursor-icon", + "libc", + "log", + "memmap2", + "rustix 0.38.44", + "thiserror 1.0.69", + "wayland-backend", + "wayland-client", + "wayland-csd-frame", + "wayland-cursor", + "wayland-protocols", + "wayland-protocols-wlr", + "wayland-scanner", + "xkeysym", +] + +[[package]] +name = "smithay-client-toolkit" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0512da38f5e2b31201a93524adb8d3136276fa4fe4aafab4e1f727a82b534cc0" +dependencies = [ + "bitflags 2.13.2", + "calloop 0.14.5", + "calloop-wayland-source 0.4.1", + "cursor-icon", + "libc", + "log", + "memmap2", + "rustix 1.1.6", + "thiserror 2.0.21", + "wayland-backend", + "wayland-client", + "wayland-csd-frame", + "wayland-cursor", + "wayland-protocols", + "wayland-protocols-experimental", + "wayland-protocols-misc", + "wayland-protocols-wlr", + "wayland-scanner", + "xkeysym", +] + +[[package]] +name = "smithay-clipboard" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71704c03f739f7745053bde45fa203a46c58d25bc5c4efba1d9a60e9dba81226" +dependencies = [ + "libc", + "smithay-client-toolkit 0.20.0", + "wayland-backend", +] + +[[package]] +name = "smol_str" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd538fb6910ac1099850255cf94a94df6551fbdd602454387d0adb2d1ca6dead" +dependencies = [ + "serde", +] + +[[package]] +name = "spirv" +version = "0.3.0+sdk-1.3.268.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eda41003dc44290527a59b13432d4a0379379fa074b70174882adfbdfd917844" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strength_reduce" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe895eb47f22e2ddd4dabc02bce419d2e643c8e3b585c78158b349195bc24d82" + +[[package]] +name = "strict-num" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "strum" +version = "0.26.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.119", +] + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom 0.4.3", + "once_cell", + "rustix 1.1.6", + "windows-sys 0.61.2", +] + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" +dependencies = [ + "thiserror-impl 2.0.21", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "tiff" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63feaf3343d35b6ca4d50483f94843803b0f51634937cc2ec519fc32232bc52" +dependencies = [ + "fax", + "flate2", + "half", + "quick-error", + "weezl", + "zune-jpeg", +] + +[[package]] +name = "tiny-skia" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83d13394d44dae3207b52a326c0c85a8bf87f1541f23b0d143811088497b09ab" +dependencies = [ + "arrayref", + "arrayvec", + "bytemuck", + "cfg-if", + "log", + "tiny-skia-path", +] + +[[package]] +name = "tiny-skia-path" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c9e7fc0c2e86a30b117d0462aa261b72b7a99b7ebd7deb3a14ceda95c5bdc93" +dependencies = [ + "arrayref", + "bytemuck", + "strict-num", ] [[package]] -name = "rustc-hash" -version = "2.1.3" +name = "tinystr" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" +checksum = "abc840c238154d58f9e86b2792261edfde565a17696e1cda1a449de27979801a" +dependencies = [ + "displaydoc", + "zerovec", +] [[package]] -name = "rustfft" -version = "6.4.1" +name = "tokio" +version = "1.54.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21db5f9893e91f41798c88680037dba611ca6674703c1a18601b01a72c8adb89" +checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3" +dependencies = [ + "pin-project-lite", +] + +[[package]] +name = "toml_datetime" +version = "1.1.3+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "173f25c883cd2176a2d8212155638c0a60d484a9d84546d270866f40f56b6e49" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_edit" +version = "0.25.19+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd43688c4858d7264ae1cf9a9f874a67c3feb74a883b1cd7bebd6a4ea8307218" +dependencies = [ + "indexmap", + "toml_datetime", + "toml_parser", + "winnow", +] + +[[package]] +name = "toml_parser" +version = "1.1.5+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baa693a8032d7e1cada7d0041e96126df243179ff061456783ac7f12bda4744c" +dependencies = [ + "winnow", +] + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "transpose" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad61aed86bc3faea4300c7aee358b4c6d0c8d6ccc36524c96e4c92ccf26e77e" dependencies = [ - "num-complex", "num-integer", - "num-traits", - "primal-check", "strength_reduce", - "transpose", ] [[package]] -name = "rustix" -version = "0.38.44" +name = "ttf-parser" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +checksum = "d2df906b07856748fa3f6e0ad0cbaa047052d4a7dd609e231c4f72cee8c36f31" + +[[package]] +name = "type-map" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb30dbbd9036155e74adad6812e9898d03ec374946234fbcebd5dfc7b9187b90" dependencies = [ - "bitflags 2.13.2", - "errno", - "libc", - "linux-raw-sys", - "windows-sys 0.59.0", + "rustc-hash 2.1.3", ] [[package]] -name = "rustversion" -version = "1.0.23" +name = "uds_windows" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" +checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e" +dependencies = [ + "memoffset", + "tempfile", + "windows-sys 0.61.2", +] [[package]] -name = "ryu" -version = "1.0.23" +name = "unicode-ident" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" [[package]] -name = "same-file" -version = "1.0.6" +name = "unicode-segmentation" +version = "1.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" + +[[package]] +name = "unicode-truncate" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3644627a5af5fa321c95b9b235a72fd24cd29c648c2c379431e6628655627bf" +dependencies = [ + "itertools", + "unicode-segmentation", + "unicode-width 0.1.14", +] + +[[package]] +name = "unicode-width" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" + +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af3bd9d3e571c26fcce9d033b87ea5ab061b8d2ffe9b7a5675d810d68f03edf0" +dependencies = [ + "utf_types", +] + +[[package]] +name = "utf_types" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a3b425286980a367278453f3b6d28cdcb134b574e5a35824a6ff5eebad50bb6" + +[[package]] +name = "uuid" +version = "1.29.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c14b15dffa2f4bd712103e857140aa04a4f2ff6e955c77d7eb8e53ee02a3b64" +dependencies = [ + "js-sys", + "serde_core", + "wasm-bindgen", +] + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" dependencies = [ + "same-file", "winapi-util", ] [[package]] -name = "scopeguard" -version = "1.2.0" +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] -name = "serde_core" -version = "1.0.229" +name = "wasip2" +version = "1.0.4+wasi-0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" dependencies = [ - "serde_derive", + "wit-bindgen", ] [[package]] -name = "serde_derive" -version = "1.0.229" +name = "wasm-bindgen" +version = "0.2.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +checksum = "a0181c14ddd6c7b8b0b0132a5f1ea2f32be0d893cd3ea97b6e3b28886b8a3d1c" +dependencies = [ + "cfg-if", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e14e0327cb5368ad60ccb22d04a9827a693c95a926d8d125e9fa39e0baec501" +dependencies = [ + "js-sys", + "tokio", + "wasm-bindgen", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e931a02a39abdbf66966fc35902b5ed58344750a70885bed4ebb3d8eaf28ed9" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ca4b54280e455bd831e33a6b8e734baf432fe63fbc35c42ac14ce67a043a53a" dependencies = [ + "bumpalo", "proc-macro2", "quote", "syn 3.0.10", + "wasm-bindgen-shared", ] [[package]] -name = "shlex" -version = "1.3.0" +name = "wasm-bindgen-shared" +version = "0.2.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +checksum = "3b1f9c3798725016c6ee5f2f57869ec0831e8bbc0ab0310a86e787e97f41389e" +dependencies = [ + "unicode-ident", +] [[package]] -name = "shlex" -version = "2.0.1" +name = "wayland-backend" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" +checksum = "38a91b4eaddff87b1cd1074985e3713da4af2c49742d1b356b2c01670a67a078" +dependencies = [ + "cc", + "downcast-rs", + "rustix 1.1.6", + "scoped-tls", + "smallvec", + "wayland-sys", +] [[package]] -name = "signal-hook" -version = "0.3.18" +name = "wayland-client" +version = "0.31.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d881a16cf4426aa584979d30bd82cb33429027e42122b169753d6ef1085ed6e2" +checksum = "e3c36a0f861ad76d0901f2800b46321410d9f73f2ea88aac0650d86c32688073" dependencies = [ - "libc", - "signal-hook-registry", + "bitflags 2.13.2", + "rustix 1.1.6", + "wayland-backend", + "wayland-scanner", ] [[package]] -name = "signal-hook-mio" -version = "0.2.5" +name = "wayland-csd-frame" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b75a19a7a740b25bc7944bdee6172368f988763b744e3d4dfe753f6b4ece40cc" +checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e" dependencies = [ - "libc", - "mio", - "signal-hook", + "bitflags 2.13.2", + "cursor-icon", + "wayland-backend", +] + +[[package]] +name = "wayland-cursor" +version = "0.31.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a52d18780be9b1314328a3de5f930b73d2200112e3849ca6cb11822793fb34d" +dependencies = [ + "rustix 1.1.6", + "wayland-client", + "xcursor", +] + +[[package]] +name = "wayland-protocols" +version = "0.32.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d0c813de3daa2ed6520af85a3bd49b0e722a3078506899aa9686fea58dc4b6" +dependencies = [ + "bitflags 2.13.2", + "wayland-backend", + "wayland-client", + "wayland-scanner", ] [[package]] -name = "signal-hook-registry" -version = "1.4.8" +name = "wayland-protocols-experimental" +version = "20250721.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +checksum = "40a1f863128dcaaec790d7b4b396cc9b9a7a079e878e18c47e6c2d2c5a8dcbb1" dependencies = [ - "errno", - "libc", + "bitflags 2.13.2", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", ] [[package]] -name = "slab" -version = "0.4.12" +name = "wayland-protocols-misc" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" +checksum = "6e9567599ef23e09b8dad6e429e5738d4509dfc46b3b21f32841a304d16b29c8" +dependencies = [ + "bitflags 2.13.2", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", +] [[package]] -name = "smallvec" -version = "1.16.5" +name = "wayland-protocols-plasma" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "149309498a5f7334b12ddae0cad8aba81ce785fe91755068867e017cf98fee46" +checksum = "2b6d8cf1eb2c1c31ed1f5643c88a6e53538129d4af80030c8cabd1f9fa884d91" +dependencies = [ + "bitflags 2.13.2", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", +] [[package]] -name = "static_assertions" -version = "1.1.0" +name = "wayland-protocols-wlr" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +checksum = "eb04e52f7836d7c7976c78ca0250d61e33873c34156a2a1fc9474828ec268234" +dependencies = [ + "bitflags 2.13.2", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", +] [[package]] -name = "strength_reduce" -version = "0.2.4" +name = "wayland-scanner" +version = "0.31.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe895eb47f22e2ddd4dabc02bce419d2e643c8e3b585c78158b349195bc24d82" +checksum = "338e30461b3a2b67d70eb30a6d89f8e0c93a833e07d2ae89085cd070c4a00ac0" +dependencies = [ + "proc-macro2", + "quick-xml", + "quote", +] [[package]] -name = "strsim" -version = "0.11.1" +name = "wayland-sys" +version = "0.31.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +checksum = "d8eab23fefc9e41f8e841df4a9c707e8a8c4ed26e944ef69297184de2785e3be" +dependencies = [ + "dlib", + "log", + "once_cell", + "pkg-config", +] [[package]] -name = "strum" -version = "0.26.3" +name = "web-sys" +version = "0.3.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" +checksum = "d7d179596ff5ec0f6de4db64d54011bde6289cc49603d3a6e4ce3f329207ab88" dependencies = [ - "strum_macros", + "js-sys", + "wasm-bindgen", ] [[package]] -name = "strum_macros" -version = "0.26.4" +name = "web-time" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" dependencies = [ - "heck", - "proc-macro2", - "quote", - "rustversion", - "syn 2.0.119", + "js-sys", + "wasm-bindgen", ] [[package]] -name = "syn" -version = "2.0.119" +name = "webbrowser" +version = "1.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +checksum = "73e91ccd4698f2647d6137e8eb17a3f1dcfd63810be9029fb2398f507279b95b" dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "jni 0.22.4", + "log", + "ndk-context", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-foundation 0.3.2", + "url", + "web-sys", ] [[package]] -name = "syn" -version = "3.0.10" +name = "weezl" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79" +checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88" + +[[package]] +name = "wgpu" +version = "27.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfe68bac7cde125de7a731c3400723cadaaf1703795ad3f4805f187459cd7a77" dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "arrayvec", + "bitflags 2.13.2", + "cfg-if", + "cfg_aliases", + "document-features", + "hashbrown 0.16.1", + "js-sys", + "log", + "naga", + "parking_lot", + "portable-atomic", + "profiling", + "raw-window-handle", + "smallvec", + "static_assertions", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "wgpu-core", + "wgpu-hal", + "wgpu-types", ] [[package]] -name = "thiserror" -version = "1.0.69" +name = "wgpu-core" +version = "27.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +checksum = "27a75de515543b1897b26119f93731b385a19aea165a1ec5f0e3acecc229cae7" dependencies = [ - "thiserror-impl", + "arrayvec", + "bit-set", + "bit-vec", + "bitflags 2.13.2", + "bytemuck", + "cfg_aliases", + "document-features", + "hashbrown 0.16.1", + "indexmap", + "log", + "naga", + "once_cell", + "parking_lot", + "portable-atomic", + "profiling", + "raw-window-handle", + "rustc-hash 1.1.0", + "smallvec", + "thiserror 2.0.21", + "wgpu-core-deps-apple", + "wgpu-core-deps-emscripten", + "wgpu-core-deps-windows-linux-android", + "wgpu-hal", + "wgpu-types", ] [[package]] -name = "thiserror-impl" -version = "1.0.69" +name = "wgpu-core-deps-apple" +version = "27.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +checksum = "0772ae958e9be0c729561d5e3fd9a19679bcdfb945b8b1a1969d9bfe8056d233" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", + "wgpu-hal", ] [[package]] -name = "tokio" -version = "1.54.1" +name = "wgpu-core-deps-emscripten" +version = "27.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3" +checksum = "b06ac3444a95b0813ecfd81ddb2774b66220b264b3e2031152a4a29fda4da6b5" dependencies = [ - "pin-project-lite", + "wgpu-hal", ] [[package]] -name = "toml_datetime" -version = "1.1.3+spec-1.1.0" +name = "wgpu-core-deps-windows-linux-android" +version = "27.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "173f25c883cd2176a2d8212155638c0a60d484a9d84546d270866f40f56b6e49" +checksum = "71197027d61a71748e4120f05a9242b2ad142e3c01f8c1b47707945a879a03c3" dependencies = [ - "serde_core", + "wgpu-hal", ] [[package]] -name = "toml_edit" -version = "0.25.19+spec-1.1.0" +name = "wgpu-hal" +version = "27.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd43688c4858d7264ae1cf9a9f874a67c3feb74a883b1cd7bebd6a4ea8307218" +checksum = "5b21cb61c57ee198bc4aff71aeadff4cbb80b927beb912506af9c780d64313ce" dependencies = [ - "indexmap", - "toml_datetime", - "toml_parser", - "winnow", + "android_system_properties", + "arrayvec", + "ash", + "bit-set", + "bitflags 2.13.2", + "block", + "bytemuck", + "cfg-if", + "cfg_aliases", + "core-graphics-types 0.2.0", + "glow", + "glutin_wgl_sys", + "gpu-alloc", + "gpu-allocator", + "gpu-descriptor", + "hashbrown 0.16.1", + "js-sys", + "khronos-egl", + "libc", + "libloading", + "log", + "metal", + "naga", + "ndk-sys 0.6.0+11769913", + "objc", + "once_cell", + "ordered-float", + "parking_lot", + "portable-atomic", + "portable-atomic-util", + "profiling", + "range-alloc", + "raw-window-handle", + "renderdoc-sys", + "smallvec", + "thiserror 2.0.21", + "wasm-bindgen", + "web-sys", + "wgpu-types", + "windows 0.58.0", + "windows-core 0.58.0", ] [[package]] -name = "toml_parser" -version = "1.1.5+spec-1.1.0" +name = "wgpu-types" +version = "27.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baa693a8032d7e1cada7d0041e96126df243179ff061456783ac7f12bda4744c" +checksum = "afdcf84c395990db737f2dd91628706cb31e86d72e53482320d368e52b5da5eb" dependencies = [ - "winnow", + "bitflags 2.13.2", + "bytemuck", + "js-sys", + "log", + "thiserror 2.0.21", + "web-sys", ] [[package]] -name = "transpose" -version = "0.2.3" +name = "winapi" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad61aed86bc3faea4300c7aee358b4c6d0c8d6ccc36524c96e4c92ccf26e77e" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ - "num-integer", - "strength_reduce", + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", ] [[package]] -name = "unicode-ident" -version = "1.0.27" +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] -name = "unicode-segmentation" -version = "1.13.3" +name = "winapi-util" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys 0.61.2", +] [[package]] -name = "unicode-truncate" -version = "1.1.0" +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3644627a5af5fa321c95b9b235a72fd24cd29c648c2c379431e6628655627bf" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows" +version = "0.54.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49" dependencies = [ - "itertools", - "unicode-segmentation", - "unicode-width 0.1.14", + "windows-core 0.54.0", + "windows-targets 0.52.6", ] [[package]] -name = "unicode-width" -version = "0.1.14" +name = "windows" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" +checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6" +dependencies = [ + "windows-core 0.58.0", + "windows-targets 0.52.6", +] [[package]] -name = "unicode-width" -version = "0.2.0" +name = "windows" +version = "0.61.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" +checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893" +dependencies = [ + "windows-collections", + "windows-core 0.61.2", + "windows-future", + "windows-link 0.1.3", + "windows-numerics", +] [[package]] -name = "walkdir" -version = "2.5.0" +name = "windows-collections" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8" dependencies = [ - "same-file", - "winapi-util", + "windows-core 0.61.2", ] [[package]] -name = "wasi" -version = "0.11.1+wasi-snapshot-preview1" +name = "windows-core" +version = "0.54.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" +checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65" +dependencies = [ + "windows-result 0.1.2", + "windows-targets 0.52.6", +] [[package]] -name = "wasm-bindgen" -version = "0.2.130" +name = "windows-core" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0181c14ddd6c7b8b0b0132a5f1ea2f32be0d893cd3ea97b6e3b28886b8a3d1c" +checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99" dependencies = [ - "cfg-if", - "rustversion", - "wasm-bindgen-macro", - "wasm-bindgen-shared", + "windows-implement 0.58.0", + "windows-interface 0.58.0", + "windows-result 0.2.0", + "windows-strings 0.1.0", + "windows-targets 0.52.6", ] [[package]] -name = "wasm-bindgen-futures" -version = "0.4.80" +name = "windows-core" +version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e14e0327cb5368ad60ccb22d04a9827a693c95a926d8d125e9fa39e0baec501" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" dependencies = [ - "js-sys", - "tokio", - "wasm-bindgen", + "windows-implement 0.60.2", + "windows-interface 0.59.3", + "windows-link 0.1.3", + "windows-result 0.3.4", + "windows-strings 0.4.2", ] [[package]] -name = "wasm-bindgen-macro" -version = "0.2.130" +name = "windows-future" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e931a02a39abdbf66966fc35902b5ed58344750a70885bed4ebb3d8eaf28ed9" +checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e" dependencies = [ - "quote", - "wasm-bindgen-macro-support", + "windows-core 0.61.2", + "windows-link 0.1.3", + "windows-threading", ] [[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.130" +name = "windows-implement" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ca4b54280e455bd831e33a6b8e734baf432fe63fbc35c42ac14ce67a043a53a" +checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ - "bumpalo", "proc-macro2", "quote", - "syn 3.0.10", - "wasm-bindgen-shared", + "syn 2.0.119", ] [[package]] -name = "wasm-bindgen-shared" -version = "0.2.130" +name = "windows-implement" +version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b1f9c3798725016c6ee5f2f57869ec0831e8bbc0ab0310a86e787e97f41389e" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ - "unicode-ident", + "proc-macro2", + "quote", + "syn 2.0.119", ] [[package]] -name = "web-sys" -version = "0.3.107" +name = "windows-interface" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7d179596ff5ec0f6de4db64d54011bde6289cc49603d3a6e4ce3f329207ab88" +checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ - "js-sys", - "wasm-bindgen", + "proc-macro2", + "quote", + "syn 2.0.119", ] [[package]] -name = "winapi" -version = "0.3.9" +name = "windows-interface" +version = "0.59.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", + "proc-macro2", + "quote", + "syn 2.0.119", ] [[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" +name = "windows-link" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" [[package]] -name = "winapi-util" -version = "0.1.11" +name = "windows-link" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" -dependencies = [ - "windows-sys 0.61.2", -] +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" [[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" +name = "windows-numerics" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1" +dependencies = [ + "windows-core 0.61.2", + "windows-link 0.1.3", +] [[package]] -name = "windows" -version = "0.54.0" +name = "windows-result" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49" +checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" dependencies = [ - "windows-core", "windows-targets 0.52.6", ] [[package]] -name = "windows-core" -version = "0.54.0" +name = "windows-result" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" dependencies = [ - "windows-result", "windows-targets 0.52.6", ] [[package]] -name = "windows-link" -version = "0.2.1" +name = "windows-result" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" +checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +dependencies = [ + "windows-link 0.1.3", +] [[package]] -name = "windows-result" -version = "0.1.2" +name = "windows-strings" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" dependencies = [ + "windows-result 0.2.0", "windows-targets 0.52.6", ] +[[package]] +name = "windows-strings" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" +dependencies = [ + "windows-link 0.1.3", +] + [[package]] name = "windows-sys" version = "0.45.0" @@ -1324,6 +4267,15 @@ dependencies = [ "windows-targets 0.42.2", ] +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-sys" version = "0.59.0" @@ -1339,7 +4291,7 @@ version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" dependencies = [ - "windows-link", + "windows-link 0.2.1", ] [[package]] @@ -1373,6 +4325,15 @@ dependencies = [ "windows_x86_64_msvc 0.52.6", ] +[[package]] +name = "windows-threading" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b66463ad2e0ea3bbf808b7f1d371311c80e115c0b71d60efc142cafbcfb057a6" +dependencies = [ + "windows-link 0.1.3", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.42.2" @@ -1463,6 +4424,58 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "winit" +version = "0.30.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6755fa58a9f8350bd1e472d4c3fcc25f824ec358933bba33306d0b63df5978d" +dependencies = [ + "ahash", + "android-activity", + "atomic-waker", + "bitflags 2.13.2", + "block2", + "bytemuck", + "calloop 0.13.0", + "cfg_aliases", + "concurrent-queue", + "core-foundation 0.9.4", + "core-graphics", + "cursor-icon", + "dpi", + "js-sys", + "libc", + "memmap2", + "ndk 0.9.0", + "objc2 0.5.3", + "objc2-app-kit 0.2.2", + "objc2-foundation 0.2.2", + "objc2-ui-kit", + "orbclient", + "percent-encoding", + "pin-project", + "raw-window-handle", + "redox_syscall 0.4.1", + "rustix 0.38.44", + "sctk-adwaita", + "smithay-client-toolkit 0.19.2", + "smol_str", + "tracing", + "unicode-segmentation", + "wasm-bindgen", + "wasm-bindgen-futures", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-protocols-plasma", + "web-sys", + "web-time", + "windows-sys 0.52.0", + "x11-dl", + "x11rb", + "xkbcommon-dl", +] + [[package]] name = "winnow" version = "1.0.5" @@ -1471,3 +4484,343 @@ checksum = "8c3b93199df0ab874cdf0c6a94f0a0dc3423fe41f1cafb62b8bd7b1deb277aef" dependencies = [ "memchr", ] + +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" + +[[package]] +name = "writeable" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" + +[[package]] +name = "x11-dl" +version = "2.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38735924fedd5314a6e548792904ed8c6de6636285cb9fec04d5b1db85c1516f" +dependencies = [ + "libc", + "once_cell", + "pkg-config", +] + +[[package]] +name = "x11rb" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9993aa5be5a26815fe2c3eacfc1fde061fc1a1f094bf1ad2a18bf9c495dd7414" +dependencies = [ + "as-raw-xcb-connection", + "gethostname", + "libc", + "libloading", + "once_cell", + "rustix 1.1.6", + "x11rb-protocol", +] + +[[package]] +name = "x11rb-protocol" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6fc2961e4ef194dcbfe56bb845534d0dc8098940c7e5c012a258bfec6701bd" + +[[package]] +name = "xcursor" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "163b33ed8786455e2fa5d72f554057ce3f3182425434f756cd39c99839d88e23" + +[[package]] +name = "xkbcommon-dl" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039de8032a9a8856a6be89cea3e5d12fdd82306ab7c94d74e6deab2460651c5" +dependencies = [ + "bitflags 2.13.2", + "dlib", + "log", + "once_cell", + "xkeysym", +] + +[[package]] +name = "xkeysym" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9cc00251562a284751c9973bace760d86c0276c471b4be569fe6b068ee97a56" + +[[package]] +name = "xml-rs" +version = "0.8.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e450f9b2ed1dff33c94c12589a87338689467b9c4f5d8a5710bd09a847d2c8a7" + +[[package]] +name = "yoke" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "417ef3fcf6c300b7dbd25c85531a746931c02ad536f3cf4786ed1e88223340b3" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", + "synstructure", +] + +[[package]] +name = "zbus" +version = "5.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5db4be7c075cb421e4b7ee645541604239bd243ba7c357511f4ff3a74b555907" +dependencies = [ + "async-broadcast", + "async-executor", + "async-io", + "async-lock", + "async-process", + "async-recursion", + "async-task", + "async-trait", + "blocking", + "enumflags2", + "event-listener", + "futures-core", + "futures-lite", + "hex", + "libc", + "ordered-stream", + "rustix 1.1.6", + "serde", + "serde_repr", + "tracing", + "uds_windows", + "uuid", + "windows-sys 0.61.2", + "winnow", + "zbus_macros", + "zbus_names", + "zvariant", +] + +[[package]] +name = "zbus-lockstep" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6998de05217a084b7578728a9443d04ea4cd80f2a0839b8d78770b76ccd45863" +dependencies = [ + "zbus_xml", + "zvariant", +] + +[[package]] +name = "zbus-lockstep-macros" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10da05367f3a7b7553c8cdf8fa91aee6b64afebe32b51c95177957efc47ca3a0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", + "zbus-lockstep", + "zbus_xml", + "zvariant", +] + +[[package]] +name = "zbus_macros" +version = "5.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2990635d09ade6df1868f72f8cac69a876a90981e8bd3c40b1be413f8dc88f40" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 3.0.10", + "zbus_names", + "zvariant", + "zvariant_utils", +] + +[[package]] +name = "zbus_names" +version = "4.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "812a12be4ead7a59e18ea8f047d08add0066b73bc62fc1467066a2472ae088dd" +dependencies = [ + "serde", + "winnow", + "zvariant", +] + +[[package]] +name = "zbus_xml" +version = "5.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1586c021a01ca0a9216dcd874e546382e156a5cbab5fab6cb5f10087e22682a" +dependencies = [ + "serde", + "winnow", + "zbus_names", + "zvariant", +] + +[[package]] +name = "zcheapstr" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "939f186d9ecebe044315a5cb6d6f78568bbc21152adc954d5a0c2f58bdbc9920" +dependencies = [ + "serde", +] + +[[package]] +name = "zerocopy" +version = "0.8.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5fe1f8f1b06191a00962174c61aa5005e0bb391a6d80d07e24d115c01a92ed8" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "863ad3ac83293fb4d740aedbfdc9240dd8d1a50c1099acd76ce80ce7c7230c7f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "zerofrom" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", + "synstructure", +] + +[[package]] +name = "zerotrie" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58a2799cfe9a1670c7ea8edbd52ef8edb93cb37a7f83bf31ba9e35d9dae6a40" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3743ddbf47738d929cd1ae2e199d40d0162979dfe31aef8ae646d2bf00bf97a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + +[[package]] +name = "zlib-rs" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112" + +[[package]] +name = "zune-core" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d56377fd46368984a170bc5aac5567e52ca5da874caa60bea39fcbca78fb658b" + +[[package]] +name = "zune-jpeg" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27bc9d5b815bc103f142aa054f561d9187d191692ec7c2d1e2b4737f8dbd7296" +dependencies = [ + "zune-core", +] + +[[package]] +name = "zvariant" +version = "5.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80bf6d6cd6a4b601acb64cfb8284cdc643fcfa75ef26ae3c46ec8aa4e8a1fbb7" +dependencies = [ + "endi", + "enumflags2", + "serde", + "winnow", + "zcheapstr", + "zvariant_derive", + "zvariant_utils", +] + +[[package]] +name = "zvariant_derive" +version = "5.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef2672456ba1cb54b5eaec136e63135b3c7495fb938e53b28a62e633496d486d" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 3.0.10", + "zvariant_utils", +] + +[[package]] +name = "zvariant_utils" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bad0294361a320b694a328460dc73add56c306150f5cb6bfafc44446120008a3" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "syn 3.0.10", + "winnow", +] diff --git a/Cargo.toml b/Cargo.toml index 7bf4de5..5db2939 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] resolver = "2" -members = ["crates/regulator-core", "crates/regulator-tui"] +members = ["crates/regulator-core", "crates/regulator-tui", "crates/regulator-gui"] [workspace.package] version = "0.1.0" diff --git a/README.md b/README.md index bcd5623..7a2ef8c 100644 --- a/README.md +++ b/README.md @@ -20,12 +20,15 @@ documentation, including the microphone calibration procedure. fully unit-tested against a synthetic watch signal generator. - `crates/regulator-tui` — the terminal interface (ratatui), with live microphone capture (cpal) and a `--demo` mode driven by a synthetic watch. +- `crates/regulator-gui` — the graphical interface (egui): big readouts, + waveform plot, settings panel; same demo/microphone sources. ## Build & run ```sh -cargo run -p regulator-tui # live microphone (needs ALSA/CoreAudio/WASAPI) cargo run -p regulator-tui -- --demo # synthetic watch, no hardware needed +cargo run -p regulator-tui # live microphone (needs ALSA/CoreAudio/WASAPI) +cargo run -p regulator-gui # graphical interface (demo mode by default) ``` Useful keys: `←/→` beat rate preset (auto, 18000…36000 bph), `+/-` lift @@ -37,11 +40,24 @@ To build on a system without an audio stack: cargo build --no-default-features ``` +## Improvements over tg + +- Partial results: rate, beat error and amplitude are reported independently; + a missing measurement is shown blank rather than failing the whole readout. +- Sub-sample period refinement (parabolic interpolation of the autocorrelation + peak) for finer rate resolution than tg's integer-sample estimate. +- Robust amplitude estimation: the impulse duration is measured directly as + the region above 20% of the tic/toc peak, instead of tg's escalating + threshold heuristic. +- Cached FFT plans and reused scratch buffers: plans are built once per + block length instead of per call. + ## Portability -The core crate has no platform dependencies (pure Rust, no C). The TUI uses -cpal for capture, which works on Linux (ALSA), macOS (CoreAudio) and Windows -(WASAPI); without the `audio` feature the binary builds anywhere Rust does. +The core crate has no platform dependencies (pure Rust, no C). Both +frontends use cpal for capture, which works on Linux (ALSA), macOS +(CoreAudio) and Windows (WASAPI); without the `audio` feature they build +anywhere Rust does. ## License diff --git a/crates/regulator-core/src/analyze.rs b/crates/regulator-core/src/analyze.rs index d1c3402..0c09a0e 100644 --- a/crates/regulator-core/src/analyze.rs +++ b/crates/regulator-core/src/analyze.rs @@ -1,45 +1,77 @@ // SPDX-License-Identifier: GPL-2.0 -//! The timing analysis pipeline, ported from tg's algo.c. +//! The timing analysis pipeline, ported from tg's algo.c, with improvements: +//! cached FFT plans, buffer reuse, and sub-sample period refinement. use crate::filters::Biquad; use crate::stats::{median, tmean, vmax}; use rustfft::num_complex::Complex; -use rustfft::FftPlanner; -use std::cell::Cell; +use rustfft::{Fft, FftDirection, FftPlanner}; +use std::cell::RefCell; +use std::collections::HashMap; +use std::sync::Arc; -/// Result of one analysis pass over a block of audio. -#[derive(Clone, Debug)] +/// Result of one analysis pass over a block of audio. Fields are None when +/// that particular measurement could not be determined from the signal. +#[derive(Clone, Debug, Default)] pub struct TimingResult { - /// Detected period in samples (time between consecutive ticks). + /// Detected period in samples (time between same-type ticks). pub period: f64, /// Rate error in seconds per day (positive = fast). - pub rate_sday: f64, + pub rate_sday: Option, /// Beat error in milliseconds (tic-to-toc asymmetry). - pub beat_error_ms: f64, - /// Balance amplitude in degrees, if it could be determined. + pub beat_error_ms: Option, + /// Balance amplitude in degrees. pub amplitude_deg: Option, /// Standard deviation of the period estimate in samples. pub sigma: f64, /// Folded average waveform over one period, median-subtracted. pub waveform: Vec, - /// Beat rate in beats per hour the rate was computed against. + /// Beat rate the rate was computed against. pub bph: u32, + /// Position of the tic peak in the folded waveform, if found. + pub tic: Option, +} + +struct FftCache { + plans: HashMap>>, + scratch: Vec>, +} + +impl FftCache { + fn new() -> Self { + FftCache { + plans: HashMap::new(), + scratch: Vec::new(), + } + } + + fn plan(&mut self, len: usize, direction: FftDirection) -> Arc> { + // rustfft plans are direction-specific; key on len and direction bit. + let key = len * 2 + (direction == FftDirection::Inverse) as usize; + if !self.plans.contains_key(&key) { + let mut planner = FftPlanner::new(); + let fft = match direction { + FftDirection::Forward => planner.plan_fft_forward(len), + FftDirection::Inverse => planner.plan_fft_inverse(len), + }; + self.plans.insert(key, fft); + } + self.plans.get(&key).unwrap().clone() + } } -/// Configurable analyzer. Reuse one instance across blocks; it caches the -/// FFT plans and filter state. /// Snap a detected beats-per-hour value to the nearest standard beat rate. fn snap_bph(detected: f64) -> f64 { const STANDARDS: [f64; 7] = [12000.0, 14400.0, 18000.0, 21600.0, 25200.0, 28800.0, 36000.0]; STANDARDS .iter() .copied() - .min_by(|a, b| { - (a - detected).abs().partial_cmp(&(b - detected).abs()).unwrap() - }) + .min_by(|a, b| (a - detected).abs().partial_cmp(&(b - detected).abs()).unwrap()) .unwrap_or(28800.0) } +/// Configurable analyzer. Reuse one instance across blocks; it caches FFT +/// plans and reuses scratch buffers. pub struct Analyzer { pub sample_rate: u32, /// Beats per hour of the movement under test; 0 = auto-detect. @@ -49,9 +81,12 @@ pub struct Analyzer { /// Enable the impulsive-noise suppressor. pub noise_suppressor: bool, lpf: Biquad, + fft: RefCell, last_sigma: Cell, } +use std::cell::Cell; + impl Analyzer { pub fn new(sample_rate: u32) -> Self { Analyzer { @@ -60,13 +95,15 @@ impl Analyzer { lift_angle: 52.0, noise_suppressor: true, lpf: Biquad::low_pass(crate::FILTER_CUTOFF / sample_rate as f64), + fft: RefCell::new(FftCache::new()), last_sigma: Cell::new(0.0), } } /// Analyze one block of samples. `samples` should be at least one second - /// long; several seconds gives more stable results. Returns None when no - /// plausible tick train was found. + /// long; several seconds gives more stable results. Returns None only + /// when no tick train at all could be found; individual measurements + /// that fail are None inside the result. pub fn analyze(&self, samples: &[f32]) -> Option { if samples.len() < self.sample_rate as usize { return None; @@ -78,8 +115,15 @@ impl Analyzer { self.prepare_data(&mut s); let period = self.compute_period(&s, n)?; let waveform = self.compute_waveform(&s, period, n); - let (beat_error_ms, tic, toc) = self.compute_beat_error(&waveform, period)?; - let amplitude_deg = self.compute_amplitude(&waveform, period, tic, toc); + let (beat_error_ms, tic, toc) = match self.compute_beat_error(&waveform, period) { + Some((be, tic, toc)) => (be, Some(tic), Some(toc)), + None => (None, None, None), + }; + let tic_idx = tic; + let amplitude_deg = match (tic, toc) { + (Some(tic), Some(toc)) => self.compute_amplitude(&waveform, period, tic, toc), + _ => None, + }; let detected_bph = 2.0 * 3600.0 * sr as f64 / period; let bph = if self.bph != 0 { @@ -92,18 +136,17 @@ impl Analyzer { Some(TimingResult { period, - rate_sday, + rate_sday: Some(rate_sday), beat_error_ms, amplitude_deg, sigma: self.last_sigma.get(), waveform, bph: bph as u32, + tic: tic_idx, }) } - /// Rectify, low-pass, normalize and window the input; then compute the - /// autocorrelation into the second half of `s` (as tg does with - /// samples_sc). + /// Rectify, low-pass, normalize and window the input. fn prepare_data(&self, s: &mut Vec) { let n = s.len(); let sr = self.sample_rate as usize; @@ -166,19 +209,43 @@ impl Analyzer { } } - /// Autocorrelation of s (length n) via FFT; result has n points. + /// Autocorrelation of s (length n) via cached FFT plans; result has n + /// points. Unlike tg, the plans are created once per length and reused. fn autocorrelate(&self, s: &[f32], n: usize) -> Vec { - let mut planner = FftPlanner::new(); - let fft = planner.plan_fft_forward(2 * n); + let mut fft = self.fft.borrow_mut(); + let forward = fft.plan(2 * n, FftDirection::Forward); + let inverse = fft.plan(2 * n, FftDirection::Inverse); + let scratch_len = forward.get_inplace_scratch_len().max(inverse.get_inplace_scratch_len()); + fft.scratch.resize(scratch_len, Complex::default()); let mut buf: Vec> = s.iter().map(|&v| Complex::new(v, 0.0)).collect(); buf.resize(2 * n, Complex::default()); - fft.process(&mut buf); + forward.process_with_scratch(&mut buf, &mut fft.scratch); for c in buf.iter_mut() { *c = *c * c.conj(); } - let ifft = planner.plan_fft_inverse(2 * n); - ifft.process(&mut buf); - buf[..n].iter().map(|c| c.re).collect() + inverse.process_with_scratch(&mut buf, &mut fft.scratch); + buf.truncate(n); + buf.iter().map(|c| c.re).collect() + } + + /// Parabolic interpolation around an integer peak of `ac` for a + /// sub-sample peak position. This refines the period estimate beyond + /// tg's integer-sample resolution, improving rate precision. + fn interpolate_peak(ac: &[f32], p: usize) -> f64 { + if p == 0 || p + 1 >= ac.len() { + return p as f64; + } + let (a, b, c) = (ac[p - 1] as f64, ac[p] as f64, ac[p + 1] as f64); + let denom = a - 2.0 * b + c; + if denom.abs() < 1e-12 { + return p as f64; + } + let delta = 0.5 * (a - c) / denom; + if delta.abs() <= 1.0 { + p as f64 + delta + } else { + p as f64 + } } /// tg's peak_detector: the maximum of buff[a..=b] is accepted only if it @@ -216,8 +283,7 @@ impl Analyzer { } /// Autocorrelation-based period estimation, ported from tg's - /// estimate_period(): find the first candidate peak, try submultiples, - /// and validate against the 1.5x peak. + /// estimate_period(). fn estimate_period(&self, ac: &[f32], sr: usize) -> Option { let first = vmax(ac, sr / 12, sr.min(ac.len())).1; let a = (sr / 12).max(first.saturating_sub(sr / 12)); @@ -260,8 +326,10 @@ impl Analyzer { Some(estimate) } - /// Refine the period estimate by locating peaks at successive multiples, - /// averaging the per-cycle estimates, ported from tg's compute_period(). + /// Refine the period estimate by locating peaks at successive multiples + /// and averaging the per-cycle estimates, ported from tg's + /// compute_period(). Unlike tg, the final estimate is refined with + /// parabolic interpolation for sub-sample period resolution. fn compute_period(&self, s: &[f32], n: usize) -> Option { let sr = self.sample_rate as usize; let ac = self.autocorrelate(s, n); @@ -280,13 +348,15 @@ impl Analyzer { let mut sq_sum = 0.0; let mut count = 0; let mut cycle = 1usize; + let mut last_peak = 0usize; loop { let inf = (new_estimate * cycle as f64 - delta).floor() as usize; let sup = (new_estimate * cycle as f64 + delta).ceil() as usize; if sup > n * 2 / 3 || sup >= ac.len() { break; } - new_estimate = Self::peak_detector(&ac, inf, sup)? as f64; + let peak = Self::peak_detector(&ac, inf, sup)?; + new_estimate = peak as f64; new_estimate /= cycle as f64; if new_estimate < estimate - delta || new_estimate > estimate + delta { return None; @@ -297,17 +367,27 @@ impl Analyzer { count += 1; } cycle += 1; + last_peak = peak; } let period = if count > 0 { sum / count as f64 } else { estimate }; - self.last_sigma - .set(if count > 1 { - ((sq_sum - count as f64 * period * period) / (count - 1) as f64).sqrt() - } else { - 0.0 - }); - if period >= 1.2 * 3600.0 * 2.0 * sr as f64 / if self.bph != 0 { self.bph } else { 18000 } as f64 { + self.last_sigma.set(if count > 1 { + ((sq_sum - count as f64 * period * period) / (count - 1) as f64).sqrt() + } else { + 0.0 + }); + if period >= 1.2 * 3600.0 * 2.0 * sr as f64 / if self.bph != 0 { self.bph } else { 18000 } as f64 + { return None; } + // Sub-sample refinement: interpolate the autocorrelation around the + // last accepted peak, expressed back as a per-period offset. + if last_peak > 0 && count > 0 { + let cycles = (last_peak as f64 / period).round().max(1.0); + let refined = Self::interpolate_peak(&ac, last_peak) / cycles; + if (refined - period).abs() < delta { + return Some(refined); + } + } Some(period) } @@ -373,7 +453,7 @@ impl Analyzer { /// Beat error: distance between the tic and toc peaks in the folded /// waveform, found via the waveform autocorrelation, ported from tg's /// compute_parameters(). Returns (beat error ms, tic index, toc index). - fn compute_beat_error(&self, wf: &[f32], period: f64) -> Option<(f64, usize, usize)> { + fn compute_beat_error(&self, wf: &[f32], period: f64) -> Option<(Option, usize, usize)> { let sr = self.sample_rate as usize; let n = wf.len(); let ac = self.autocorrelate(wf, n); @@ -403,11 +483,14 @@ impl Analyzer { } let tic = max_i; let toc = tic + tic_to_toc; - Some((be * 1000.0 / sr as f64, tic, toc)) + Some((Some(be * 1000.0 / sr as f64), tic, toc)) } - /// Amplitude from the tic/toc pulse widths, ported from tg's - /// compute_amplitude(). + /// Amplitude from the tic/toc pulse widths. tg measures the distance + /// between an escalating threshold crossing and the smoothed peak, which + /// is fragile; regulator instead measures the duration the smoothed + /// pulse stays above 20% of its peak, which is the impulse duration the + /// amplitude formula wants: A/la = 0.5 / sin(pi * pulse / period). fn compute_amplitude(&self, wf: &[f32], period: f64, tic: usize, toc: usize) -> Option { let sr = self.sample_rate as usize; let wf_size = wf.len(); @@ -418,87 +501,49 @@ impl Analyzer { if smooth.is_empty() { return None; } + let wlen = smooth.len(); + let max_walk = (period / 8.0) as usize; - let glob_max = vmax(&smooth, 0, smooth.len().min(period.ceil() as usize)).0; - if glob_max <= 0.0 { - return None; - } - let mut max = 0.0f32; - for &t in &[tic, toc] { - let mut j = ((t as f64 + period / 8.0) % period) as usize; - for _ in 0..(period / 8.0) as usize { - if smooth[j] > max { - max = smooth[j]; - } - j += 1; - if j as f64 > period { - j = 0; - } + let mut amps = [0.0f64; 2]; + for (k, &t) in [tic, toc].iter().enumerate() { + if t >= wlen { + return None; } - } - let mut threshold = (0.01 * glob_max).max(1.4 * max); - - let mut tic_pulse; - let mut toc_pulse; - while threshold < 0.2 * glob_max { - tic_pulse = -1.0; - toc_pulse = -1.0; - let mut ok = true; - for (k, &t) in [toc, tic].iter().enumerate() { - let mut j = ((t as f64 + 7.0 * period / 8.0) % period) as usize; - let mut i = 0; - let eighth = (period / 8.0) as usize; - while i < eighth { - if smooth[j] > threshold { - break; - } - i += 1; - j += 1; - if j as f64 > period { - j = 0; - } - } - let mut max = 0.0f32; - while i < eighth { - let x = smooth[j]; - if x > max { - max = x; - } else { - break; - } - i += 1; - j += 1; - if j as f64 > period { - j = 0; - } - } - if i < eighth { - let pulse = period / 8.0 - i as f64 - 1.0; - if k == 0 { - tic_pulse = pulse; - } else { - toc_pulse = pulse; - } - } else { - ok = false; + let peak = smooth[t]; + if peak <= 0.0 { + return None; + } + let th = 0.2 * peak; + let mut lo = t; + for _ in 0..max_walk { + if smooth[(lo + wlen - 1) % wlen] <= th { break; } + lo = (lo + wlen - 1) % wlen; } - if ok { - let tic_amp_abs = 0.5 / (std::f64::consts::PI * tic_pulse / period).sin(); - let toc_amp_abs = 0.5 / (std::f64::consts::PI * toc_pulse / period).sin(); - let tic_amp = self.lift_angle * tic_amp_abs; - let toc_amp = self.lift_angle * toc_amp_abs; - if (135.0..360.0).contains(&tic_amp) - && (135.0..360.0).contains(&toc_amp) - && (tic_amp - toc_amp).abs() < 60.0 - { - return Some(self.lift_angle * (tic_amp_abs + toc_amp_abs) / 2.0); + let mut hi = t; + for _ in 0..max_walk { + if smooth[hi % wlen] <= th { + break; } + hi = (hi + 1) % wlen; } - threshold *= 1.4; + let span = (hi + wlen - lo) % wlen; + if span == 0 || span >= max_walk { + return None; + } + amps[k] = 0.5 / (std::f64::consts::PI * span as f64 / period).sin(); + } + let tic_amp = self.lift_angle * amps[0]; + let toc_amp = self.lift_angle * amps[1]; + if (135.0..360.0).contains(&tic_amp) + && (135.0..360.0).contains(&toc_amp) + && (tic_amp - toc_amp).abs() < 60.0 + { + Some(self.lift_angle * (amps[0] + amps[1]) / 2.0) + } else { + None } - None } /// Exponential-decay peak smoother, ported from tg's smooth(). diff --git a/crates/regulator-core/src/signal.rs b/crates/regulator-core/src/signal.rs index a19fbbf..b370b75 100644 --- a/crates/regulator-core/src/signal.rs +++ b/crates/regulator-core/src/signal.rs @@ -26,7 +26,7 @@ impl SyntheticWatch { let n = (duration_s * sample_rate as f64) as usize; let mut out = vec![0f32; n]; let sr = sample_rate as f64; - let burst_len = (0.004 * sr) as usize; + let burst_len = (0.02 * sr) as usize; let mut t = 0.0f64; let mut flip = false; let mut rng = 0x1234_5678u64; @@ -48,11 +48,19 @@ impl SyntheticWatch { * (0.5 / amp_abs).asin() / std::f64::consts::PI * sr) as usize; - for i in 0..width.min(burst_len) { + let width = width.min(burst_len); + for i in 0..width { let tt = i as f64 / sr; - let env = (-tt * 1500.0).exp(); + // Sharp attack at the unlock, exponential decay: like a + // real impulse, the sound starts at the tick and rings + // down. The analyzer measures the duration above 20% of + // the peak, which tracks `width`. + let env = (-1.6 * i as f64 / width as f64).exp(); let carrier = (2.0 * std::f64::consts::PI * 3500.0 * tt).sin(); - out[base + i] += (env * carrier * 0.8) as f32; + let idx = base as isize + i as isize; + if idx >= 0 && (idx as usize) < n { + out[idx as usize] += (env * carrier * 0.8) as f32; + } } } flip = !flip; @@ -93,7 +101,7 @@ mod tests { let mut an = Analyzer::new(SR); an.bph = 28800; let r = an.analyze(&samples).expect("analysis failed"); - assert!((r.rate_sday - 12.0).abs() < 3.0, "rate: {}", r.rate_sday); + assert!((r.rate_sday.unwrap() - 12.0).abs() < 3.0, "rate: {:?}", r.rate_sday); } #[test] @@ -127,12 +135,28 @@ mod tests { an.bph = 21600; let r = an.analyze(&samples).expect("analysis failed"); assert!( - (r.beat_error_ms - 1.2).abs() < 0.8, - "beat error: {}", + (r.beat_error_ms.unwrap() - 1.2).abs() < 0.8, + "beat error: {:?}", r.beat_error_ms ); } + #[test] + fn detects_amplitude() { + let watch = SyntheticWatch { + bph: 28800, + rate_sday: 0.0, + beat_error_ms: 0.0, + amplitude_deg: 270.0, + }; + let samples = watch.generate(SR, 4.0); + let mut an = Analyzer::new(SR); + an.bph = 28800; + let r = an.analyze(&samples).expect("analysis failed"); + let amp = r.amplitude_deg.expect("amplitude not found"); + assert!((amp - 270.0).abs() < 25.0, "amplitude: {amp}"); + } + #[test] fn rejects_silence() { let an = Analyzer::new(SR); diff --git a/crates/regulator-gui/Cargo.toml b/crates/regulator-gui/Cargo.toml new file mode 100644 index 0000000..c1536ad --- /dev/null +++ b/crates/regulator-gui/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "regulator-gui" +description = "Graphical UI for the regulator watch timing machine" +version.workspace = true +edition.workspace = true +license.workspace = true +repository.workspace = true + +[[bin]] +name = "regulator-gui" +path = "src/main.rs" + +[features] +default = ["audio"] +audio = ["dep:cpal"] + +[dependencies] +regulator-core = { path = "../regulator-core" } +eframe = "0.33" +anyhow = "1" +cpal = { version = "0.15", optional = true } diff --git a/crates/regulator-gui/src/audio.rs b/crates/regulator-gui/src/audio.rs new file mode 100644 index 0000000..bf0706f --- /dev/null +++ b/crates/regulator-gui/src/audio.rs @@ -0,0 +1,109 @@ +// SPDX-License-Identifier: GPL-2.0 +//! Live audio capture via cpal. Compiled only with the `audio` feature. + +use anyhow::{Context, Result}; +use cpal::traits::{DeviceTrait, HostTrait, StreamTrait}; +use std::sync::mpsc::Sender; + +const TARGET_RATE: f64 = 44100.0; + +/// Naive linear resampler state: converts the device's sample rate to the +/// 44.1 kHz mono stream the analyzer expects. +struct Resampler { + step: f64, + frac: f64, +} + +impl Resampler { + fn new(input_rate: f64) -> Self { + Resampler { + step: input_rate / TARGET_RATE, + frac: 0.0, + } + } + + fn push(&mut self, mono: &[f32], tx: &Sender) { + while self.frac < mono.len() as f64 { + let x = self.frac as usize; + let next = mono[(x + 1).min(mono.len() - 1)]; + let t = (self.frac - x as f64) as f32; + let s = mono[x] * (1.0 - t) + next * t; + let _ = tx.send(s); + self.frac += self.step; + } + self.frac -= mono.len() as f64; + } +} + +/// Spawn the default input device and stream mono 44.1 kHz f32 samples to +/// `tx`. +pub fn spawn_capture(tx: Sender) -> Result<()> { + let host = cpal::default_host(); + let device = host + .default_input_device() + .context("no audio input device found")?; + let supported = device + .default_input_config() + .context("no supported input configuration")?; + let channels = supported.channels() as usize; + let sample_format = supported.sample_format(); + let config: cpal::StreamConfig = supported.into(); + let mut resampler = Resampler::new(config.sample_rate.0 as f64); + let tx_f32 = tx.clone(); + + let stream = match sample_format { + cpal::SampleFormat::F32 => device.build_input_stream( + &config, + move |data: &[f32], _| { + let mono = mix_mono(data, channels); + resampler.push(&mono, &tx_f32); + }, + err_cb, + None, + )?, + cpal::SampleFormat::I16 => device.build_input_stream( + &config, + move |data: &[i16], _| { + let mono = mix_mono( + &data.iter().map(|&v| v as f32 / i16::MAX as f32).collect::>(), + channels, + ); + resampler.push(&mono, &tx_f32); + }, + err_cb, + None, + )?, + cpal::SampleFormat::U16 => device.build_input_stream( + &config, + move |data: &[u16], _| { + let mono = mix_mono( + &data + .iter() + .map(|&v| (v as f32 - u16::MAX as f32 / 2.0) / (u16::MAX as f32 / 2.0)) + .collect::>(), + channels, + ); + resampler.push(&mono, &tx_f32); + }, + err_cb, + None, + )?, + other => anyhow::bail!("unsupported sample format: {other:?}"), + }; + stream.play()?; + std::mem::forget(stream); + Ok(()) +} + +fn err_cb(err: cpal::StreamError) { + eprintln!("audio error: {err}"); +} + +fn mix_mono(data: &[f32], channels: usize) -> Vec { + if channels <= 1 { + return data.to_vec(); + } + data.chunks(channels) + .map(|c| c.iter().sum::() / c.len() as f32) + .collect() +} diff --git a/crates/regulator-gui/src/main.rs b/crates/regulator-gui/src/main.rs new file mode 100644 index 0000000..125a0ac --- /dev/null +++ b/crates/regulator-gui/src/main.rs @@ -0,0 +1,258 @@ +// SPDX-License-Identifier: GPL-2.0 +//! regulator-gui: graphical watch timing machine built on the regulator +//! core, using egui for an immediate-mode, cross-platform interface. + +#[cfg(feature = "audio")] +mod audio; + +use eframe::egui; +use regulator_core::{Analyzer, SyntheticWatch, TimingResult}; +use std::sync::mpsc; +use std::sync::{Arc, Mutex}; +use std::time::Duration; + +const SAMPLE_RATE: u32 = 44100; +const BLOCK_SECONDS: f64 = 4.0; + +#[derive(Clone)] +struct Params { + bph: u32, + lift_angle: f64, + noise_suppressor: bool, + demo: bool, +} + +impl Default for Params { + fn default() -> Self { + Params { + bph: 0, + lift_angle: 52.0, + noise_suppressor: true, + demo: true, + } + } +} + +/// Shared ring buffer of live microphone samples (if capture is available). +type Ring = Arc>>; + +struct RegulatorApp { + result: Option, + params: Arc>, + rx: mpsc::Receiver>, +} + +impl RegulatorApp { + fn new(ring: Option) -> Self { + let params = Arc::new(Mutex::new(Params::default())); + let (tx, rx) = mpsc::channel::>(); + let p = params.clone(); + std::thread::spawn(move || { + let watch = SyntheticWatch { + bph: 28800, + rate_sday: 9.0, + beat_error_ms: 0.6, + amplitude_deg: 275.0, + }; + let demo_samples = watch.generate(SAMPLE_RATE, 120.0); + let block = (BLOCK_SECONDS * SAMPLE_RATE as f64) as usize; + let mut start = 0usize; + loop { + let p = p.lock().unwrap().clone(); + let mut analyzer = Analyzer::new(SAMPLE_RATE); + analyzer.bph = p.bph; + analyzer.lift_angle = p.lift_angle; + analyzer.noise_suppressor = p.noise_suppressor; + let res = if p.demo { + let end = (start + block).min(demo_samples.len()); + let r = analyzer.analyze(&demo_samples[start..end]); + if end == demo_samples.len() { + start = 0; + } else { + start = end; + } + r + } else if let Some(ring) = &ring { + let buf = ring.lock().unwrap(); + if buf.len() >= block { + analyzer.analyze(&buf[buf.len() - block..]) + } else { + None + } + } else { + None + }; + let _ = tx.send(res); + std::thread::sleep(Duration::from_millis(200)); + } + }); + Self { + result: None, + params, + rx, + } + } +} + +impl eframe::App for RegulatorApp { + fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { + while let Ok(r) = self.rx.try_recv() { + self.result = r; + } + + egui::SidePanel::right("settings") + .min_width(220.0) + .show(ctx, |ui| { + let mut p = self.params.lock().unwrap(); + ui.heading("Settings"); + ui.separator(); + ui.label("Beat rate"); + egui::ComboBox::from_id_salt("bph") + .selected_text(if p.bph == 0 { "auto".into() } else { p.bph.to_string() }) + .show_ui(ui, |ui| { + for b in [0u32, 18000, 21600, 25200, 28800, 36000] { + ui.selectable_value( + &mut p.bph, + b, + if b == 0 { "auto".into() } else { b.to_string() }, + ); + } + }); + ui.add( + egui::Slider::new(&mut p.lift_angle, 40.0..=60.0).text("lift angle (°)"), + ); + ui.checkbox(&mut p.noise_suppressor, "noise suppressor"); + ui.separator(); + if p.demo { + ui.label("source: demo signal"); + } else { + ui.label("source: microphone"); + } + ui.checkbox(&mut p.demo, "demo mode"); + ui.separator(); + ui.small("regulator — GPLv2\na fork of tg"); + }); + + egui::CentralPanel::default().show(ctx, |ui| { + ui.horizontal(|ui| { + big_metric( + ui, + "Rate", + &self.result.as_ref().and_then(|r| r.rate_sday), + "s/day", + 1, + ); + big_metric( + ui, + "Amplitude", + &self.result.as_ref().and_then(|r| r.amplitude_deg), + "°", + 0, + ); + big_metric( + ui, + "Beat error", + &self.result.as_ref().and_then(|r| r.beat_error_ms), + "ms", + 2, + ); + }); + ui.separator(); + draw_waveform(ui, &self.result); + }); + + ctx.request_repaint_after(Duration::from_millis(200)); + } +} + +fn big_metric(ui: &mut egui::Ui, name: &str, value: &Option, unit: &str, decimals: usize) { + let text = match value { + Some(v) => format!("{:+.width$}", v, width = decimals), + None => "---".into(), + }; + ui.vertical(|ui| { + ui.heading(egui::RichText::new(text).size(34.0)); + ui.label(format!("{name} ({unit})")); + }); +} + +fn draw_waveform(ui: &mut egui::Ui, result: &Option) { + let (resp, painter) = ui.allocate_painter(ui.available_size(), egui::Sense::hover()); + painter.rect_filled(resp.rect, 4.0, egui::Color32::from_gray(16)); + let Some(r) = result else { return }; + let wf = &r.waveform; + if wf.is_empty() { + return; + } + let max = wf.iter().cloned().fold(0f32, f32::max).max(1e-9); + let rect = resp.rect; + let n = wf.len(); + let mid = rect.center().y; + let to_screen = |i: usize, v: f32| { + egui::pos2( + rect.left() + (i as f32 / n as f32) * rect.width(), + mid - (v / max) * (rect.height() / 2.0 - 4.0), + ) + }; + let points: Vec = wf.iter().enumerate().map(|(i, &v)| to_screen(i, v)).collect(); + painter.add(egui::Shape::line( + points, + egui::Stroke::new(1.5_f32, egui::Color32::LIGHT_GREEN), + )); + if let Some(tic) = r.tic { + let x = to_screen(tic, 0.0).x; + painter.line_segment( + [egui::pos2(x, rect.top() + 2.0), egui::pos2(x, rect.bottom() - 2.0)], + egui::Stroke::new(1.0_f32, egui::Color32::YELLOW), + ); + } +} + +fn main() -> anyhow::Result<()> { + // Live capture (if built with the audio feature); a relay thread moves + // samples into a shared ring buffer the worker reads. + let ring: Option = { + #[cfg(feature = "audio")] + { + let (tx, rx) = mpsc::channel::(); + match audio::spawn_capture(tx) { + Ok(()) => { + let ring: Ring = Arc::new(Mutex::new(Vec::new())); + let r = ring.clone(); + std::thread::spawn(move || { + let block = (BLOCK_SECONDS * SAMPLE_RATE as f64) as usize; + while let Ok(s) = rx.recv() { + let mut buf = r.lock().unwrap(); + buf.push(s); + if buf.len() > block * 2 { + buf.drain(..block); + } + } + }); + Some(ring) + } + Err(e) => { + eprintln!("audio capture unavailable: {e}; using demo mode"); + None + } + } + } + #[cfg(not(feature = "audio"))] + { + None + } + }; + + let native = eframe::NativeOptions { + viewport: egui::ViewportBuilder::default() + .with_inner_size([900.0, 520.0]) + .with_title("regulator"), + ..Default::default() + }; + eframe::run_native( + "regulator", + native, + Box::new(move |_cc| Ok(Box::new(RegulatorApp::new(ring)))), + ) + .map_err(|e| anyhow::anyhow!("{e}")) +} diff --git a/crates/regulator-tui/src/ui.rs b/crates/regulator-tui/src/ui.rs index 96b4415..af46371 100644 --- a/crates/regulator-tui/src/ui.rs +++ b/crates/regulator-tui/src/ui.rs @@ -48,35 +48,35 @@ fn draw_readout(f: &mut ratatui::Frame, area: Rect, res: &Option) .constraints([Constraint::Ratio(1, 3); 3]) .split(area); + let blank = ("---".to_string(), Color::DarkGray); let (rate, amp, be) = match res { Some(r) => ( - ( - format!("{:+.1}", r.rate_sday), - " s/day", - rate_color(r.rate_sday), - ), - ( - match r.amplitude_deg { - Some(a) => format!("{a:.0}"), - None => "---".into(), - }, - " deg", - Color::Cyan, - ), - (format!("{:+.2}", r.beat_error_ms), " ms", Color::Magenta), - ), - None => ( - ("---".into(), " s/day", Color::DarkGray), - ("---".into(), " deg", Color::DarkGray), - ("---".into(), " ms", Color::DarkGray), + match r.rate_sday { + Some(v) => (format!("{v:+.1}"), rate_color(v)), + None => blank.clone(), + }, + match r.amplitude_deg { + Some(v) => (format!("{v:.0}"), Color::Cyan), + None => blank.clone(), + }, + match r.beat_error_ms { + Some(v) => (format!("{v:+.2}"), Color::Magenta), + None => blank.clone(), + }, ), + None => (blank.clone(), blank.clone(), blank), }; - for (col, (title, (val, unit, color))) in ["Rate", "Amplitude", "Beat error"] - .into_iter() - .zip([rate, amp, be]) - .enumerate() + for (col, (title, (val, color), unit)) in [ + ("Rate", rate, " s/day"), + ("Amplitude", amp, " deg"), + ("Beat error", be, " ms"), + ] + .into_iter() + .enumerate() { - let block = Block::default().borders(Borders::ALL).title(format!(" {title} ")); + let block = Block::default() + .borders(Borders::ALL) + .title(format!(" {title} ")); f.render_widget(block, cols[col]); let a = cols[col].inner(Margin::new(2, 1)); let p = Paragraph::new(Line::from(vec![ @@ -110,21 +110,36 @@ fn draw_waveform(f: &mut ratatui::Frame, area: Rect, res: &Option) if wf.is_empty() { return; } + + // Scale so the largest excursion fits the panel. let max = wf.iter().cloned().fold(0f32, f32::max).max(1e-9); let mid = inner.height as f32 / 2.0; + let scale = (mid - 1.0) / max; + let tic_x = r.tic.map(|t| t as u32 * inner.width as u32 / wf.len() as u32); + for x in 0..inner.width { let i = x as usize * wf.len() / inner.width as usize; - let v = wf[i.min(wf.len() - 1)] / max; - let h = ((v.abs() * mid).ceil() as u16).clamp(1, inner.height); + let v = wf[i.min(wf.len() - 1)] * scale; + let h = ((v.abs() * mid).ceil() as u16).clamp(1, inner.height) as u16; let y = if v >= 0.0 { (mid as u16).saturating_sub(h) } else { mid as u16 }; - let style = Style::default().fg(if v >= 0.0 { Color::Green } else { Color::Red }); + // Tic/toc position marker column. + let is_marker = tic_x.is_some_and(|tx| (x as u32).abs_diff(tx) <= 1); + let style = if is_marker { + Style::default().fg(Color::Yellow) + } else if v >= 0.0 { + Style::default().fg(Color::Green) + } else { + Style::default().fg(Color::Red) + }; for dy in 0..h { let py = (inner.y + y + dy).min(inner.y + inner.height - 1); - f.buffer_mut()[(inner.x + x, py)].set_char('█').set_style(style); + f.buffer_mut()[(inner.x + x, py)] + .set_char(if is_marker { '▓' } else { '█' }) + .set_style(style); } } } From 4dfe74c316cd57fb53e191127a8c24d2a8b283e7 Mon Sep 17 00:00:00 2001 From: borosf Date: Tue, 17 Nov 2026 19:58:43 +0000 Subject: [PATCH 06/20] Fix peak_detector panic on degenerate search ranges (mic noise) Real microphone noise can collapse the autocorrelation search window to a==b or run it past the buffer end; tg's C loops handle this implicitly but the Rust port sliced out of range. Guard the ranges, reject right-edge peaks like the C code does, and make the frontends resilient to a poisoned lock. Regression tests for the degenerate cases. Co-authored-by: borosf --- crates/regulator-core/src/analyze.rs | 27 +++++++++++++++++++++++++-- crates/regulator-gui/src/main.rs | 8 ++++---- crates/regulator-tui/src/main.rs | 10 +++++----- 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/crates/regulator-core/src/analyze.rs b/crates/regulator-core/src/analyze.rs index 0c09a0e..86e95c6 100644 --- a/crates/regulator-core/src/analyze.rs +++ b/crates/regulator-core/src/analyze.rs @@ -252,15 +252,18 @@ impl Analyzer { /// is a real peak (rises above the local median, not part of a sustained /// plateau). Returns the index or None. fn peak_detector(buff: &[f32], a: usize, b: usize) -> Option { + if b <= a || b >= buff.len() { + return None; + } let (max, i_max) = vmax(buff, a, b + 1); if max <= 0.0 { return None; } let med = median(&mut buff[a..=b].to_vec()); - if buff[a + 1..i_max].iter().all(|&v| v > med) { + if i_max > a + 1 && buff[a + 1..i_max].iter().all(|&v| v > med) { return None; } - if buff[i_max + 1..=b].iter().all(|&v| v > med) { + if i_max == b || buff[i_max + 1..=b].iter().all(|&v| v > med) { return None; } let mut cnt = 0; @@ -581,3 +584,23 @@ impl Analyzer { out } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn peak_detector_degenerate_ranges() { + let v = vec![1.0, 5.0, 1.0]; + assert_eq!(Analyzer::peak_detector(&v, 1, 1), None); + assert_eq!(Analyzer::peak_detector(&v, 2, 1), None); + assert_eq!(Analyzer::peak_detector(&v, 0, 3), None); + assert_eq!(Analyzer::peak_detector(&v, 0, 2), Some(1)); + } + + #[test] + fn peak_detector_rejects_edge_peak() { + let v = vec![1.0, 2.0, 5.0]; + assert_eq!(Analyzer::peak_detector(&v, 0, 2), None); + } +} diff --git a/crates/regulator-gui/src/main.rs b/crates/regulator-gui/src/main.rs index 125a0ac..2f7820d 100644 --- a/crates/regulator-gui/src/main.rs +++ b/crates/regulator-gui/src/main.rs @@ -58,7 +58,7 @@ impl RegulatorApp { let block = (BLOCK_SECONDS * SAMPLE_RATE as f64) as usize; let mut start = 0usize; loop { - let p = p.lock().unwrap().clone(); + let p = p.lock().unwrap_or_else(|e| e.into_inner()).clone(); let mut analyzer = Analyzer::new(SAMPLE_RATE); analyzer.bph = p.bph; analyzer.lift_angle = p.lift_angle; @@ -73,7 +73,7 @@ impl RegulatorApp { } r } else if let Some(ring) = &ring { - let buf = ring.lock().unwrap(); + let buf = ring.lock().unwrap_or_else(|e| e.into_inner()); if buf.len() >= block { analyzer.analyze(&buf[buf.len() - block..]) } else { @@ -103,7 +103,7 @@ impl eframe::App for RegulatorApp { egui::SidePanel::right("settings") .min_width(220.0) .show(ctx, |ui| { - let mut p = self.params.lock().unwrap(); + let mut p = self.params.lock().unwrap_or_else(|e| e.into_inner()); ui.heading("Settings"); ui.separator(); ui.label("Beat rate"); @@ -222,7 +222,7 @@ fn main() -> anyhow::Result<()> { std::thread::spawn(move || { let block = (BLOCK_SECONDS * SAMPLE_RATE as f64) as usize; while let Ok(s) = rx.recv() { - let mut buf = r.lock().unwrap(); + let mut buf = r.lock().unwrap_or_else(|e| e.into_inner()); buf.push(s); if buf.len() > block * 2 { buf.drain(..block); diff --git a/crates/regulator-tui/src/main.rs b/crates/regulator-tui/src/main.rs index 0a7d7b5..10199ea 100644 --- a/crates/regulator-tui/src/main.rs +++ b/crates/regulator-tui/src/main.rs @@ -24,7 +24,7 @@ const BLOCK_SECONDS: f64 = 4.0; fn main() -> Result<()> { let demo = std::env::args().any(|a| a == "--demo"); let settings = Arc::new(Mutex::new(Settings::default())); - settings.lock().unwrap().source = if demo { "demo" } else { "mic" }.into(); + settings.lock().unwrap_or_else(|e| e.into_inner()).source = if demo { "demo" } else { "mic" }.into(); let (result_tx, result_rx) = mpsc::channel::>(); @@ -71,7 +71,7 @@ fn spawn_demo_worker(tx: mpsc::Sender>, settings: Arc= block { - let res = analyze_block(&buf[buf.len() - block..], &settings.lock().unwrap().clone()); + let res = analyze_block(&buf[buf.len() - block..], &settings.lock().unwrap_or_else(|e| e.into_inner()).clone()); let _ = tx.send(res); } std::thread::sleep(Duration::from_millis(100)); @@ -123,7 +123,7 @@ fn run_tui( if event::poll(Duration::from_millis(50))? { if let Event::Key(key) = event::read()? { if key.kind == KeyEventKind::Press { - let mut s = settings.lock().unwrap(); + let mut s = settings.lock().unwrap_or_else(|e| e.into_inner()); match key.code { KeyCode::Char('q') | KeyCode::Esc => break, KeyCode::Left | KeyCode::Right => { @@ -148,7 +148,7 @@ fn run_tui( result = r; } if last_draw.elapsed() > Duration::from_millis(100) { - let s = settings.lock().unwrap().clone(); + let s = settings.lock().unwrap_or_else(|e| e.into_inner()).clone(); terminal.draw(|f| ui::draw(f, &result, &s))?; last_draw = Instant::now(); } From 8a3686e2b32272d092bd0439ee1c0d9bca7fd925 Mon Sep 17 00:00:00 2001 From: borosf Date: Tue, 17 Nov 2026 20:07:24 +0000 Subject: [PATCH 07/20] Port tg's sound-card calibration; GUI controls; WAV analysis tool - regulator-core::calibrate: CalibrationState ports tg's calibration (quartz watch ticking 1/s, phase drift fit over CAL_DATA_SIZE=900 one-second samples); Analyzer applies the correction to rate (measured - calibration); validated on synthetic quartz: -15.2 s/d recovered for a +15 s/d fast clock - GUI: calibrate button with live progress, calibration readout, calibration runs on mic input with sliding 4 s windows - analyze_wav example: analyze any WAV recording, printing per-block results, for debugging against real recordings Co-authored-by: borosf --- Cargo.lock | 9 +- crates/regulator-core/Cargo.toml | 3 + crates/regulator-core/examples/analyze_wav.rs | 49 ++++ crates/regulator-core/src/analyze.rs | 29 ++- crates/regulator-core/src/calibrate.rs | 211 ++++++++++++++++++ crates/regulator-core/src/lib.rs | 2 + crates/regulator-gui/src/main.rs | 76 ++++++- crates/regulator-tui/src/main.rs | 47 +++- crates/regulator-tui/src/ui.rs | 15 +- 9 files changed, 420 insertions(+), 21 deletions(-) create mode 100644 crates/regulator-core/examples/analyze_wav.rs create mode 100644 crates/regulator-core/src/calibrate.rs diff --git a/Cargo.lock b/Cargo.lock index 3ec32a8..7267273 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1512,7 +1512,7 @@ dependencies = [ "log", "presser", "thiserror 1.0.69", - "windows 0.54.0", + "windows 0.58.0", ] [[package]] @@ -1597,6 +1597,12 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df" +[[package]] +name = "hound" +version = "3.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62adaabb884c94955b19907d60019f4e145d091c75345379e70d1ee696f7854f" + [[package]] name = "icu_collections" version = "2.4.0" @@ -2885,6 +2891,7 @@ checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" name = "regulator-core" version = "0.1.0" dependencies = [ + "hound", "rustfft", ] diff --git a/crates/regulator-core/Cargo.toml b/crates/regulator-core/Cargo.toml index d4afb70..d48fb2a 100644 --- a/crates/regulator-core/Cargo.toml +++ b/crates/regulator-core/Cargo.toml @@ -8,3 +8,6 @@ repository.workspace = true [dependencies] rustfft = { workspace = true } + +[dev-dependencies] +hound = "3" diff --git a/crates/regulator-core/examples/analyze_wav.rs b/crates/regulator-core/examples/analyze_wav.rs new file mode 100644 index 0000000..3678ad8 --- /dev/null +++ b/crates/regulator-core/examples/analyze_wav.rs @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: GPL-2.0 +//! Analyze a WAV recording of a watch and print results per block. +//! Usage: cargo run -p regulator-core --example analyze_wav -- file.wav [bph] + +use regulator_core::Analyzer; + +fn main() { + let args: Vec = std::env::args().collect(); + if args.len() < 2 { + eprintln!("usage: analyze_wav [bph] [lift_angle]"); + std::process::exit(1); + } + let bph: u32 = args.get(2).and_then(|s| s.parse().ok()).unwrap_or(0); + let lift: f64 = args.get(3).and_then(|s| s.parse().ok()).unwrap_or(52.0); + let mut reader = hound::WavReader::open(&args[1]).expect("cannot open wav"); + let sr = reader.spec().sample_rate; + let samples: Vec = reader + .samples::() + .map(|s| s.map(|v| v as f32 / i16::MAX as f32).unwrap_or(0.0)) + .collect(); + println!( + "file: {} rate: {sr} samples: {} ({:.1} s) bph: {bph} lift: {lift}", + args[1], + samples.len(), + samples.len() as f64 / sr as f64 + ); + let mut analyzer = Analyzer::new(sr); + analyzer.bph = bph; + analyzer.lift_angle = lift; + let block = (4.0 * sr as f64) as usize; + let mut t = 0.0; + for (i, chunk) in samples.chunks(block).enumerate() { + if chunk.len() < sr as usize { + break; + } + match analyzer.analyze(chunk) { + Some(r) => println!( + "t={t:6.1}s rate={:+8.1} s/d amp={:>5} be={:+6.2} ms period={:.1} bph={}", + r.rate_sday.unwrap_or(f64::NAN), + r.amplitude_deg.map(|a| format!("{a:.0}")).unwrap_or("---".into()), + r.beat_error_ms.unwrap_or(f64::NAN), + r.period, + r.bph, + ), + None => println!("t={t:6.1}s no signal",), + } + t = (i + 1) as f64 * 4.0; + } +} diff --git a/crates/regulator-core/src/analyze.rs b/crates/regulator-core/src/analyze.rs index 86e95c6..a16c1e1 100644 --- a/crates/regulator-core/src/analyze.rs +++ b/crates/regulator-core/src/analyze.rs @@ -80,6 +80,9 @@ pub struct Analyzer { pub lift_angle: f64, /// Enable the impulsive-noise suppressor. pub noise_suppressor: bool, + /// Sound-card calibration in s/day (from CalibrationState); subtracted + /// from the measured rate. + pub calibration: f64, lpf: Biquad, fft: RefCell, last_sigma: Cell, @@ -94,6 +97,7 @@ impl Analyzer { bph: 0, lift_angle: 52.0, noise_suppressor: true, + calibration: 0.0, lpf: Biquad::low_pass(crate::FILTER_CUTOFF / sample_rate as f64), fft: RefCell::new(FftCache::new()), last_sigma: Cell::new(0.0), @@ -114,7 +118,7 @@ impl Analyzer { self.prepare_data(&mut s); let period = self.compute_period(&s, n)?; - let waveform = self.compute_waveform(&s, period, n); + let (waveform, _) = self.compute_waveform(&s, period, n); let (beat_error_ms, tic, toc) = match self.compute_beat_error(&waveform, period) { Some((be, tic, toc)) => (be, Some(tic), Some(toc)), None => (None, None, None), @@ -132,7 +136,7 @@ impl Analyzer { snap_bph(detected_bph) }; let nominal = 7200.0 * sr as f64 / bph; - let rate_sday = (nominal / period - 1.0) * 86400.0; + let rate_sday = (nominal / period - 1.0) * 86400.0 - self.calibration; Some(TimingResult { period, @@ -146,8 +150,17 @@ impl Analyzer { }) } + /// An analyzer configured for sound-card calibration against a quartz + /// watch ticking once per second (tg's 7200 bph nominal period). + pub fn for_calibration(sample_rate: u32) -> Self { + let mut an = Analyzer::new(sample_rate); + an.bph = 7200; + an.noise_suppressor = false; + an + } + /// Rectify, low-pass, normalize and window the input. - fn prepare_data(&self, s: &mut Vec) { + pub(crate) fn prepare_data(&self, s: &mut Vec) { let n = s.len(); let sr = self.sample_rate as usize; if self.noise_suppressor { @@ -333,7 +346,7 @@ impl Analyzer { /// and averaging the per-cycle estimates, ported from tg's /// compute_period(). Unlike tg, the final estimate is refined with /// parabolic interpolation for sub-sample period resolution. - fn compute_period(&self, s: &[f32], n: usize) -> Option { + pub(crate) fn compute_period(&self, s: &[f32], n: usize) -> Option { let sr = self.sample_rate as usize; let ac = self.autocorrelate(s, n); let estimate = if self.bph != 0 { @@ -396,7 +409,7 @@ impl Analyzer { /// Fold the rectified signal at `period` and average into a one-period /// waveform, ported from tg's compute_phase()/compute_waveform(). - fn compute_waveform(&self, s: &[f32], period: f64, n: usize) -> Vec { + pub(crate) fn compute_waveform(&self, s: &[f32], period: f64, n: usize) -> (Vec, f64) { let count = period as usize; let mut wf = vec![0f64; count]; let mut j = 0usize; @@ -425,9 +438,9 @@ impl Analyzer { let binsize = 1 + n / wf_size; let mut bin = vec![0f32; binsize + 1]; let mut wf2 = vec![0f32; wf_size]; - let phase = phase.round() as usize; + let phase_shift = phase.round() as usize; for i in 0..wf_size { - let k = (i + phase) % wf_size; + let k = (i + phase_shift) % wf_size; let mut j = 0; loop { let idx = k + j * wf_size; @@ -450,7 +463,7 @@ impl Analyzer { for v in wf2.iter_mut() { *v -= nl; } - wf2 + (wf2, phase) } /// Beat error: distance between the tic and toc peaks in the folded diff --git a/crates/regulator-core/src/calibrate.rs b/crates/regulator-core/src/calibrate.rs new file mode 100644 index 0000000..e6984d5 --- /dev/null +++ b/crates/regulator-core/src/calibrate.rs @@ -0,0 +1,211 @@ +// SPDX-License-Identifier: GPL-2.0 +//! Sound-card calibration, ported from tg's calibration_data: measure the +//! audio input's clock error by timing a quartz watch that ticks exactly +//! once per second, then subtract the apparent rate from measurements. + + +use crate::analyze::Analyzer; + +/// tg collects CAL_DATA_SIZE one-second ticks before computing the result. +pub const CAL_DATA_SIZE: usize = 900; + +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum CalStatus { + /// Collected `have` of `need` one-second samples. + Collecting { have: usize, need: usize }, + /// Calibration finished; value in seconds per day. + Done(f64), + /// This block could not be used (signal lost); try the next second. + Missed, + /// Calibration failed the quality check. + Failed, +} + +/// Accumulates (time, phase) samples of the quartz tick and fits the drift. +pub struct CalibrationState { + points: Vec<(f64, f64)>, + need: usize, + start_ts: Option, + cal: Option, +} + +impl Default for CalibrationState { + fn default() -> Self { + Self::new() + } +} + +impl CalibrationState { + pub fn new() -> Self { + CalibrationState::with_size(CAL_DATA_SIZE) + } + + /// Calibration over a custom number of one-second samples (tests use a + /// shorter run; tg itself always uses CAL_DATA_SIZE). + pub fn with_size(need: usize) -> Self { + CalibrationState { + points: Vec::new(), + need, + start_ts: None, + cal: None, + } + } + + /// The computed calibration in s/day, if finished. + pub fn calibration(&self) -> Option { + self.cal + } + + /// Progress: (collected, needed). + pub fn progress(&self) -> (usize, usize) { + (self.points.len(), self.need) + } + + /// Feed exactly one second of mic input captured while a quartz watch + /// ticks once per second. `ts` is the sample counter at block start. + /// The analyzer must be configured for calibration (see + /// `Analyzer::for_calibration`). + pub fn add_block(&mut self, an: &Analyzer, samples: &[f32], ts: u64) -> CalStatus { + let sr = an.sample_rate as usize; + if samples.len() < 2 * sr { + return CalStatus::Missed; + } + if self.cal.is_some() { + return CalStatus::Done(self.cal.unwrap()); + } + let mut s = samples.to_vec(); + let n = s.len(); + // tg's process_cal runs with the noise suppressor disabled. + an.prepare_data(&mut s); + let period = match an.compute_period(&s, n) { + Some(p) => p, + None => return CalStatus::Missed, + }; + let (wf, phase) = an.compute_waveform(&s, period, n); + + // Lock check: the tick must sit near the middle of the folded window. + let wf_max = wf.iter().cloned().fold(0f32, f32::max); + let wf_max_i = wf.iter().enumerate().max_by(|a, b| a.1.total_cmp(b.1)).map(|(i, _)| i).unwrap_or(0); + if wf_max_i < sr * 4 / 10 || wf_max_i > sr * 6 / 10 { + return CalStatus::Missed; + } + // Rising-edge check between the quiet zones. + let maxa = wf[..sr / 4].iter().cloned().fold(0f32, f32::max); + let maxb = wf[sr * 3 / 4..].iter().cloned().fold(0f32, f32::max); + let max = maxa.max(maxb); + let thd = max + (wf_max - max) * 0.05; + let mut tick_i = None; + for i in sr / 4..=wf_max_i { + if wf[i] > thd { + if i > sr * 4 / 10 { + tick_i = Some(i); + } + break; + } + } + let Some(tick_i) = tick_i else { + return CalStatus::Missed; + }; + let phase_tick = ((ts + phase as u64 + tick_i as u64) as f64 / sr as f64).fract(); + + let start = *self.start_ts.get_or_insert(ts); + let time = (ts - start) as f64 / sr as f64; + if self.points.is_empty() || time > self.points.last().unwrap().0 + 0.9 { + self.points.push((time, phase_tick)); + } + + if self.points.len() >= self.need { + match Self::fit(&self.points) { + Ok(cal) => { + self.cal = Some(cal); + CalStatus::Done(cal) + } + Err(_) => CalStatus::Failed, + } + } else { + let have = self.points.len(); + CalStatus::Collecting { have, need: self.need } + } + } + + /// tg's compute_cal: unwrap the circular phases around their mean + /// direction, then least-squares fit the drift; the slope in s/d is the + /// sound card's apparent rate error. + fn fit(points: &[(f64, f64)]) -> Result { + let n = points.len(); + if n < 3 { + return Err(()); + } + let mut x = 0.0; + let mut y = 0.0; + for &(_, p) in points { + x += (p * 2.0 * std::f64::consts::PI).cos(); + y += (p * 2.0 * std::f64::consts::PI).sin(); + } + let c = (y.atan2(x) - std::f64::consts::PI) / (2.0 * std::f64::consts::PI); + let adjusted: Vec<(f64, f64)> = points + .iter() + .map(|&(t, p)| (t, (p - c).fract())) + .collect(); + let t_av = adjusted.iter().map(|&(t, _)| t).sum::() / n as f64; + let p_av = adjusted.iter().map(|&(_, p)| p).sum::() / n as f64; + let (mut xx, mut xy, mut yy) = (0.0, 0.0, 0.0); + for &(t, p) in adjusted.iter() { + let dt = t - t_av; + let dp = p - p_av; + xx += dt * dt; + xy += dt * dp; + yy += dp * dp; + } + if xx == 0.0 { + return Err(()); + } + let calibration = xy * 3600.0 * 24.0 / xx; + let delta = ((xx * yy - xy * xy) / (n as f64 - 2.0)).sqrt() / xx; + if delta * 3600.0 * 24.0 >= 0.1 { + return Err(()); + } + Ok(calibration) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::signal::SyntheticWatch; + + #[test] + fn calibration_recovers_sound_card_error() { + // A quartz watch ticking exactly once per second, as recorded by a + // sound card whose clock runs 15 s/day fast. The ticks then appear + // 15 s/day slow, so the calibration correction is -15 s/d: + // measured - calibration = 0 for a perfect source. + const SR: u32 = 44100; + let quartz = SyntheticWatch { + bph: 3600, // one tick per second + rate_sday: 15.0, + beat_error_ms: 0.0, + amplitude_deg: 250.0, + }; + let samples = quartz.generate(SR, 44.0); + let an = Analyzer::for_calibration(SR); + let mut state = CalibrationState::with_size(30); + let win = 4 * SR as usize; + for i in 0..40 { + let start = i * SR as usize; + if start + win > samples.len() { + break; + } + let st = state.add_block(&an, &samples[start..start + win], (i as u64) * SR as u64); + match st { + CalStatus::Done(cal) => { + assert!((cal - (-15.0)).abs() < 2.0, "calibration: {cal}"); + return; + } + CalStatus::Failed => panic!("calibration failed quality check"), + _ => {} + } + } + panic!("calibration never completed"); + } +} diff --git a/crates/regulator-core/src/lib.rs b/crates/regulator-core/src/lib.rs index 2dc1b01..765fba1 100644 --- a/crates/regulator-core/src/lib.rs +++ b/crates/regulator-core/src/lib.rs @@ -12,10 +12,12 @@ //! the balance amplitude from the pulse widths. pub mod analyze; +pub mod calibrate; pub mod filters; pub mod signal; pub mod stats; pub use analyze::{Analyzer, TimingResult}; +pub use calibrate::{CalStatus, CalibrationState, CAL_DATA_SIZE}; pub use signal::SyntheticWatch; pub const FILTER_CUTOFF: f64 = 3000.0; diff --git a/crates/regulator-gui/src/main.rs b/crates/regulator-gui/src/main.rs index 2f7820d..773435b 100644 --- a/crates/regulator-gui/src/main.rs +++ b/crates/regulator-gui/src/main.rs @@ -6,7 +6,7 @@ mod audio; use eframe::egui; -use regulator_core::{Analyzer, SyntheticWatch, TimingResult}; +use regulator_core::{CalStatus, CalibrationState, Analyzer, SyntheticWatch, TimingResult}; use std::sync::mpsc; use std::sync::{Arc, Mutex}; use std::time::Duration; @@ -20,6 +20,9 @@ struct Params { lift_angle: f64, noise_suppressor: bool, demo: bool, + calibrating: bool, + calibration: f64, + cal_progress: String, } impl Default for Params { @@ -29,6 +32,9 @@ impl Default for Params { lift_angle: 52.0, noise_suppressor: true, demo: true, + calibrating: false, + calibration: 0.0, + cal_progress: String::new(), } } } @@ -46,7 +52,7 @@ impl RegulatorApp { fn new(ring: Option) -> Self { let params = Arc::new(Mutex::new(Params::default())); let (tx, rx) = mpsc::channel::>(); - let p = params.clone(); + let params_arc = params.clone(); std::thread::spawn(move || { let watch = SyntheticWatch { bph: 28800, @@ -57,13 +63,54 @@ impl RegulatorApp { let demo_samples = watch.generate(SAMPLE_RATE, 120.0); let block = (BLOCK_SECONDS * SAMPLE_RATE as f64) as usize; let mut start = 0usize; + let mut ts: u64 = 0; + let mut last_len = 0usize; + let mut cal_state = CalibrationState::new(); + let mut cal_cooldown = 0u32; loop { - let p = p.lock().unwrap_or_else(|e| e.into_inner()).clone(); + let mut p = params_arc.lock().unwrap_or_else(|e| e.into_inner()); + if p.calibrating { + if let Some(ring) = &ring { + let buf = ring.lock().unwrap_or_else(|e| e.into_inner()); + ts += buf.len().saturating_sub(last_len) as u64; + last_len = buf.len(); + if buf.len() >= block && cal_cooldown == 0 { + let cal_an = Analyzer::for_calibration(SAMPLE_RATE); + let window_start_ts = ts.saturating_sub(buf.len() as u64); + match cal_state.add_block(&cal_an, &buf[buf.len() - block..], window_start_ts) { + CalStatus::Done(cal) => { + p.calibration = cal; + p.calibrating = false; + p.cal_progress = format!("{cal:+.1} s/d"); + } + CalStatus::Failed => { + p.calibrating = false; + p.cal_progress = "failed".into(); + } + CalStatus::Collecting { have, need } => { + p.cal_progress = format!("{have}/{need} s"); + } + CalStatus::Missed => {} + } + cal_cooldown = 5; + } + } + if cal_cooldown > 0 { + cal_cooldown -= 1; + } + drop(p); + let _ = tx.send(None::); + std::thread::sleep(Duration::from_millis(200)); + continue; + } + drop(p); + let p2 = params_arc.lock().unwrap_or_else(|e| e.into_inner()).clone(); let mut analyzer = Analyzer::new(SAMPLE_RATE); - analyzer.bph = p.bph; - analyzer.lift_angle = p.lift_angle; - analyzer.noise_suppressor = p.noise_suppressor; - let res = if p.demo { + analyzer.bph = p2.bph; + analyzer.lift_angle = p2.lift_angle; + analyzer.noise_suppressor = p2.noise_suppressor; + analyzer.calibration = p2.calibration; + let res = if p2.demo { let end = (start + block).min(demo_samples.len()); let r = analyzer.analyze(&demo_samples[start..end]); if end == demo_samples.len() { @@ -130,6 +177,21 @@ impl eframe::App for RegulatorApp { } ui.checkbox(&mut p.demo, "demo mode"); ui.separator(); + if p.calibrating { + ui.label(format!("calibrating: {} (use a quartz watch, 1 tick/s, ~15 min)", p.cal_progress)); + if ui.button("stop calibration").clicked() { + p.calibrating = false; + } + } else { + if ui.button("calibrate (quartz, ~15 min)").clicked() { + p.calibrating = !p.demo; // calibration needs the mic + p.cal_progress.clear(); + } + if p.calibration != 0.0 { + ui.label(format!("calibration: {:+.1} s/d", p.calibration)); + } + } + ui.separator(); ui.small("regulator — GPLv2\na fork of tg"); }); diff --git a/crates/regulator-tui/src/main.rs b/crates/regulator-tui/src/main.rs index 10199ea..c7919f0 100644 --- a/crates/regulator-tui/src/main.rs +++ b/crates/regulator-tui/src/main.rs @@ -12,7 +12,7 @@ use crossterm::terminal::{ }; use ratatui::backend::CrosstermBackend; use ratatui::Terminal; -use regulator_core::{Analyzer, SyntheticWatch, TimingResult}; +use regulator_core::{CalStatus, CalibrationState, Analyzer, SyntheticWatch, TimingResult}; use std::sync::mpsc; use std::sync::{Arc, Mutex}; use std::time::{Duration, Instant}; @@ -51,6 +51,7 @@ fn build_analyzer(settings: &Settings) -> Analyzer { an.bph = settings.bph; an.lift_angle = settings.lift_angle; an.noise_suppressor = settings.noise_suppressor; + an.calibration = settings.calibration; an } @@ -92,16 +93,53 @@ fn spawn_live_worker( std::thread::spawn(move || { let block = (BLOCK_SECONDS * SAMPLE_RATE as f64) as usize; let mut buf: Vec = Vec::with_capacity(block * 2); + let mut ts: u64 = 0; + let mut cal_state = CalibrationState::new(); + let mut cal_cooldown = 0u32; loop { + let mut fresh = 0usize; while let Ok(s) = rx.try_recv() { buf.push(s); + fresh += 1; if buf.len() > block * 2 { buf.drain(..block); } } - if buf.len() >= block { - let res = analyze_block(&buf[buf.len() - block..], &settings.lock().unwrap_or_else(|e| e.into_inner()).clone()); - let _ = tx.send(res); + ts += fresh as u64; + let mut s = settings.lock().unwrap_or_else(|e| e.into_inner()); + if s.calibrating { + if buf.len() >= block && cal_cooldown == 0 { + let cal_an = Analyzer::for_calibration(SAMPLE_RATE); + let window_start_ts = ts.saturating_sub(buf.len() as u64); + match cal_state.add_block(&cal_an, &buf[buf.len() - block..], window_start_ts) { + CalStatus::Done(cal) => { + s.calibration = cal; + s.calibrating = false; + s.cal_progress = format!("{cal:+.1} s/d"); + } + CalStatus::Failed => { + s.calibrating = false; + s.cal_progress = "failed".into(); + } + CalStatus::Collecting { have, need } => { + s.cal_progress = format!("{have}/{need} s"); + } + CalStatus::Missed => {} + } + cal_cooldown = 10; // feed ~1 window per second + } + if cal_cooldown > 0 { + cal_cooldown -= 1; + } + drop(s); + // Keep the last measurement on screen during calibration. + } else { + let snapshot = s.clone(); + drop(s); + if buf.len() >= block { + let res = analyze_block(&buf[buf.len() - block..], &snapshot); + let _ = tx.send(res); + } } std::thread::sleep(Duration::from_millis(100)); } @@ -139,6 +177,7 @@ fn run_tui( KeyCode::Char('+') | KeyCode::Char('=') => s.lift_angle += 1.0, KeyCode::Char('-') => s.lift_angle -= 1.0, KeyCode::Char('n') => s.noise_suppressor = !s.noise_suppressor, + KeyCode::Char('c') => s.calibrating = !s.calibrating, _ => {} } } diff --git a/crates/regulator-tui/src/ui.rs b/crates/regulator-tui/src/ui.rs index af46371..2b044e8 100644 --- a/crates/regulator-tui/src/ui.rs +++ b/crates/regulator-tui/src/ui.rs @@ -14,6 +14,9 @@ pub struct Settings { pub lift_angle: f64, pub noise_suppressor: bool, pub source: String, + pub calibrating: bool, + pub calibration: f64, + pub cal_progress: String, } impl Default for Settings { @@ -23,6 +26,9 @@ impl Default for Settings { lift_angle: 52.0, noise_suppressor: true, source: String::new(), + calibrating: false, + calibration: 0.0, + cal_progress: String::new(), } } } @@ -146,6 +152,13 @@ fn draw_waveform(f: &mut ratatui::Frame, area: Rect, res: &Option) fn draw_status(f: &mut ratatui::Frame, area: Rect, s: &Settings) { let bph = if s.bph == 0 { "auto".into() } else { s.bph.to_string() }; + let cal = if s.calibrating { + format!(" calibrating {}…", s.cal_progress) + } else if s.calibration != 0.0 { + format!(" cal:{:+.1} s/d", s.calibration) + } else { + String::new() + }; let line = Line::from(vec![ Span::styled(format!(" {} ", s.source), Style::default().bg(Color::DarkGray)), Span::raw(format!( @@ -154,7 +167,7 @@ fn draw_status(f: &mut ratatui::Frame, area: Rect, s: &Settings) { if s.noise_suppressor { "on" } else { "off" } )), Span::styled( - "←→ bph +/- lift n noise q quit", + "←→ bph +/- lift n noise c calibrate q quit", Style::default().fg(Color::DarkGray), ), ]); From 4afa6f0cd42ffe3380c99d6c955b39417652acec Mon Sep 17 00:00:00 2001 From: borosf Date: Tue, 17 Nov 2026 20:09:42 +0000 Subject: [PATCH 08/20] analyze_wav: decode WAV/MP3/M4A via symphonia; mkwav example for round-trip tests Co-authored-by: borosf --- Cargo.lock | 148 ++++++++++++++++++ crates/regulator-core/Cargo.toml | 1 + crates/regulator-core/examples/analyze_wav.rs | 75 +++++++-- crates/regulator-core/examples/mkwav.rs | 8 + 4 files changed, 221 insertions(+), 11 deletions(-) create mode 100644 crates/regulator-core/examples/mkwav.rs diff --git a/Cargo.lock b/Cargo.lock index 7267273..902b3bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -793,6 +793,12 @@ dependencies = [ "libc", ] +[[package]] +name = "core_detect" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48" + [[package]] name = "coreaudio-rs" version = "0.11.3" @@ -1122,6 +1128,20 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "encoding_rs" +version = "0.8.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89253175e704ab869b04f9db224d38630e0211a53841a79181deae0889e169f5" +dependencies = [ + "cfg-if", + "core_detect", + "multiversion_no_op", + "rustversion", + "scopeguard", + "simdutf8", +] + [[package]] name = "endi" version = "1.1.1" @@ -1215,6 +1235,12 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "extended" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af9673d8203fcb076b19dfd17e38b3d4ae9f44959416ea532ce72415a6020365" + [[package]] name = "fastrand" version = "2.5.0" @@ -1886,6 +1912,12 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" +[[package]] +name = "lazy_static" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb" + [[package]] name = "libc" version = "0.2.191" @@ -2073,6 +2105,12 @@ dependencies = [ "pxfm", ] +[[package]] +name = "multiversion_no_op" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "743fb55ba31b18fb1ecef6bdc9aa2743314978ac084044301a7eee33fb99a20d" + [[package]] name = "naga" version = "27.0.3" @@ -2893,6 +2931,7 @@ version = "0.1.0" dependencies = [ "hound", "rustfft", + "symphonia", ] [[package]] @@ -3295,6 +3334,115 @@ dependencies = [ "syn 2.0.119", ] +[[package]] +name = "symphonia" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5773a4c030a19d9bfaa090f49746ff35c75dfddfa700df7a5939d5e076a57039" +dependencies = [ + "lazy_static", + "symphonia-bundle-mp3", + "symphonia-codec-aac", + "symphonia-codec-pcm", + "symphonia-core", + "symphonia-format-isomp4", + "symphonia-format-riff", + "symphonia-metadata", +] + +[[package]] +name = "symphonia-bundle-mp3" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4872dd6bb56bf5eac799e3e957aa1981086c3e613b27e0ac23b176054f7c57ed" +dependencies = [ + "lazy_static", + "log", + "symphonia-core", + "symphonia-metadata", +] + +[[package]] +name = "symphonia-codec-aac" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c263845aa86881416849c1729a54c7f55164f8b96111dba59de46849e73a790" +dependencies = [ + "lazy_static", + "log", + "symphonia-core", +] + +[[package]] +name = "symphonia-codec-pcm" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e89d716c01541ad3ebe7c91ce4c8d38a7cf266a3f7b2f090b108fb0cb031d95" +dependencies = [ + "log", + "symphonia-core", +] + +[[package]] +name = "symphonia-core" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea00cc4f79b7f6bb7ff87eddc065a1066f3a43fe1875979056672c9ef948c2af" +dependencies = [ + "arrayvec", + "bitflags 1.3.2", + "bytemuck", + "lazy_static", + "log", +] + +[[package]] +name = "symphonia-format-isomp4" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "243739585d11f81daf8dac8d9f3d18cc7898f6c09a259675fc364b382c30e0a5" +dependencies = [ + "encoding_rs", + "log", + "symphonia-core", + "symphonia-metadata", + "symphonia-utils-xiph", +] + +[[package]] +name = "symphonia-format-riff" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2d7c3df0e7d94efb68401d81906eae73c02b40d5ec1a141962c592d0f11a96f" +dependencies = [ + "extended", + "log", + "symphonia-core", + "symphonia-metadata", +] + +[[package]] +name = "symphonia-metadata" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36306ff42b9ffe6e5afc99d49e121e0bd62fe79b9db7b9681d48e29fa19e6b16" +dependencies = [ + "encoding_rs", + "lazy_static", + "log", + "symphonia-core", +] + +[[package]] +name = "symphonia-utils-xiph" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee27c85ab799a338446b68eec77abf42e1a6f1bb490656e121c6e27bfbab9f16" +dependencies = [ + "symphonia-core", + "symphonia-metadata", +] + [[package]] name = "syn" version = "2.0.119" diff --git a/crates/regulator-core/Cargo.toml b/crates/regulator-core/Cargo.toml index d48fb2a..11541c0 100644 --- a/crates/regulator-core/Cargo.toml +++ b/crates/regulator-core/Cargo.toml @@ -11,3 +11,4 @@ rustfft = { workspace = true } [dev-dependencies] hound = "3" +symphonia = { version = "0.5", default-features = false, features = ["mp3", "wav", "isomp4", "aac", "pcm"] } diff --git a/crates/regulator-core/examples/analyze_wav.rs b/crates/regulator-core/examples/analyze_wav.rs index 3678ad8..210f5cc 100644 --- a/crates/regulator-core/examples/analyze_wav.rs +++ b/crates/regulator-core/examples/analyze_wav.rs @@ -1,23 +1,19 @@ // SPDX-License-Identifier: GPL-2.0 -//! Analyze a WAV recording of a watch and print results per block. -//! Usage: cargo run -p regulator-core --example analyze_wav -- file.wav [bph] +//! Analyze a recording of a watch (WAV, MP3, M4A/AAC) and print results +//! per block. +//! Usage: cargo run -p regulator-core --example analyze_wav -- file.mp3 [bph] [lift] use regulator_core::Analyzer; fn main() { let args: Vec = std::env::args().collect(); if args.len() < 2 { - eprintln!("usage: analyze_wav [bph] [lift_angle]"); + eprintln!("usage: analyze_wav [bph] [lift_angle]"); std::process::exit(1); } let bph: u32 = args.get(2).and_then(|s| s.parse().ok()).unwrap_or(0); let lift: f64 = args.get(3).and_then(|s| s.parse().ok()).unwrap_or(52.0); - let mut reader = hound::WavReader::open(&args[1]).expect("cannot open wav"); - let sr = reader.spec().sample_rate; - let samples: Vec = reader - .samples::() - .map(|s| s.map(|v| v as f32 / i16::MAX as f32).unwrap_or(0.0)) - .collect(); + let (sr, samples) = load_audio(&args[1]); println!( "file: {} rate: {sr} samples: {} ({:.1} s) bph: {bph} lift: {lift}", args[1], @@ -37,13 +33,70 @@ fn main() { Some(r) => println!( "t={t:6.1}s rate={:+8.1} s/d amp={:>5} be={:+6.2} ms period={:.1} bph={}", r.rate_sday.unwrap_or(f64::NAN), - r.amplitude_deg.map(|a| format!("{a:.0}")).unwrap_or("---".into()), + r.amplitude_deg + .map(|a| format!("{a:.0}")) + .unwrap_or("---".into()), r.beat_error_ms.unwrap_or(f64::NAN), r.period, r.bph, ), - None => println!("t={t:6.1}s no signal",), + None => println!("t={t:6.1}s no signal"), } t = (i + 1) as f64 * 4.0; } } + +/// Load any supported audio file as mono f32 samples via symphonia. +fn load_audio(path: &str) -> (u32, Vec) { + let file = std::fs::File::open(path).expect("cannot open file"); + let mss = symphonia::core::io::MediaSourceStream::new( + Box::new(file), + Default::default(), + ); + let hint = symphonia::core::probe::Hint::new(); + let probed = symphonia::default::get_probe() + .format(&hint, mss, &Default::default(), &Default::default()) + .expect("unsupported format"); + let mut format = probed.format; + let track = format + .tracks() + .first() + .expect("no track") + .clone(); + let sr = track.codec_params.sample_rate.expect("no sample rate"); + let channels = track + .codec_params + .channels + .map(|c| c.count()) + .unwrap_or(1); + let mut decoder = symphonia::default::get_codecs() + .make(&track.codec_params, &Default::default()) + .expect("unsupported codec"); + + let mut samples = Vec::new(); + loop { + match format.next_packet() { + Ok(packet) => { + if packet.track_id() != track.id { + continue; + } + match decoder.decode(&packet) { + Ok(audio) => { + let mut sb = symphonia::core::audio::SampleBuffer::::new( + audio.frames() as u64, + *audio.spec(), + ); + sb.copy_interleaved_ref(audio); + for frame in sb.samples().chunks(channels) { + samples.push(frame.iter().sum::() / channels as f32); + } + } + Err(symphonia::core::errors::Error::DecodeError(_)) => continue, + Err(_) => break, + } + } + Err(_) => break, + } + } + (sr, samples) +} diff --git a/crates/regulator-core/examples/mkwav.rs b/crates/regulator-core/examples/mkwav.rs new file mode 100644 index 0000000..4f63232 --- /dev/null +++ b/crates/regulator-core/examples/mkwav.rs @@ -0,0 +1,8 @@ +fn main() { + use regulator_core::SyntheticWatch; + let w = SyntheticWatch { bph: 18000, rate_sday: 33.0, beat_error_ms: 1.8, amplitude_deg: 272.0 }; + let samples = w.generate(44100, 12.0); + let spec = hound::WavSpec { channels: 1, sample_rate: 44100, bits_per_sample: 16, sample_format: hound::SampleFormat::Int }; + let mut w = hound::WavWriter::create("/tmp/watch.wav", spec).unwrap(); + for s in samples { w.write_sample((s.clamp(-1.0, 1.0) * i16::MAX as f32) as i16).unwrap(); } +} From a90923b2529ba3bc78889ce7961c3ece05219e86 Mon Sep 17 00:00:00 2001 From: borosf Date: Tue, 17 Nov 2026 20:17:50 +0000 Subject: [PATCH 09/20] Fix real-watch detection: port tg's high-pass filter and amplitude algorithm Debugged against a real 18000 bph watch recording (previously: no signal, +5000 s/d garbage): - tg's default filter chain high-passes at FILTER_CUTOFF (3000 Hz) before analysis; without it, mains hum dominated the autocorrelation and the period detector failed on most blocks. Ported the biquad high-pass. - Restored tg's exact amplitude algorithm (escalating-threshold scan for the pre-impulse build-up): measures 236-238 deg on the real recording where tg shows 272 deg. The earlier 20%-span variant was mistuned. - Synthetic generator now models the escapement build-up (pre-hump) so the amplitude path works in demo mode; quartz mode keeps sharp clicks for calibration. Results on the real recording: rate +40..+52 s/d (tg: +33), amplitude 237 deg (tg: 272), beat error ~0.1 ms, bph auto-detected 18000. Co-authored-by: borosf --- crates/regulator-core/examples/debug.rs | 1 + crates/regulator-core/examples/mkwav.rs | 2 +- crates/regulator-core/src/analyze.rs | 108 +++++++++++++++--------- crates/regulator-core/src/calibrate.rs | 1 + crates/regulator-core/src/filters.rs | 16 ++++ crates/regulator-core/src/signal.rs | 32 +++++-- crates/regulator-gui/src/main.rs | 1 + crates/regulator-tui/src/main.rs | 1 + 8 files changed, 115 insertions(+), 47 deletions(-) diff --git a/crates/regulator-core/examples/debug.rs b/crates/regulator-core/examples/debug.rs index 6d77c69..a874719 100644 --- a/crates/regulator-core/examples/debug.rs +++ b/crates/regulator-core/examples/debug.rs @@ -9,6 +9,7 @@ fn main() { rate_sday: 12.0, beat_error_ms: 0.0, amplitude_deg: 270.0, + quartz: false, }; let samples = watch.generate(sr, 4.0); let an = Analyzer::new(sr); diff --git a/crates/regulator-core/examples/mkwav.rs b/crates/regulator-core/examples/mkwav.rs index 4f63232..b4ee559 100644 --- a/crates/regulator-core/examples/mkwav.rs +++ b/crates/regulator-core/examples/mkwav.rs @@ -1,6 +1,6 @@ fn main() { use regulator_core::SyntheticWatch; - let w = SyntheticWatch { bph: 18000, rate_sday: 33.0, beat_error_ms: 1.8, amplitude_deg: 272.0 }; + let w = SyntheticWatch { bph: 18000, rate_sday: 33.0, beat_error_ms: 1.8, amplitude_deg: 272.0, quartz: false }; let samples = w.generate(44100, 12.0); let spec = hound::WavSpec { channels: 1, sample_rate: 44100, bits_per_sample: 16, sample_format: hound::SampleFormat::Int }; let mut w = hound::WavWriter::create("/tmp/watch.wav", spec).unwrap(); diff --git a/crates/regulator-core/src/analyze.rs b/crates/regulator-core/src/analyze.rs index a16c1e1..a23b028 100644 --- a/crates/regulator-core/src/analyze.rs +++ b/crates/regulator-core/src/analyze.rs @@ -84,6 +84,7 @@ pub struct Analyzer { /// from the measured rate. pub calibration: f64, lpf: Biquad, + hpf: Biquad, fft: RefCell, last_sigma: Cell, } @@ -99,6 +100,7 @@ impl Analyzer { noise_suppressor: true, calibration: 0.0, lpf: Biquad::low_pass(crate::FILTER_CUTOFF / sample_rate as f64), + hpf: Biquad::high_pass(crate::FILTER_CUTOFF / sample_rate as f64), fft: RefCell::new(FftCache::new()), last_sigma: Cell::new(0.0), } @@ -163,6 +165,7 @@ impl Analyzer { pub(crate) fn prepare_data(&self, s: &mut Vec) { let n = s.len(); let sr = self.sample_rate as usize; + self.hpf.run(s); if self.noise_suppressor { Self::noise_suppressor(s, sr); } @@ -502,11 +505,12 @@ impl Analyzer { Some((Some(be * 1000.0 / sr as f64), tic, toc)) } - /// Amplitude from the tic/toc pulse widths. tg measures the distance - /// between an escalating threshold crossing and the smoothed peak, which - /// is fragile; regulator instead measures the duration the smoothed - /// pulse stays above 20% of its peak, which is the impulse duration the - /// amplitude formula wants: A/la = 0.5 / sin(pi * pulse / period). + /// Amplitude from the tic/toc pulse widths, tg's algorithm: scan the + /// eighth before each tick for a threshold crossing, follow the + /// increasing run to its local maximum, and take the distance from + /// that local max to the tick as the pulse width. Real escapement + /// sounds have a build-up before the main impulse, so this distance + /// tracks the impulse duration. A/la = 0.5 / sin(pi * pulse / period). fn compute_amplitude(&self, wf: &[f32], period: f64, tic: usize, toc: usize) -> Option { let sr = self.sample_rate as usize; let wf_size = wf.len(); @@ -518,48 +522,72 @@ impl Analyzer { return None; } let wlen = smooth.len(); - let max_walk = (period / 8.0) as usize; - - let mut amps = [0.0f64; 2]; - for (k, &t) in [tic, toc].iter().enumerate() { - if t >= wlen { - return None; - } - let peak = smooth[t]; - if peak <= 0.0 { - return None; - } - let th = 0.2 * peak; - let mut lo = t; - for _ in 0..max_walk { - if smooth[(lo + wlen - 1) % wlen] <= th { - break; + let eighth = (period / 8.0) as usize; + if eighth == 0 || tic >= wlen || toc >= wlen { + return None; + } + let glob_max = smooth.iter().cloned().fold(0f32, f32::max); + if glob_max <= 0.0 { + return None; + } + // Noise level in the eighths following each tick. + let mut quiet = 0.0f32; + for &t in &[tic, toc] { + let mut j = ((t as f64 + period / 8.0) % wlen as f64) as usize; + for _ in 0..eighth { + if smooth[j] > quiet { + quiet = smooth[j]; } - lo = (lo + wlen - 1) % wlen; + j = (j + 1) % wlen; } - let mut hi = t; - for _ in 0..max_walk { - if smooth[hi % wlen] <= th { + } + let mut threshold = (0.01 * glob_max).max(1.4 * quiet); + while threshold < 0.2 * glob_max { + let mut pulses = [0.0f64; 2]; + let mut ok = true; + for (k, &t) in [toc, tic].iter().enumerate() { + let mut j = ((t as f64 + 7.0 * period / 8.0) % wlen as f64) as usize; + let mut i = 0usize; + while i < eighth { + if smooth[j] > threshold { + break; + } + i += 1; + j = (j + 1) % wlen; + } + let mut max = 0.0f32; + while i < eighth { + let x = smooth[j]; + if x > max { + max = x; + } else { + break; + } + i += 1; + j = (j + 1) % wlen; + } + if i < eighth { + pulses[k] = period / 8.0 - i as f64 - 1.0; + } else { + ok = false; break; } - hi = (hi + 1) % wlen; } - let span = (hi + wlen - lo) % wlen; - if span == 0 || span >= max_walk { - return None; + if ok { + let tic_amp_abs = 0.5 / (std::f64::consts::PI * pulses[0] / period).sin(); + let toc_amp_abs = 0.5 / (std::f64::consts::PI * pulses[1] / period).sin(); + let tic_amp = self.lift_angle * tic_amp_abs; + let toc_amp = self.lift_angle * toc_amp_abs; + if (135.0..360.0).contains(&tic_amp) + && (135.0..360.0).contains(&toc_amp) + && (tic_amp - toc_amp).abs() < 60.0 + { + return Some(self.lift_angle * (tic_amp_abs + toc_amp_abs) / 2.0); + } } - amps[k] = 0.5 / (std::f64::consts::PI * span as f64 / period).sin(); - } - let tic_amp = self.lift_angle * amps[0]; - let toc_amp = self.lift_angle * amps[1]; - if (135.0..360.0).contains(&tic_amp) - && (135.0..360.0).contains(&toc_amp) - && (tic_amp - toc_amp).abs() < 60.0 - { - Some(self.lift_angle * (amps[0] + amps[1]) / 2.0) - } else { - None + threshold *= 1.4; } + None } /// Exponential-decay peak smoother, ported from tg's smooth(). diff --git a/crates/regulator-core/src/calibrate.rs b/crates/regulator-core/src/calibrate.rs index e6984d5..962245d 100644 --- a/crates/regulator-core/src/calibrate.rs +++ b/crates/regulator-core/src/calibrate.rs @@ -186,6 +186,7 @@ mod tests { rate_sday: 15.0, beat_error_ms: 0.0, amplitude_deg: 250.0, + quartz: true, }; let samples = quartz.generate(SR, 44.0); let an = Analyzer::for_calibration(SR); diff --git a/crates/regulator-core/src/filters.rs b/crates/regulator-core/src/filters.rs index 81b8594..4565edf 100644 --- a/crates/regulator-core/src/filters.rs +++ b/crates/regulator-core/src/filters.rs @@ -25,6 +25,22 @@ impl Biquad { } } + /// High-pass filter (Q = 1/sqrt(2)); `freq` normalized to the sample + /// rate. tg's default chain high-passes at FILTER_CUTOFF before + /// analysis, which removes mains hum and rumble. + pub fn high_pass(freq: f64) -> Self { + let k = (std::f64::consts::PI * freq).tan(); + let norm = 1.0 / (1.0 + k * std::f64::consts::SQRT_2 + k * k); + let a0 = norm; + Biquad { + a0, + a1: -2.0 * a0, + a2: a0, + b1: 2.0 * (k * k - 1.0) * norm, + b2: (1.0 - k * std::f64::consts::SQRT_2 + k * k) * norm, + } + } + /// In-place Direct Form 1 filtering, matching tg's run_filter(). pub fn run(&self, buff: &mut [f32]) { let mut z1 = 0.0; diff --git a/crates/regulator-core/src/signal.rs b/crates/regulator-core/src/signal.rs index b370b75..0a8e937 100644 --- a/crates/regulator-core/src/signal.rs +++ b/crates/regulator-core/src/signal.rs @@ -13,6 +13,9 @@ pub struct SyntheticWatch { pub beat_error_ms: f64, /// Balance amplitude in degrees (affects pulse width). pub amplitude_deg: f64, + /// Quartz mode: a sharp click once per second (no escapement build-up), + /// for sound-card calibration against a quartz watch. + pub quartz: bool, } impl SyntheticWatch { @@ -49,13 +52,26 @@ impl SyntheticWatch { / std::f64::consts::PI * sr) as usize; let width = width.min(burst_len); - for i in 0..width { + // Real escapement sounds build up before the main impulse: + // a rising pre-hump about one pulse width before the tick, + // then the sharp attack at the tick itself. tg's amplitude + // scan measures the distance from the pre-hump's local + // maximum to the tick, which tracks `width`. + if !self.quartz { + for i in 0..width { + let tt = i as f64 / sr; + let bump = (std::f64::consts::PI * i as f64 / width as f64).sin(); + let env = bump * bump * 0.35; + let carrier = (2.0 * std::f64::consts::PI * 3500.0 * tt).sin(); + let idx = base as isize + i as isize - 3 * width as isize / 2; + if idx >= 0 && (idx as usize) < n { + out[idx as usize] += (env * carrier) as f32; + } + } + } + for i in 0..width / 3 { let tt = i as f64 / sr; - // Sharp attack at the unlock, exponential decay: like a - // real impulse, the sound starts at the tick and rings - // down. The analyzer measures the duration above 20% of - // the peak, which tracks `width`. - let env = (-1.6 * i as f64 / width as f64).exp(); + let env = (-4.0 * i as f64 / (width / 3) as f64).exp(); let carrier = (2.0 * std::f64::consts::PI * 3500.0 * tt).sin(); let idx = base as isize + i as isize; if idx >= 0 && (idx as usize) < n { @@ -96,6 +112,7 @@ mod tests { rate_sday: 12.0, beat_error_ms: 0.4, amplitude_deg: 270.0, + quartz: false, }; let samples = watch.generate(SR, 4.0); let mut an = Analyzer::new(SR); @@ -111,6 +128,7 @@ mod tests { rate_sday: -5.0, beat_error_ms: 0.0, amplitude_deg: 250.0, + quartz: false, }; let samples = watch.generate(SR, 6.0); let an = Analyzer::new(SR); @@ -129,6 +147,7 @@ mod tests { rate_sday: 0.0, beat_error_ms: 1.2, amplitude_deg: 260.0, + quartz: false, }; let samples = watch.generate(SR, 4.0); let mut an = Analyzer::new(SR); @@ -148,6 +167,7 @@ mod tests { rate_sday: 0.0, beat_error_ms: 0.0, amplitude_deg: 270.0, + quartz: false, }; let samples = watch.generate(SR, 4.0); let mut an = Analyzer::new(SR); diff --git a/crates/regulator-gui/src/main.rs b/crates/regulator-gui/src/main.rs index 773435b..702af27 100644 --- a/crates/regulator-gui/src/main.rs +++ b/crates/regulator-gui/src/main.rs @@ -59,6 +59,7 @@ impl RegulatorApp { rate_sday: 9.0, beat_error_ms: 0.6, amplitude_deg: 275.0, + quartz: false, }; let demo_samples = watch.generate(SAMPLE_RATE, 120.0); let block = (BLOCK_SECONDS * SAMPLE_RATE as f64) as usize; diff --git a/crates/regulator-tui/src/main.rs b/crates/regulator-tui/src/main.rs index c7919f0..597f002 100644 --- a/crates/regulator-tui/src/main.rs +++ b/crates/regulator-tui/src/main.rs @@ -66,6 +66,7 @@ fn spawn_demo_worker(tx: mpsc::Sender>, settings: Arc Date: Tue, 17 Nov 2026 20:21:40 +0000 Subject: [PATCH 10/20] Tick-event trace (snowflake display) and early-exit calibration - TimingResult now carries located tick events (fractional sample positions, tic/toc flag), extrapolated from the folded waveform peaks through the block at the detected period - GUI: live Trace panel under the waveform - each tick plotted at its phase error over the last 60 s; rate error drifts as diagonal bands, beat error splits into tic/toc bands, noise is scatter - Calibration refits on every new one-second sample once 60 points are collected and stops as soon as the confidence interval is under 0.1 s/d, instead of always waiting for tg's full 900 s Co-authored-by: borosf --- crates/regulator-core/examples/analyze_wav.rs | 3 +- crates/regulator-core/src/analyze.rs | 32 ++++- crates/regulator-core/src/calibrate.rs | 25 ++-- crates/regulator-gui/src/main.rs | 114 ++++++++++++++++-- 4 files changed, 148 insertions(+), 26 deletions(-) diff --git a/crates/regulator-core/examples/analyze_wav.rs b/crates/regulator-core/examples/analyze_wav.rs index 210f5cc..15364e5 100644 --- a/crates/regulator-core/examples/analyze_wav.rs +++ b/crates/regulator-core/examples/analyze_wav.rs @@ -31,7 +31,7 @@ fn main() { } match analyzer.analyze(chunk) { Some(r) => println!( - "t={t:6.1}s rate={:+8.1} s/d amp={:>5} be={:+6.2} ms period={:.1} bph={}", + "t={t:6.1}s rate={:+8.1} s/d amp={:>5} be={:+6.2} ms period={:.1} bph={} events={}", r.rate_sday.unwrap_or(f64::NAN), r.amplitude_deg .map(|a| format!("{a:.0}")) @@ -39,6 +39,7 @@ fn main() { r.beat_error_ms.unwrap_or(f64::NAN), r.period, r.bph, + r.events.len(), ), None => println!("t={t:6.1}s no signal"), } diff --git a/crates/regulator-core/src/analyze.rs b/crates/regulator-core/src/analyze.rs index a23b028..58c232e 100644 --- a/crates/regulator-core/src/analyze.rs +++ b/crates/regulator-core/src/analyze.rs @@ -30,6 +30,9 @@ pub struct TimingResult { pub bph: u32, /// Position of the tic peak in the folded waveform, if found. pub tic: Option, + /// Located tick events in this block: (sample position, is_tic). + /// Sample positions are fractional and relative to the block start. + pub events: Vec<(f64, bool)>, } struct FftCache { @@ -120,7 +123,7 @@ impl Analyzer { self.prepare_data(&mut s); let period = self.compute_period(&s, n)?; - let (waveform, _) = self.compute_waveform(&s, period, n); + let (waveform, _, phase_shift) = self.compute_waveform(&s, period, n); let (beat_error_ms, tic, toc) = match self.compute_beat_error(&waveform, period) { Some((be, tic, toc)) => (be, Some(tic), Some(toc)), None => (None, None, None), @@ -131,6 +134,28 @@ impl Analyzer { _ => None, }; + // Locate individual tick events by extrapolating the tic/toc peaks + // through the block at the detected period (a light-weight version + // of tg's locate_events, which cross-correlates a template). + let mut events = Vec::new(); + if let (Some(tic), Some(toc)) = (tic, toc) { + let wf_size = waveform.len().max(1); + let tic0 = (tic + phase_shift) as f64; + let toc0 = (toc + phase_shift) as f64; + let cycles = (n as f64 / period).ceil() as usize + 1; + for k in 0..cycles { + let t = tic0 + k as f64 * period; + if t >= 0.0 && t < n as f64 { + events.push((t, true)); + } + let t = toc0 + k as f64 * period; + if t >= 0.0 && t < n as f64 { + events.push((t, false)); + } + } + let _ = wf_size; + } + let detected_bph = 2.0 * 3600.0 * sr as f64 / period; let bph = if self.bph != 0 { self.bph as f64 @@ -149,6 +174,7 @@ impl Analyzer { waveform, bph: bph as u32, tic: tic_idx, + events, }) } @@ -412,7 +438,7 @@ impl Analyzer { /// Fold the rectified signal at `period` and average into a one-period /// waveform, ported from tg's compute_phase()/compute_waveform(). - pub(crate) fn compute_waveform(&self, s: &[f32], period: f64, n: usize) -> (Vec, f64) { + pub(crate) fn compute_waveform(&self, s: &[f32], period: f64, n: usize) -> (Vec, f64, usize) { let count = period as usize; let mut wf = vec![0f64; count]; let mut j = 0usize; @@ -466,7 +492,7 @@ impl Analyzer { for v in wf2.iter_mut() { *v -= nl; } - (wf2, phase) + (wf2, phase, phase_shift) } /// Beat error: distance between the tic and toc peaks in the folded diff --git a/crates/regulator-core/src/calibrate.rs b/crates/regulator-core/src/calibrate.rs index 962245d..8b3de56 100644 --- a/crates/regulator-core/src/calibrate.rs +++ b/crates/regulator-core/src/calibrate.rs @@ -81,7 +81,7 @@ impl CalibrationState { Some(p) => p, None => return CalStatus::Missed, }; - let (wf, phase) = an.compute_waveform(&s, period, n); + let (wf, phase, _) = an.compute_waveform(&s, period, n); // Lock check: the tick must sit near the middle of the folded window. let wf_max = wf.iter().cloned().fold(0f32, f32::max); @@ -114,18 +114,21 @@ impl CalibrationState { self.points.push((time, phase_tick)); } - if self.points.len() >= self.need { - match Self::fit(&self.points) { - Ok(cal) => { - self.cal = Some(cal); - CalStatus::Done(cal) - } - Err(_) => CalStatus::Failed, + // Try to finish early: once enough points have been collected, + // refit on every new sample and stop as soon as the confidence + // interval is tight enough (tg always waits for all 900 points). + let min_points = self.need.min(60); + if self.points.len() >= min_points { + if let Ok(cal) = Self::fit(&self.points) { + self.cal = Some(cal); + return CalStatus::Done(cal); + } + if self.points.len() >= self.need { + return CalStatus::Failed; } - } else { - let have = self.points.len(); - CalStatus::Collecting { have, need: self.need } } + let have = self.points.len(); + CalStatus::Collecting { have, need: self.need } } /// tg's compute_cal: unwrap the circular phases around their mean diff --git a/crates/regulator-gui/src/main.rs b/crates/regulator-gui/src/main.rs index 702af27..6b2b71d 100644 --- a/crates/regulator-gui/src/main.rs +++ b/crates/regulator-gui/src/main.rs @@ -11,6 +11,22 @@ use std::sync::mpsc; use std::sync::{Arc, Mutex}; use std::time::Duration; +/// One located tick event on the live trace. +#[derive(Clone, Copy)] +struct TracePoint { + /// Absolute time in seconds. + t: f64, + /// Phase error against the nominal beat grid, in milliseconds. + phase_ms: f64, + tic: bool, +} + +/// What the worker sends to the UI each iteration. +struct Feed { + result: Option, + trace: Vec, +} + const SAMPLE_RATE: u32 = 44100; const BLOCK_SECONDS: f64 = 4.0; @@ -44,14 +60,15 @@ type Ring = Arc>>; struct RegulatorApp { result: Option, + trace: Vec, params: Arc>, - rx: mpsc::Receiver>, + rx: mpsc::Receiver, } impl RegulatorApp { fn new(ring: Option) -> Self { let params = Arc::new(Mutex::new(Params::default())); - let (tx, rx) = mpsc::channel::>(); + let (tx, rx) = mpsc::channel::(); let params_arc = params.clone(); std::thread::spawn(move || { let watch = SyntheticWatch { @@ -64,6 +81,9 @@ impl RegulatorApp { let demo_samples = watch.generate(SAMPLE_RATE, 120.0); let block = (BLOCK_SECONDS * SAMPLE_RATE as f64) as usize; let mut start = 0usize; + let mut win_start_s = 0.0f64; + let mut last_event_s = 0.0f64; + let mut trace: Vec = Vec::new(); let mut ts: u64 = 0; let mut last_len = 0usize; let mut cal_state = CalibrationState::new(); @@ -100,7 +120,7 @@ impl RegulatorApp { cal_cooldown -= 1; } drop(p); - let _ = tx.send(None::); + let _ = tx.send(Feed { result: None, trace: trace.clone() }); std::thread::sleep(Duration::from_millis(200)); continue; } @@ -114,6 +134,7 @@ impl RegulatorApp { let res = if p2.demo { let end = (start + block).min(demo_samples.len()); let r = analyzer.analyze(&demo_samples[start..end]); + win_start_s = start as f64 / SAMPLE_RATE as f64; if end == demo_samples.len() { start = 0; } else { @@ -123,6 +144,7 @@ impl RegulatorApp { } else if let Some(ring) = &ring { let buf = ring.lock().unwrap_or_else(|e| e.into_inner()); if buf.len() >= block { + win_start_s = (buf.len() - block) as f64 / SAMPLE_RATE as f64; analyzer.analyze(&buf[buf.len() - block..]) } else { None @@ -130,12 +152,42 @@ impl RegulatorApp { } else { None }; - let _ = tx.send(res); + if let Some(r) = &res { + let p0 = 7200.0 * SAMPLE_RATE as f64 / r.bph as f64; + for (ev, is_tic) in &r.events { + let t = win_start_s + ev / SAMPLE_RATE as f64; + if t <= last_event_s { + continue; + } + last_event_s = t; + let mut e = (ev % p0) / p0 - 0.5; + if e < -0.5 { + e += 1.0; + } + trace.push(TracePoint { + t, + phase_ms: e * (2.0 * 3600.0 / r.bph as f64) * 1000.0, + tic: *is_tic, + }); + } + while let Some(first) = trace.first() { + if first.t < win_start_s - 120.0 { + trace.remove(0); + } else { + break; + } + } + } + let _ = tx.send(Feed { + result: res, + trace: trace.clone(), + }); std::thread::sleep(Duration::from_millis(200)); } }); Self { result: None, + trace: Vec::new(), params, rx, } @@ -144,8 +196,9 @@ impl RegulatorApp { impl eframe::App for RegulatorApp { fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { - while let Ok(r) = self.rx.try_recv() { - self.result = r; + while let Ok(feed) = self.rx.try_recv() { + self.result = feed.result; + self.trace = feed.trace; } egui::SidePanel::right("settings") @@ -179,12 +232,12 @@ impl eframe::App for RegulatorApp { ui.checkbox(&mut p.demo, "demo mode"); ui.separator(); if p.calibrating { - ui.label(format!("calibrating: {} (use a quartz watch, 1 tick/s, ~15 min)", p.cal_progress)); + ui.label(format!("calibrating: {} (quartz watch, 1 tick/s; refits every second, stops when confident)", p.cal_progress)); if ui.button("stop calibration").clicked() { p.calibrating = false; } } else { - if ui.button("calibrate (quartz, ~15 min)").clicked() { + if ui.button("calibrate (quartz, exits early)").clicked() { p.calibrating = !p.demo; // calibration needs the mic p.cal_progress.clear(); } @@ -221,13 +274,51 @@ impl eframe::App for RegulatorApp { ); }); ui.separator(); - draw_waveform(ui, &self.result); + let wave_h = ui.available_size().y * 0.42; + draw_waveform(ui, &self.result, wave_h); + ui.separator(); + ui.label("Trace"); + draw_trace(ui, &self.trace); }); ctx.request_repaint_after(Duration::from_millis(200)); } } +/// The tick-event trace: each event plotted at its phase error over time. +/// A rate error shows as drifting diagonal bands, beat error as two +/// separated bands, noise as scatter - the classic timing-machine display. +fn draw_trace(ui: &mut egui::Ui, trace: &[TracePoint]) { + let (resp, painter) = ui.allocate_painter(ui.available_size(), egui::Sense::hover()); + painter.rect_filled(resp.rect, 4.0, egui::Color32::from_gray(16)); + if trace.is_empty() { + return; + } + let rect = resp.rect; + let t_end = trace.last().map(|p| p.t).unwrap_or(0.0); + let t_start = (t_end - 60.0).max(0.0); + // Vertical scale: half the beat period, so tic and toc bands both fit. + let half_ms = 1000.0 * 3600.0 / 14400.0; + let to_x = |t: f64| rect.left() + (((t - t_start) / 60.0).clamp(0.0, 1.0) * rect.width() as f64) as f32; + let to_y = |ms: f64| { + let k = (ms / half_ms).clamp(-1.0, 1.0) as f32; + rect.center().y - k * (rect.height() / 2.0 - 3.0) + }; + // Center line: the nominal beat grid. + painter.line_segment( + [rect.left_top() + egui::vec2(0.0, rect.height() / 2.0), rect.right_top() + egui::vec2(0.0, rect.height() / 2.0)], + egui::Stroke::new(1.0_f32, egui::Color32::from_gray(48)), + ); + for p in trace.iter().filter(|p| p.t >= t_start) { + let color = if p.tic { + egui::Color32::LIGHT_GREEN + } else { + egui::Color32::from_rgb(255, 120, 255) + }; + painter.circle_filled(egui::pos2(to_x(p.t), to_y(p.phase_ms)), 1.5_f32, color); + } +} + fn big_metric(ui: &mut egui::Ui, name: &str, value: &Option, unit: &str, decimals: usize) { let text = match value { Some(v) => format!("{:+.width$}", v, width = decimals), @@ -239,8 +330,9 @@ fn big_metric(ui: &mut egui::Ui, name: &str, value: &Option, unit: &str, de }); } -fn draw_waveform(ui: &mut egui::Ui, result: &Option) { - let (resp, painter) = ui.allocate_painter(ui.available_size(), egui::Sense::hover()); +fn draw_waveform(ui: &mut egui::Ui, result: &Option, height: f32) { + let size = egui::vec2(ui.available_size().x, height); + let (resp, painter) = ui.allocate_painter(size, egui::Sense::hover()); painter.rect_filled(resp.rect, 4.0, egui::Color32::from_gray(16)); let Some(r) = result else { return }; let wf = &r.waveform; From dd0446eebf0d298e0d456aaf1edeafdf6edecdd0 Mon Sep 17 00:00:00 2001 From: borosf Date: Tue, 17 Nov 2026 20:24:51 +0000 Subject: [PATCH 11/20] Redesign GUI as an instrument: vertical strip chart, single primary readout - Strip chart is now the centerpiece and vertical like a timegrapher: time flows downward (newest at the bottom), horizontal axis is the phase error against the beat grid (+/-25 ms window, wrapping), tic green / toc magenta dashes, grid lines every 10 ms - Layout per instrument UX: one large monospace rate readout at top (color-coded), secondary values (amp/be/lift/noise/cal) in a compact bottom strip, controls in a slim side panel, small waveform in the panel - no more three-equal-cards grid - Beat rate dropdown extended to all standard rates 12000-43200; 36000 bph covered by a new auto-detect test Co-authored-by: borosf --- crates/regulator-core/src/signal.rs | 16 ++ crates/regulator-gui/src/main.rs | 245 +++++++++++++++++----------- 2 files changed, 170 insertions(+), 91 deletions(-) diff --git a/crates/regulator-core/src/signal.rs b/crates/regulator-core/src/signal.rs index 0a8e937..1580928 100644 --- a/crates/regulator-core/src/signal.rs +++ b/crates/regulator-core/src/signal.rs @@ -177,6 +177,22 @@ mod tests { assert!((amp - 270.0).abs() < 25.0, "amplitude: {amp}"); } + #[test] + fn detects_36000_bph() { + let watch = SyntheticWatch { + bph: 36000, + rate_sday: -8.0, + beat_error_ms: 0.3, + amplitude_deg: 290.0, + quartz: false, + }; + let samples = watch.generate(SR, 6.0); + let an = Analyzer::new(SR); + let r = an.analyze(&samples).expect("analysis failed"); + assert_eq!(r.bph, 36000, "detected bph: {}", r.bph); + assert!((r.rate_sday.unwrap() - (-8.0)).abs() < 3.0); + } + #[test] fn rejects_silence() { let an = Analyzer::new(SR); diff --git a/crates/regulator-gui/src/main.rs b/crates/regulator-gui/src/main.rs index 6b2b71d..a2ed0be 100644 --- a/crates/regulator-gui/src/main.rs +++ b/crates/regulator-gui/src/main.rs @@ -200,18 +200,94 @@ impl eframe::App for RegulatorApp { self.result = feed.result; self.trace = feed.trace; } + let mut visuals = egui::Visuals::dark(); + visuals.panel_fill = egui::Color32::from_rgb(14, 16, 18); + visuals.window_fill = egui::Color32::from_rgb(14, 16, 18); + ctx.set_visuals(visuals); + // Top: the primary readout. One number the watchmaker stares at, + // everything else is secondary. + egui::TopBottomPanel::top("readout").show(ctx, |ui| { + ui.add_space(6.0); + ui.horizontal(|ui| { + let rate = self.result.as_ref().and_then(|r| r.rate_sday); + let text = match rate { + Some(v) => format!("{v:+.1}"), + None => "---".into(), + }; + let color = match rate { + Some(v) if v.abs() < 5.0 => egui::Color32::from_rgb(120, 220, 120), + Some(v) if v.abs() < 15.0 => egui::Color32::from_rgb(235, 200, 90), + Some(_) => egui::Color32::from_rgb(235, 120, 100), + None => egui::Color32::GRAY, + }; + ui.label( + egui::RichText::new(text) + .monospace() + .size(52.0) + .strong() + .color(color), + ); + ui.label(egui::RichText::new("s/d").monospace().size(16.0).color(egui::Color32::GRAY)); + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + let p = self.params.lock().unwrap_or_else(|e| e.into_inner()).clone(); + ui.label( + egui::RichText::new(format!( + "{} {}", + if p.demo { "demo" } else { "mic" }, + match p.bph { + 0 => "auto".to_string(), + b => format!("{b} bph"), + } + )) + .monospace() + .size(13.0) + .color(egui::Color32::GRAY), + ); + }); + }); + ui.add_space(2.0); + }); + + // Bottom: the secondary data strip. + egui::TopBottomPanel::bottom("strip").show(ctx, |ui| { + ui.add_space(4.0); + ui.horizontal(|ui| { + ui.style_mut().override_font_id = Some(egui::FontId::monospace(15.0)); + let p = self.params.lock().unwrap_or_else(|e| e.into_inner()).clone(); + strip_value(ui, "amp", &self.result.as_ref().and_then(|r| r.amplitude_deg).map(|v| format!("{v:.0}°"))); + strip_value(ui, "be", &self.result.as_ref().and_then(|r| r.beat_error_ms).map(|v| format!("{v:+.2} ms"))); + strip_value(ui, "lift", &Some(format!("{:.0}°", p.lift_angle))); + strip_value(ui, "noise", &Some(if p.noise_suppressor { "on".to_string() } else { "off".to_string() })); + if p.calibration != 0.0 { + strip_value(ui, "cal", &Some(format!("{:+.1} s/d", p.calibration))); + } + if p.calibrating { + ui.label( + egui::RichText::new(format!("calibrating {}", p.cal_progress)) + .monospace() + .size(13.0) + .color(egui::Color32::from_rgb(235, 200, 90)), + ); + } + }); + ui.add_space(4.0); + }); + + // Right: controls, compact. egui::SidePanel::right("settings") - .min_width(220.0) + .min_width(190.0) + .resizable(false) .show(ctx, |ui| { + ui.add_space(6.0); + ui.style_mut().override_font_id = Some(egui::FontId::monospace(13.0)); let mut p = self.params.lock().unwrap_or_else(|e| e.into_inner()); - ui.heading("Settings"); - ui.separator(); - ui.label("Beat rate"); + ui.label(egui::RichText::new("BEAT RATE").small().weak()); egui::ComboBox::from_id_salt("bph") .selected_text(if p.bph == 0 { "auto".into() } else { p.bph.to_string() }) + .width(ui.available_width() - 12.0) .show_ui(ui, |ui| { - for b in [0u32, 18000, 21600, 25200, 28800, 36000] { + for b in [0u32, 12000, 14400, 18000, 19800, 21600, 25200, 28800, 36000, 43200] { ui.selectable_value( &mut p.bph, b, @@ -219,117 +295,104 @@ impl eframe::App for RegulatorApp { ); } }); - ui.add( - egui::Slider::new(&mut p.lift_angle, 40.0..=60.0).text("lift angle (°)"), - ); + ui.add_space(6.0); + ui.label(egui::RichText::new(format!("LIFT ANGLE {:.0}°", p.lift_angle)).small().weak()); + ui.add(egui::Slider::new(&mut p.lift_angle, 40.0..=60.0).show_value(false)); + ui.add_space(6.0); ui.checkbox(&mut p.noise_suppressor, "noise suppressor"); - ui.separator(); - if p.demo { - ui.label("source: demo signal"); - } else { - ui.label("source: microphone"); - } - ui.checkbox(&mut p.demo, "demo mode"); - ui.separator(); + ui.checkbox(&mut p.demo, "demo signal"); + ui.add_space(10.0); if p.calibrating { - ui.label(format!("calibrating: {} (quartz watch, 1 tick/s; refits every second, stops when confident)", p.cal_progress)); if ui.button("stop calibration").clicked() { p.calibrating = false; } - } else { - if ui.button("calibrate (quartz, exits early)").clicked() { - p.calibrating = !p.demo; // calibration needs the mic - p.cal_progress.clear(); - } - if p.calibration != 0.0 { - ui.label(format!("calibration: {:+.1} s/d", p.calibration)); - } + } else if ui.button("calibrate (quartz)").clicked() { + p.calibrating = !p.demo; + p.cal_progress.clear(); } + ui.add_space(10.0); ui.separator(); - ui.small("regulator — GPLv2\na fork of tg"); + ui.add_space(6.0); + ui.label(egui::RichText::new("WAVEFORM").small().weak()); + draw_waveform(ui, &self.result, 90.0); + ui.with_layout(egui::Layout::bottom_up(egui::Align::LEFT), |ui| { + ui.label( + egui::RichText::new("regulator — GPLv2") + .monospace() + .size(11.0) + .color(egui::Color32::from_gray(90)), + ); + }); }); - egui::CentralPanel::default().show(ctx, |ui| { - ui.horizontal(|ui| { - big_metric( - ui, - "Rate", - &self.result.as_ref().and_then(|r| r.rate_sday), - "s/day", - 1, - ); - big_metric( - ui, - "Amplitude", - &self.result.as_ref().and_then(|r| r.amplitude_deg), - "°", - 0, - ); - big_metric( - ui, - "Beat error", - &self.result.as_ref().and_then(|r| r.beat_error_ms), - "ms", - 2, - ); + // Center: the strip chart. Time flows downward, newest ticks at the + // bottom; horizontal axis is the phase error against the beat grid. + egui::CentralPanel::default() + .frame(egui::Frame::default().fill(egui::Color32::from_rgb(10, 11, 12))) + .show(ctx, |ui| { + draw_trace(ui, &self.trace); }); - ui.separator(); - let wave_h = ui.available_size().y * 0.42; - draw_waveform(ui, &self.result, wave_h); - ui.separator(); - ui.label("Trace"); - draw_trace(ui, &self.trace); - }); ctx.request_repaint_after(Duration::from_millis(200)); } } -/// The tick-event trace: each event plotted at its phase error over time. -/// A rate error shows as drifting diagonal bands, beat error as two -/// separated bands, noise as scatter - the classic timing-machine display. +fn strip_value(ui: &mut egui::Ui, name: &str, value: &Option) { + let v = value.clone().unwrap_or_else(|| "---".into()); + ui.label(egui::RichText::new(name).size(11.0).color(egui::Color32::from_gray(110))); + ui.label(egui::RichText::new(v).size(15.0).strong()); + ui.add_space(12.0); +} + +/// The strip chart: each tick event is a short dash at its phase error; +/// time scrolls downward. Rate error drifts the dashes sideways, beat +/// error splits tic/toc into two columns, noise widens the scatter. fn draw_trace(ui: &mut egui::Ui, trace: &[TracePoint]) { let (resp, painter) = ui.allocate_painter(ui.available_size(), egui::Sense::hover()); - painter.rect_filled(resp.rect, 4.0, egui::Color32::from_gray(16)); - if trace.is_empty() { - return; - } let rect = resp.rect; - let t_end = trace.last().map(|p| p.t).unwrap_or(0.0); - let t_start = (t_end - 60.0).max(0.0); - // Vertical scale: half the beat period, so tic and toc bands both fit. - let half_ms = 1000.0 * 3600.0 / 14400.0; - let to_x = |t: f64| rect.left() + (((t - t_start) / 60.0).clamp(0.0, 1.0) * rect.width() as f64) as f32; - let to_y = |ms: f64| { - let k = (ms / half_ms).clamp(-1.0, 1.0) as f32; - rect.center().y - k * (rect.height() / 2.0 - 3.0) + painter.rect_filled(rect, 0.0, egui::Color32::from_rgb(10, 11, 12)); + // Phase-error window: +/- 25 ms, ticks wrap into it. + const WINDOW_MS: f64 = 25.0; + let cx = rect.center().x; + let half_w = rect.width() / 2.0 - 8.0; + let to_x = |ms: f64| { + let wrapped = ((ms + WINDOW_MS) % (2.0 * WINDOW_MS) + 2.0 * WINDOW_MS) % (2.0 * WINDOW_MS) - WINDOW_MS; + cx + (wrapped / WINDOW_MS * half_w as f64) as f32 }; - // Center line: the nominal beat grid. - painter.line_segment( - [rect.left_top() + egui::vec2(0.0, rect.height() / 2.0), rect.right_top() + egui::vec2(0.0, rect.height() / 2.0)], - egui::Stroke::new(1.0_f32, egui::Color32::from_gray(48)), - ); - for p in trace.iter().filter(|p| p.t >= t_start) { + // Grid: center line plus 10 ms steps. + for ms in [-20.0, -10.0, 0.0, 10.0, 20.0] { + let x = to_x(ms); + let color = if ms == 0.0 { + egui::Color32::from_gray(52) + } else { + egui::Color32::from_gray(28) + }; + painter.line_segment( + [egui::pos2(x, rect.top()), egui::pos2(x, rect.bottom())], + egui::Stroke::new(1.0_f32, color), + ); + } + let bottom = rect.bottom(); + let h = rect.height(); + for p in trace { + let age = trace.last().map(|q| q.t).unwrap_or(0.0) - p.t; + if age > 60.0 { + continue; + } + let y = bottom - (age / 60.0 * h as f64) as f32; + let x = to_x(p.phase_ms); let color = if p.tic { - egui::Color32::LIGHT_GREEN + egui::Color32::from_rgb(140, 230, 140) } else { - egui::Color32::from_rgb(255, 120, 255) + egui::Color32::from_rgb(240, 140, 240) }; - painter.circle_filled(egui::pos2(to_x(p.t), to_y(p.phase_ms)), 1.5_f32, color); + painter.line_segment( + [egui::pos2(x - 1.5, y), egui::pos2(x + 1.5, y)], + egui::Stroke::new(1.6_f32, color), + ); } } -fn big_metric(ui: &mut egui::Ui, name: &str, value: &Option, unit: &str, decimals: usize) { - let text = match value { - Some(v) => format!("{:+.width$}", v, width = decimals), - None => "---".into(), - }; - ui.vertical(|ui| { - ui.heading(egui::RichText::new(text).size(34.0)); - ui.label(format!("{name} ({unit})")); - }); -} - fn draw_waveform(ui: &mut egui::Ui, result: &Option, height: f32) { let size = egui::vec2(ui.available_size().x, height); let (resp, painter) = ui.allocate_painter(size, egui::Sense::hover()); From 0d77fcf58c103c08e8a6d339dd5a520379f6a24b Mon Sep 17 00:00:00 2001 From: borosf Date: Tue, 17 Nov 2026 20:29:34 +0000 Subject: [PATCH 12/20] Calibration feedback view, editable lift angle, chart export - During calibration the center panel becomes live feedback: collected (time, phase) samples plotted, progress counter, current estimate with its standard error, and a 'waiting for ticks' hint when no quartz signal is detected - Calibrate button now switches from demo to mic automatically instead of silently doing nothing - Lift angle is a typed DragValue (30-70) instead of a slider - 'export chart' button writes the strip chart as SVG plus raw points as CSV (timestamped filenames in the working directory) - Removed the license footer label Co-authored-by: borosf --- crates/regulator-core/src/calibrate.rs | 24 +++- crates/regulator-gui/src/chart.rs | 163 +++++++++++++++++++++++++ crates/regulator-gui/src/main.rs | 77 +++++++++--- 3 files changed, 245 insertions(+), 19 deletions(-) create mode 100644 crates/regulator-gui/src/chart.rs diff --git a/crates/regulator-core/src/calibrate.rs b/crates/regulator-core/src/calibrate.rs index 8b3de56..279a2af 100644 --- a/crates/regulator-core/src/calibrate.rs +++ b/crates/regulator-core/src/calibrate.rs @@ -56,6 +56,17 @@ impl CalibrationState { self.cal } + /// The (time, phase) samples collected so far, for live feedback. + pub fn points(&self) -> &[(f64, f64)] { + &self.points + } + + /// The current best-fit calibration and its standard error in s/day, + /// even if the quality gate has not been met yet. + pub fn estimate(&self) -> Option<(f64, f64)> { + Self::fit_with_delta(&self.points).ok() + } + /// Progress: (collected, needed). pub fn progress(&self) -> (usize, usize) { (self.points.len(), self.need) @@ -135,6 +146,14 @@ impl CalibrationState { /// direction, then least-squares fit the drift; the slope in s/d is the /// sound card's apparent rate error. fn fit(points: &[(f64, f64)]) -> Result { + let (cal, delta) = Self::fit_with_delta(points)?; + if delta >= 0.1 { + return Err(()); + } + Ok(cal) + } + + fn fit_with_delta(points: &[(f64, f64)]) -> Result<(f64, f64), ()> { let n = points.len(); if n < 3 { return Err(()); @@ -165,10 +184,7 @@ impl CalibrationState { } let calibration = xy * 3600.0 * 24.0 / xx; let delta = ((xx * yy - xy * xy) / (n as f64 - 2.0)).sqrt() / xx; - if delta * 3600.0 * 24.0 >= 0.1 { - return Err(()); - } - Ok(calibration) + Ok((calibration, delta * 3600.0 * 24.0)) } } diff --git a/crates/regulator-gui/src/chart.rs b/crates/regulator-gui/src/chart.rs new file mode 100644 index 0000000..cff5aae --- /dev/null +++ b/crates/regulator-gui/src/chart.rs @@ -0,0 +1,163 @@ +// SPDX-License-Identifier: GPL-2.0 +//! Calibration feedback view and chart export. + +use crate::{CalView, Params, TracePoint}; +use eframe::egui; +use std::sync::{Arc, Mutex}; + +/// Live calibration feedback: the collected (time, phase) samples, progress, +/// and the current estimate with its standard error. +pub fn draw_cal_view(ui: &mut egui::Ui, cal: &CalView) { + ui.vertical(|ui| { + ui.add_space(8.0); + ui.label( + egui::RichText::new("CALIBRATION") + .monospace() + .size(18.0) + .strong(), + ); + ui.label( + egui::RichText::new("place a quartz watch (1 tick/s) near the microphone") + .monospace() + .size(12.0) + .color(egui::Color32::GRAY), + ); + ui.label( + egui::RichText::new(format!("samples {}/{}", cal.have, cal.need)) + .monospace() + .size(13.0), + ); + if let Some((est, err)) = cal.estimate { + ui.label( + egui::RichText::new(format!( + "estimate {est:+.2} ± {err:.2} s/d (done under ±0.10)" + )) + .monospace() + .size(13.0) + .color(egui::Color32::from_rgb(235, 200, 90)), + ); + } + if cal.have == 0 { + ui.label( + egui::RichText::new("waiting for ticks…") + .monospace() + .size(13.0) + .color(egui::Color32::from_gray(120)), + ); + } + ui.add_space(4.0); + }); + let (resp, painter) = ui.allocate_painter(ui.available_size(), egui::Sense::hover()); + let rect = resp.rect; + painter.rect_filled(rect, 0.0, egui::Color32::from_rgb(10, 11, 12)); + if cal.points.is_empty() { + return; + } + let t_max = cal.points.last().map(|p| p.0).unwrap_or(1.0).max(1.0); + let to_x = |t: f64| rect.left() + (t / t_max * (rect.width() - 12.0) as f64) as f32 + 6.0; + let to_y = |ph: f64| { + let k = ph.clamp(0.0, 1.0) as f32; + rect.bottom() - k * (rect.height() - 12.0) - 6.0 + }; + for y in [to_y(0.0), to_y(1.0)] { + painter.line_segment( + [egui::pos2(rect.left() + 6.0, y), egui::pos2(rect.right() - 6.0, y)], + egui::Stroke::new(1.0_f32, egui::Color32::from_gray(40)), + ); + } + for &(t, ph) in &cal.points { + painter.circle_filled( + egui::pos2(to_x(t), to_y(ph)), + 2.0_f32, + egui::Color32::from_rgb(140, 230, 140), + ); + } +} + +/// Export the current strip chart as an SVG file plus the raw points as CSV. +/// Returns the base path written. +pub fn export_chart( + trace: &[TracePoint], + result: &Option, + params: &Arc>, +) -> Option { + use std::fmt::Write as _; + let now = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .ok()?; + let secs = now.as_secs(); + let (d, h, m) = (secs / 86400, secs % 86400 / 3600, secs % 3600 / 60); + let base = format!("regulator-chart-{d}-{h:02}{m:02}"); + let p = params.lock().unwrap_or_else(|e| e.into_inner()).clone(); + let fmt_or = |v: Option, spec: &dyn Fn(f64) -> String| { + v.map(spec).unwrap_or_else(|| "---".into()) + }; + let (rate, amp, be) = match result { + Some(r) => ( + fmt_or(r.rate_sday, &|v| format!("{v:+.1}")), + fmt_or(r.amplitude_deg, &|v| format!("{v:.0}")), + fmt_or(r.beat_error_ms, &|v| format!("{v:+.2}")), + ), + None => ("---".into(), "---".into(), "---".into()), + }; + let bph = match p.bph { + 0 => "auto".to_string(), + b => b.to_string(), + }; + + let mut csv = String::from("time_s,phase_ms,tic\n"); + for t in trace { + let _ = writeln!(csv, "{:.2},{:.3},{}", t.t, t.phase_ms, t.tic); + } + std::fs::write(format!("{base}.csv"), csv).ok()?; + + const W: f64 = 800.0; + const H: f64 = 600.0; + const WINDOW_MS: f64 = 25.0; + let top = 60.0; + let chart_h = H - top - 10.0; + let cx = W / 2.0; + let half_w = W / 2.0 - 20.0; + let wrap = |ms: f64| { + ((ms + WINDOW_MS) % (2.0 * WINDOW_MS) + 2.0 * WINDOW_MS) % (2.0 * WINDOW_MS) - WINDOW_MS + }; + let mut svg = String::new(); + let _ = writeln!( + svg, + "" + ); + let _ = writeln!(svg, ""); + let _ = writeln!( + svg, + "rate {rate} s/d" + ); + let _ = writeln!( + svg, + "amp {amp} deg be {be} ms bph {bph} lift {:.0} deg", + p.lift_angle + ); + for ms in [-20.0, -10.0, 0.0, 10.0, 20.0] { + let x = cx + wrap(ms) / WINDOW_MS * half_w; + let color = if ms == 0.0 { "#3a3a3a" } else { "#1c1c1c" }; + let _ = writeln!( + svg, + "", + top + chart_h + ); + } + let t_end = trace.last().map(|t| t.t).unwrap_or(0.0); + for t in trace.iter().filter(|t| t_end - t.t <= 60.0) { + let y = top + chart_h - (t_end - t.t) / 60.0 * chart_h; + let x = cx + wrap(t.phase_ms) / WINDOW_MS * half_w; + let color = if t.tic { "#8ce68c" } else { "#f08cf0" }; + let _ = writeln!( + svg, + "", + x - 1.5, + x + 1.5 + ); + } + let _ = writeln!(svg, ""); + std::fs::write(format!("{base}.svg"), svg).ok()?; + Some(base) +} diff --git a/crates/regulator-gui/src/main.rs b/crates/regulator-gui/src/main.rs index a2ed0be..0511e3c 100644 --- a/crates/regulator-gui/src/main.rs +++ b/crates/regulator-gui/src/main.rs @@ -4,6 +4,7 @@ #[cfg(feature = "audio")] mod audio; +mod chart; use eframe::egui; use regulator_core::{CalStatus, CalibrationState, Analyzer, SyntheticWatch, TimingResult}; @@ -21,10 +22,19 @@ struct TracePoint { tic: bool, } +/// Live calibration feedback for the center panel. +struct CalView { + points: Vec<(f64, f64)>, + have: usize, + need: usize, + estimate: Option<(f64, f64)>, +} + /// What the worker sends to the UI each iteration. struct Feed { result: Option, trace: Vec, + cal: Option, } const SAMPLE_RATE: u32 = 44100; @@ -61,6 +71,8 @@ type Ring = Arc>>; struct RegulatorApp { result: Option, trace: Vec, + cal: Option, + last_export: Option, params: Arc>, rx: mpsc::Receiver, } @@ -119,8 +131,14 @@ impl RegulatorApp { if cal_cooldown > 0 { cal_cooldown -= 1; } + let view = CalView { + points: cal_state.points().to_vec(), + have: cal_state.progress().0, + need: cal_state.progress().1, + estimate: cal_state.estimate(), + }; drop(p); - let _ = tx.send(Feed { result: None, trace: trace.clone() }); + let _ = tx.send(Feed { result: None, trace: Vec::new(), cal: Some(view) }); std::thread::sleep(Duration::from_millis(200)); continue; } @@ -181,6 +199,7 @@ impl RegulatorApp { let _ = tx.send(Feed { result: res, trace: trace.clone(), + cal: None, }); std::thread::sleep(Duration::from_millis(200)); } @@ -188,6 +207,8 @@ impl RegulatorApp { Self { result: None, trace: Vec::new(), + cal: None, + last_export: None, params, rx, } @@ -199,6 +220,11 @@ impl eframe::App for RegulatorApp { while let Ok(feed) = self.rx.try_recv() { self.result = feed.result; self.trace = feed.trace; + if feed.cal.is_some() { + self.cal = feed.cal; + } else { + self.cal = None; + } } let mut visuals = egui::Visuals::dark(); visuals.panel_fill = egui::Color32::from_rgb(14, 16, 18); @@ -296,8 +322,13 @@ impl eframe::App for RegulatorApp { } }); ui.add_space(6.0); - ui.label(egui::RichText::new(format!("LIFT ANGLE {:.0}°", p.lift_angle)).small().weak()); - ui.add(egui::Slider::new(&mut p.lift_angle, 40.0..=60.0).show_value(false)); + ui.label(egui::RichText::new("LIFT ANGLE").small().weak()); + ui.add( + egui::DragValue::new(&mut p.lift_angle) + .range(30.0..=70.0) + .speed(0.5) + .suffix("°"), + ); ui.add_space(6.0); ui.checkbox(&mut p.noise_suppressor, "noise suppressor"); ui.checkbox(&mut p.demo, "demo signal"); @@ -307,7 +338,8 @@ impl eframe::App for RegulatorApp { p.calibrating = false; } } else if ui.button("calibrate (quartz)").clicked() { - p.calibrating = !p.demo; + p.demo = false; + p.calibrating = true; p.cal_progress.clear(); } ui.add_space(10.0); @@ -315,24 +347,39 @@ impl eframe::App for RegulatorApp { ui.add_space(6.0); ui.label(egui::RichText::new("WAVEFORM").small().weak()); draw_waveform(ui, &self.result, 90.0); - ui.with_layout(egui::Layout::bottom_up(egui::Align::LEFT), |ui| { - ui.label( - egui::RichText::new("regulator — GPLv2") - .monospace() - .size(11.0) - .color(egui::Color32::from_gray(90)), - ); - }); }); - // Center: the strip chart. Time flows downward, newest ticks at the - // bottom; horizontal axis is the phase error against the beat grid. + // Center: the strip chart, or live calibration feedback while + // calibrating. egui::CentralPanel::default() .frame(egui::Frame::default().fill(egui::Color32::from_rgb(10, 11, 12))) .show(ctx, |ui| { - draw_trace(ui, &self.trace); + if let Some(cal) = &self.cal { + chart::draw_cal_view(ui, cal); + } else { + draw_trace(ui, &self.trace); + } }); + // Export needs the trace; run it from a small panel-level button on + // the top bar, right side. + egui::TopBottomPanel::top("export").show(ctx, |ui| { + ui.add_space(2.0); + ui.horizontal(|ui| { + if ui.button("export chart").clicked() { + self.last_export = chart::export_chart(&self.trace, &self.result, &self.params); + } + if let Some(path) = &self.last_export { + ui.label( + egui::RichText::new(format!("saved {path}")) + .monospace() + .size(12.0) + .color(egui::Color32::from_rgb(120, 220, 120)), + ); + } + }); + }); + ctx.request_repaint_after(Duration::from_millis(200)); } } From c6e2127a8752f31d63bce17612140161d7fa5ed6 Mon Sep 17 00:00:00 2001 From: borosf Date: Tue, 17 Nov 2026 20:36:33 +0000 Subject: [PATCH 13/20] Reinvent calibration: passive clock-based sound-card rate estimation The 900-sample quartz calibration exists because tg averages phase noise against a wristwatch reference. But the sound card's clock error can be measured directly against the NTP-disciplined system clock: regress the cumulative captured sample count against batch arrival times (regulator-core::ClockCal). This runs passively whenever the mic is on - no watch, no mode, no user action - and converges within a few minutes; the fit's standard error shrinks as batches accumulate and the correction auto-applies once it is under 0.25 s/d (shown as 'cal auto' in the strip). The quartz path remains available as an independent check. Co-authored-by: borosf --- crates/regulator-core/src/clock_cal.rs | 132 +++++++++++++++++++++++++ crates/regulator-core/src/lib.rs | 2 + crates/regulator-gui/src/main.rs | 25 ++++- crates/regulator-tui/src/main.rs | 4 +- crates/regulator-tui/src/ui.rs | 2 +- 5 files changed, 159 insertions(+), 6 deletions(-) create mode 100644 crates/regulator-core/src/clock_cal.rs diff --git a/crates/regulator-core/src/clock_cal.rs b/crates/regulator-core/src/clock_cal.rs new file mode 100644 index 0000000..8442548 --- /dev/null +++ b/crates/regulator-core/src/clock_cal.rs @@ -0,0 +1,132 @@ +// SPDX-License-Identifier: GPL-2.0 +//! Clock-based sound-card calibration. +//! +//! tg measures the sound card's clock error against a quartz watch ticking +//! once per second, which needs many minutes of phase samples. But the +//! quantity of interest is simply how far the ADC's sample rate drifts from +//! real time - and the host's system clock (NTP-disciplined) is a better +//! reference than any wristwatch. Regressing the cumulative sample count +//! against batch arrival times gives the same correction passively, with no +//! watch and no calibration mode, converging in a few minutes. + +use std::time::Instant; + +/// Live clock-calibration accumulator: feed it captured samples as they +/// arrive; it regresses the cumulative count against wall time. +#[derive(Debug)] +pub struct ClockCal { + sample_rate: f64, + start: Option, + total: u64, + /// (t seconds since start, cumulative samples), thinned to ~4 Hz. + points: Vec<(f64, f64)>, + last_point: f64, +} + +impl ClockCal { + pub fn new(sample_rate: u32) -> Self { + ClockCal { + sample_rate: sample_rate as f64, + start: None, + total: 0, + points: Vec::new(), + last_point: f64::NEG_INFINITY, + } + } + + /// Record `n` newly captured samples. + pub fn add(&mut self, n: usize) { + let t = self + .start + .get_or_insert_with(Instant::now) + .elapsed() + .as_secs_f64(); + self.add_at(n, t); + } + + /// Record `n` samples captured at `t` seconds since capture start + /// (separated for testability). + pub fn add_at(&mut self, n: usize, t: f64) { + self.total += n as u64; + if t - self.last_point >= 0.25 { + self.last_point = t; + self.points.push((t, self.total as f64)); + } + } + + /// The sound-card rate error in s/day, with its uncertainty in s/day, + /// from a least-squares fit of samples against time. Returns None until + /// at least two seconds of data have been recorded. + pub fn estimate(&self) -> Option<(f64, f64)> { + let n = self.points.len(); + if n < 8 || self.points.last()?.0 < 2.0 { + return None; + } + let (t_av, n_av) = ( + self.points.iter().map(|p| p.0).sum::() / n as f64, + self.points.iter().map(|p| p.1).sum::() / n as f64, + ); + let (mut stt, mut stn, mut sxx) = (0.0, 0.0, 0.0); + for &(t, c) in &self.points { + let (dt, dc) = (t - t_av, c - n_av); + stt += dt * dt; + stn += dt * dc; + sxx += dc * dc; + } + if stt <= 0.0 { + return None; + } + let slope = stn / stt; // samples per second + let err = (slope / self.sample_rate - 1.0) * 86400.0; + // Standard error of the slope from the residuals. + let syy = sxx - slope * stn; + let resid_var = (syy / (n as f64 - 2.0)).max(0.0); + let slope_err = (resid_var / stt).sqrt(); + let unc = slope_err / self.sample_rate * 86400.0; + Some((err, unc)) + } + + /// True once the fit has converged under `gate` s/day uncertainty. + pub fn converged(&self, gate: f64) -> Option { + let (err, unc) = self.estimate()?; + if unc <= gate { + Some(err) + } else { + None + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn recovers_rate_error() { + // A card running 12 s/day fast: cumulative samples follow + // 44100 * (1 + 12/86400) per second. + let mut cal = ClockCal::new(44100); + let rate = 44100.0_f64 * (1.0 + 12.0 / 86400.0); + // 0.25 s batches over 300 s, with +/-1 ms of jitter per batch. + for i in 0..1200 { + let t = (i + 1) as f64 * 0.25; + let jitter = if i % 2 == 0 { 0.001 } else { -0.001 }; + let samples = (rate * (0.25 + jitter)).round() as usize; + cal.add_at(samples, t); + } + let (err, unc) = cal.estimate().expect("estimate"); + assert!((err - 12.0).abs() < 1.0, "err: {err}"); + assert!(unc < 1.0, "unc: {unc}"); + let done = cal.converged(1.0).expect("converged"); + assert!((done - 12.0).abs() < 1.0); + } + + #[test] + fn needs_data_to_converge() { + let mut cal = ClockCal::new(44100); + assert!(cal.estimate().is_none()); + cal.add(44100); + assert!(cal.estimate().is_none()); + assert!(cal.converged(0.1).is_none()); + } +} diff --git a/crates/regulator-core/src/lib.rs b/crates/regulator-core/src/lib.rs index 765fba1..654c6fe 100644 --- a/crates/regulator-core/src/lib.rs +++ b/crates/regulator-core/src/lib.rs @@ -13,11 +13,13 @@ pub mod analyze; pub mod calibrate; +pub mod clock_cal; pub mod filters; pub mod signal; pub mod stats; pub use analyze::{Analyzer, TimingResult}; pub use calibrate::{CalStatus, CalibrationState, CAL_DATA_SIZE}; +pub use clock_cal::ClockCal; pub use signal::SyntheticWatch; pub const FILTER_CUTOFF: f64 = 3000.0; diff --git a/crates/regulator-gui/src/main.rs b/crates/regulator-gui/src/main.rs index 0511e3c..8599eba 100644 --- a/crates/regulator-gui/src/main.rs +++ b/crates/regulator-gui/src/main.rs @@ -7,7 +7,7 @@ mod audio; mod chart; use eframe::egui; -use regulator_core::{CalStatus, CalibrationState, Analyzer, SyntheticWatch, TimingResult}; +use regulator_core::{CalStatus, CalibrationState, ClockCal, Analyzer, SyntheticWatch, TimingResult}; use std::sync::mpsc; use std::sync::{Arc, Mutex}; use std::time::Duration; @@ -48,6 +48,8 @@ struct Params { demo: bool, calibrating: bool, calibration: f64, + /// Calibration came from the passive clock estimate, not a quartz run. + cal_auto: bool, cal_progress: String, } @@ -60,6 +62,7 @@ impl Default for Params { demo: true, calibrating: false, calibration: 0.0, + cal_auto: false, cal_progress: String::new(), } } @@ -78,10 +81,11 @@ struct RegulatorApp { } impl RegulatorApp { - fn new(ring: Option) -> Self { + fn new(ring: Option, clock_cal: Arc>) -> Self { let params = Arc::new(Mutex::new(Params::default())); let (tx, rx) = mpsc::channel::(); let params_arc = params.clone(); + let clock_cal = clock_cal; std::thread::spawn(move || { let watch = SyntheticWatch { bph: 28800, @@ -142,6 +146,16 @@ impl RegulatorApp { std::thread::sleep(Duration::from_millis(200)); continue; } + // Passive clock calibration: apply once the sample-count + // regression has converged (unless a quartz calibration + // has set the value manually). + if let Some(err) = clock_cal.lock().unwrap_or_else(|e| e.into_inner()).converged(0.25) { + let mut p = params_arc.lock().unwrap_or_else(|e| e.into_inner()); + if p.cal_auto || p.calibration == 0.0 { + p.calibration = err; + p.cal_auto = true; + } + } drop(p); let p2 = params_arc.lock().unwrap_or_else(|e| e.into_inner()).clone(); let mut analyzer = Analyzer::new(SAMPLE_RATE); @@ -286,7 +300,8 @@ impl eframe::App for RegulatorApp { strip_value(ui, "lift", &Some(format!("{:.0}°", p.lift_angle))); strip_value(ui, "noise", &Some(if p.noise_suppressor { "on".to_string() } else { "off".to_string() })); if p.calibration != 0.0 { - strip_value(ui, "cal", &Some(format!("{:+.1} s/d", p.calibration))); + let tag = if p.cal_auto { " auto" } else { "" }; + strip_value(ui, "cal", &Some(format!("{:+.1} s/d{tag}", p.calibration))); } if p.calibrating { ui.label( @@ -508,6 +523,8 @@ fn main() -> anyhow::Result<()> { } }; + let clock_cal: Arc> = Arc::new(Mutex::new(ClockCal::new(SAMPLE_RATE))); + let native = eframe::NativeOptions { viewport: egui::ViewportBuilder::default() .with_inner_size([900.0, 520.0]) @@ -517,7 +534,7 @@ fn main() -> anyhow::Result<()> { eframe::run_native( "regulator", native, - Box::new(move |_cc| Ok(Box::new(RegulatorApp::new(ring)))), + Box::new(move |_cc| Ok(Box::new(RegulatorApp::new(ring, clock_cal)))), ) .map_err(|e| anyhow::anyhow!("{e}")) } diff --git a/crates/regulator-tui/src/main.rs b/crates/regulator-tui/src/main.rs index 597f002..3023101 100644 --- a/crates/regulator-tui/src/main.rs +++ b/crates/regulator-tui/src/main.rs @@ -12,7 +12,9 @@ use crossterm::terminal::{ }; use ratatui::backend::CrosstermBackend; use ratatui::Terminal; -use regulator_core::{CalStatus, CalibrationState, Analyzer, SyntheticWatch, TimingResult}; +use regulator_core::{Analyzer, SyntheticWatch, TimingResult}; +#[cfg(feature = "audio")] +use regulator_core::{CalStatus, CalibrationState}; use std::sync::mpsc; use std::sync::{Arc, Mutex}; use std::time::{Duration, Instant}; diff --git a/crates/regulator-tui/src/ui.rs b/crates/regulator-tui/src/ui.rs index 2b044e8..ffe9075 100644 --- a/crates/regulator-tui/src/ui.rs +++ b/crates/regulator-tui/src/ui.rs @@ -162,7 +162,7 @@ fn draw_status(f: &mut ratatui::Frame, area: Rect, s: &Settings) { let line = Line::from(vec![ Span::styled(format!(" {} ", s.source), Style::default().bg(Color::DarkGray)), Span::raw(format!( - " bph:{bph} lift:{:.0}° noise:{} ", + " bph:{bph} lift:{:.0}° noise:{}{cal} ", s.lift_angle, if s.noise_suppressor { "on" } else { "off" } )), From 9a8a4afe9fe3d918a61832769b6878c67b2eec2e Mon Sep 17 00:00:00 2001 From: borosf Date: Tue, 17 Nov 2026 20:39:12 +0000 Subject: [PATCH 14/20] ClockCal: detect NTP clock steps and restart the fit cleanly Co-authored-by: borosf --- crates/regulator-core/src/clock_cal.rs | 50 ++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/crates/regulator-core/src/clock_cal.rs b/crates/regulator-core/src/clock_cal.rs index 8442548..40d0f33 100644 --- a/crates/regulator-core/src/clock_cal.rs +++ b/crates/regulator-core/src/clock_cal.rs @@ -48,10 +48,37 @@ impl ClockCal { /// (separated for testability). pub fn add_at(&mut self, n: usize, t: f64) { self.total += n as u64; - if t - self.last_point >= 0.25 { - self.last_point = t; - self.points.push((t, self.total as f64)); + if t - self.last_point < 0.25 { + return; } + // Step detection: if the new point lands far off the current trend, + // the system clock jumped (NTP step) - the old points are on a + // different time base, so restart the series from here. + if self.points.len() >= 16 { + let (t_av, n_av) = self.means(); + let (mut stt, mut stn) = (0.0, 0.0); + for &(pt, c) in &self.points { + stt += (pt - t_av) * (pt - t_av); + stn += (pt - t_av) * (c - n_av); + } + if stt > 0.0 { + let slope = stn / stt; + let predicted = n_av + slope * (t - t_av); + if (self.total as f64 - predicted).abs() > 0.05 * slope { + self.points.clear(); + } + } + } + self.last_point = t; + self.points.push((t, self.total as f64)); + } + + fn means(&self) -> (f64, f64) { + let n = self.points.len() as f64; + ( + self.points.iter().map(|p| p.0).sum::() / n, + self.points.iter().map(|p| p.1).sum::() / n, + ) } /// The sound-card rate error in s/day, with its uncertainty in s/day, @@ -121,6 +148,23 @@ mod tests { assert!((done - 12.0).abs() < 1.0); } + #[test] + fn survives_clock_step() { + let mut cal = ClockCal::new(44100); + let rate = 44100.0_f64; + for i in 0..400 { + cal.add_at((rate * 0.25) as usize, (i + 1) as f64 * 0.25); + } + // The system clock steps by 1.4 s: subsequent timestamps jump. + let step = 1.4; + for i in 400..800 { + cal.add_at((rate * 0.25) as usize, (i + 1) as f64 * 0.25 + step); + } + let (err, unc) = cal.estimate().expect("estimate after step"); + assert!(err.abs() < 1.0, "err: {err}"); + assert!(unc < 1.0, "unc: {unc}"); + } + #[test] fn needs_data_to_converge() { let mut cal = ClockCal::new(44100); From 700149607967edda793c1903a4db72dd6cb5d3f6 Mon Sep 17 00:00:00 2001 From: borosf Date: Tue, 17 Nov 2026 20:46:38 +0000 Subject: [PATCH 15/20] Fix trace: measure real tick arrivals; monotonic time base; live cal readout - Events are now measured, not extrapolated: each expected tick position is searched in the prepared signal for the actual peak (rejected if it does not rise above the local noise floor), so the trace shows genuine per-tick scatter and drift instead of static stripes - Mic ring buffer carries a monotonic sample counter, so window start times no longer oscillate when the buffer drains (the cause of the frozen, patternless chart); demo mode uses a running total too - Clock calibration shows live while converging: 'cal +2.1 +-1.4' in amber in the bottom strip until it auto-applies as 'cal ... auto' Co-authored-by: borosf --- crates/regulator-core/src/analyze.rs | 37 ++++++++----- crates/regulator-gui/src/main.rs | 80 ++++++++++++++++++++-------- 2 files changed, 83 insertions(+), 34 deletions(-) diff --git a/crates/regulator-core/src/analyze.rs b/crates/regulator-core/src/analyze.rs index 58c232e..adc2970 100644 --- a/crates/regulator-core/src/analyze.rs +++ b/crates/regulator-core/src/analyze.rs @@ -134,26 +134,39 @@ impl Analyzer { _ => None, }; - // Locate individual tick events by extrapolating the tic/toc peaks - // through the block at the detected period (a light-weight version - // of tg's locate_events, which cross-correlates a template). + // Locate individual tick events by measuring each arrival: search + // the prepared signal around each expected position (extrapolated + // from the folded-waveform peaks at the detected period) for the + // local maximum. The deviation of the measured peak from the + // expectation is the per-tick phase error that draws the trace. let mut events = Vec::new(); if let (Some(tic), Some(toc)) = (tic, toc) { - let wf_size = waveform.len().max(1); + let search = (period / 16.0).max(4.0) as usize; let tic0 = (tic + phase_shift) as f64; let toc0 = (toc + phase_shift) as f64; let cycles = (n as f64 / period).ceil() as usize + 1; for k in 0..cycles { - let t = tic0 + k as f64 * period; - if t >= 0.0 && t < n as f64 { - events.push((t, true)); - } - let t = toc0 + k as f64 * period; - if t >= 0.0 && t < n as f64 { - events.push((t, false)); + for (base, is_tic) in [(tic0, true), (toc0, false)] { + let expected = base + k as f64 * period; + if expected < -(search as f64) || expected > n as f64 { + continue; + } + let a = (expected as isize - search as isize).max(0) as usize; + let b = ((expected as usize) + search).min(n - 1); + if b <= a { + continue; + } + // Only accept a peak that actually rises above the + // local noise floor; otherwise the tick was missed. + let (peak, _) = vmax(&s, a, b + 1); + let med = median(&mut s[a..=b].to_vec()); + if peak <= 0.0 || peak < 2.0 * med { + continue; + } + let (_, i_max) = vmax(&s, a, b + 1); + events.push((i_max as f64, is_tic)); } } - let _ = wf_size; } let detected_bph = 2.0 * 3600.0 * sr as f64 / period; diff --git a/crates/regulator-gui/src/main.rs b/crates/regulator-gui/src/main.rs index 8599eba..bc97ca6 100644 --- a/crates/regulator-gui/src/main.rs +++ b/crates/regulator-gui/src/main.rs @@ -50,6 +50,8 @@ struct Params { calibration: f64, /// Calibration came from the passive clock estimate, not a quartz run. cal_auto: bool, + /// Live clock-calibration estimate and uncertainty while converging. + cal_live: Option<(f64, f64)>, cal_progress: String, } @@ -63,13 +65,31 @@ impl Default for Params { calibrating: false, calibration: 0.0, cal_auto: false, + cal_live: None, cal_progress: String::new(), } } } -/// Shared ring buffer of live microphone samples (if capture is available). -type Ring = Arc>>; +/// Shared ring buffer of live microphone samples (if capture is available), +/// with a monotonic total so window start times never go backwards. +struct MicBuf { + data: Vec, + total: u64, +} + +#[cfg(feature = "audio")] +impl MicBuf { + fn push(&mut self, s: f32, cap: usize) { + self.data.push(s); + self.total += 1; + if self.data.len() > cap { + self.data.drain(..cap / 2); + } + } +} + +type Ring = Arc>; struct RegulatorApp { result: Option, @@ -98,6 +118,7 @@ impl RegulatorApp { let block = (BLOCK_SECONDS * SAMPLE_RATE as f64) as usize; let mut start = 0usize; let mut win_start_s = 0.0f64; + let mut demo_total_s = 0.0f64; let mut last_event_s = 0.0f64; let mut trace: Vec = Vec::new(); let mut ts: u64 = 0; @@ -109,12 +130,12 @@ impl RegulatorApp { if p.calibrating { if let Some(ring) = &ring { let buf = ring.lock().unwrap_or_else(|e| e.into_inner()); - ts += buf.len().saturating_sub(last_len) as u64; - last_len = buf.len(); - if buf.len() >= block && cal_cooldown == 0 { + ts += buf.total.saturating_sub(last_len as u64) as u64; + last_len = buf.total as usize; + if buf.data.len() >= block && cal_cooldown == 0 { let cal_an = Analyzer::for_calibration(SAMPLE_RATE); - let window_start_ts = ts.saturating_sub(buf.len() as u64); - match cal_state.add_block(&cal_an, &buf[buf.len() - block..], window_start_ts) { + let window_start_ts = ts.saturating_sub(buf.data.len() as u64); + match cal_state.add_block(&cal_an, &buf.data[buf.data.len() - block..], window_start_ts) { CalStatus::Done(cal) => { p.calibration = cal; p.calibrating = false; @@ -149,9 +170,11 @@ impl RegulatorApp { // Passive clock calibration: apply once the sample-count // regression has converged (unless a quartz calibration // has set the value manually). - if let Some(err) = clock_cal.lock().unwrap_or_else(|e| e.into_inner()).converged(0.25) { + let cc_est = clock_cal.lock().unwrap_or_else(|e| e.into_inner()).estimate(); + if let Some((err, unc)) = cc_est { let mut p = params_arc.lock().unwrap_or_else(|e| e.into_inner()); - if p.cal_auto || p.calibration == 0.0 { + p.cal_live = Some((err, unc)); + if unc <= 0.25 && (p.cal_auto || p.calibration == 0.0) { p.calibration = err; p.cal_auto = true; } @@ -166,7 +189,8 @@ impl RegulatorApp { let res = if p2.demo { let end = (start + block).min(demo_samples.len()); let r = analyzer.analyze(&demo_samples[start..end]); - win_start_s = start as f64 / SAMPLE_RATE as f64; + win_start_s = demo_total_s; + demo_total_s += (end - start) as f64 / SAMPLE_RATE as f64; if end == demo_samples.len() { start = 0; } else { @@ -175,9 +199,9 @@ impl RegulatorApp { r } else if let Some(ring) = &ring { let buf = ring.lock().unwrap_or_else(|e| e.into_inner()); - if buf.len() >= block { - win_start_s = (buf.len() - block) as f64 / SAMPLE_RATE as f64; - analyzer.analyze(&buf[buf.len() - block..]) + if buf.data.len() >= block { + win_start_s = (buf.total - block as u64) as f64 / SAMPLE_RATE as f64; + analyzer.analyze(&buf.data[buf.data.len() - block..]) } else { None } @@ -302,6 +326,14 @@ impl eframe::App for RegulatorApp { if p.calibration != 0.0 { let tag = if p.cal_auto { " auto" } else { "" }; strip_value(ui, "cal", &Some(format!("{:+.1} s/d{tag}", p.calibration))); + } else if let Some((err, unc)) = p.cal_live { + ui.label( + egui::RichText::new(format!("cal {err:+.1} ±{unc:.1}")) + .monospace() + .size(14.0) + .color(egui::Color32::from_rgb(235, 200, 90)), + ); + ui.add_space(12.0); } if p.calibrating { ui.label( @@ -489,23 +521,29 @@ fn draw_waveform(ui: &mut egui::Ui, result: &Option, height: f32) } fn main() -> anyhow::Result<()> { + let clock_cal: Arc> = Arc::new(Mutex::new(ClockCal::new(SAMPLE_RATE))); + // Live capture (if built with the audio feature); a relay thread moves - // samples into a shared ring buffer the worker reads. + // samples into a shared ring buffer the worker reads, feeding the + // clock calibration as it goes. let ring: Option = { #[cfg(feature = "audio")] { let (tx, rx) = mpsc::channel::(); match audio::spawn_capture(tx) { Ok(()) => { - let ring: Ring = Arc::new(Mutex::new(Vec::new())); + let ring: Ring = Arc::new(Mutex::new(MicBuf { data: Vec::new(), total: 0 })); let r = ring.clone(); + let cc = clock_cal.clone(); std::thread::spawn(move || { - let block = (BLOCK_SECONDS * SAMPLE_RATE as f64) as usize; + let cap = (BLOCK_SECONDS * SAMPLE_RATE as f64) as usize * 2; + let mut batch = 0usize; while let Ok(s) = rx.recv() { - let mut buf = r.lock().unwrap_or_else(|e| e.into_inner()); - buf.push(s); - if buf.len() > block * 2 { - buf.drain(..block); + r.lock().unwrap_or_else(|e| e.into_inner()).push(s, cap); + batch += 1; + if batch >= 2048 { + cc.lock().unwrap_or_else(|e| e.into_inner()).add(batch); + batch = 0; } } }); @@ -523,8 +561,6 @@ fn main() -> anyhow::Result<()> { } }; - let clock_cal: Arc> = Arc::new(Mutex::new(ClockCal::new(SAMPLE_RATE))); - let native = eframe::NativeOptions { viewport: egui::ViewportBuilder::default() .with_inner_size([900.0, 520.0]) From ed5ab9c39fa79bb12dbf3350ee8ca16d568c2676 Mon Sep 17 00:00:00 2001 From: borosf Date: Tue, 17 Nov 2026 20:51:38 +0000 Subject: [PATCH 16/20] Fix GUI freeze: no locks held across analysis, panel order, O(n) trace draw - Worker copies the 4 s window out of the ring buffer under the lock (sub-millisecond) and analyzes it unlocked, so the capture relay and UI never stall behind analysis - One Analyzer is reused across iterations, keeping the FFT plan cache warm instead of rebuilding 350k-point plans every 200 ms - Export button moved into the top readout bar; the egui panel added after CentralPanel is gone (panels must precede the central panel) - draw_trace hoists the newest-timestamp lookup out of the per-point loop (was O(n^2) per frame) Co-authored-by: borosf --- crates/regulator-gui/src/main.rs | 58 +++++++++++++++++--------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/crates/regulator-gui/src/main.rs b/crates/regulator-gui/src/main.rs index bc97ca6..12500e8 100644 --- a/crates/regulator-gui/src/main.rs +++ b/crates/regulator-gui/src/main.rs @@ -125,6 +125,7 @@ impl RegulatorApp { let mut last_len = 0usize; let mut cal_state = CalibrationState::new(); let mut cal_cooldown = 0u32; + let mut analyzer = Analyzer::new(SAMPLE_RATE); loop { let mut p = params_arc.lock().unwrap_or_else(|e| e.into_inner()); if p.calibrating { @@ -181,7 +182,6 @@ impl RegulatorApp { } drop(p); let p2 = params_arc.lock().unwrap_or_else(|e| e.into_inner()).clone(); - let mut analyzer = Analyzer::new(SAMPLE_RATE); analyzer.bph = p2.bph; analyzer.lift_angle = p2.lift_angle; analyzer.noise_suppressor = p2.noise_suppressor; @@ -198,12 +198,23 @@ impl RegulatorApp { } r } else if let Some(ring) = &ring { - let buf = ring.lock().unwrap_or_else(|e| e.into_inner()); - if buf.data.len() >= block { - win_start_s = (buf.total - block as u64) as f64 / SAMPLE_RATE as f64; - analyzer.analyze(&buf.data[buf.data.len() - block..]) - } else { - None + // Copy the window out under the lock (a fraction of a + // millisecond), then analyze without holding it so the + // capture relay never stalls. + let window = { + let buf = ring.lock().unwrap_or_else(|e| e.into_inner()); + if buf.data.len() >= block { + Some((buf.total, buf.data[buf.data.len() - block..].to_vec())) + } else { + None + } + }; + match window { + Some((total, w)) => { + win_start_s = (total - block as u64) as f64 / SAMPLE_RATE as f64; + analyzer.analyze(&w) + } + None => None, } } else { None @@ -295,6 +306,17 @@ impl eframe::App for RegulatorApp { ui.label(egui::RichText::new("s/d").monospace().size(16.0).color(egui::Color32::GRAY)); ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { let p = self.params.lock().unwrap_or_else(|e| e.into_inner()).clone(); + if ui.button("export").clicked() { + self.last_export = chart::export_chart(&self.trace, &self.result, &self.params); + } + if let Some(path) = &self.last_export { + ui.label( + egui::RichText::new(format!("saved {path}")) + .monospace() + .size(12.0) + .color(egui::Color32::from_rgb(120, 220, 120)), + ); + } ui.label( egui::RichText::new(format!( "{} {}", @@ -408,25 +430,6 @@ impl eframe::App for RegulatorApp { } }); - // Export needs the trace; run it from a small panel-level button on - // the top bar, right side. - egui::TopBottomPanel::top("export").show(ctx, |ui| { - ui.add_space(2.0); - ui.horizontal(|ui| { - if ui.button("export chart").clicked() { - self.last_export = chart::export_chart(&self.trace, &self.result, &self.params); - } - if let Some(path) = &self.last_export { - ui.label( - egui::RichText::new(format!("saved {path}")) - .monospace() - .size(12.0) - .color(egui::Color32::from_rgb(120, 220, 120)), - ); - } - }); - }); - ctx.request_repaint_after(Duration::from_millis(200)); } } @@ -468,8 +471,9 @@ fn draw_trace(ui: &mut egui::Ui, trace: &[TracePoint]) { } let bottom = rect.bottom(); let h = rect.height(); + let t_end = trace.last().map(|q| q.t).unwrap_or(0.0); for p in trace { - let age = trace.last().map(|q| q.t).unwrap_or(0.0) - p.t; + let age = t_end - p.t; if age > 60.0 { continue; } From 8b2916c58e2394040c5e437ddffa7d44a5053ce5 Mon Sep 17 00:00:00 2001 From: borosf Date: Tue, 17 Nov 2026 20:53:08 +0000 Subject: [PATCH 17/20] Fix deadlock: worker re-locked the params mutex it already held The clock-calibration block locked params a second time while the outer guard was still held; std::sync::Mutex is not reentrant, so the worker hung forever the moment the clock estimate first became available (~2 s after the mic started), taking the UI with it. Reuse the held guard instead. Co-authored-by: borosf --- crates/regulator-gui/src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/regulator-gui/src/main.rs b/crates/regulator-gui/src/main.rs index 12500e8..0c343d7 100644 --- a/crates/regulator-gui/src/main.rs +++ b/crates/regulator-gui/src/main.rs @@ -173,7 +173,8 @@ impl RegulatorApp { // has set the value manually). let cc_est = clock_cal.lock().unwrap_or_else(|e| e.into_inner()).estimate(); if let Some((err, unc)) = cc_est { - let mut p = params_arc.lock().unwrap_or_else(|e| e.into_inner()); + // `p` is already held here; re-locking params would + // deadlock (std Mutex is not reentrant). p.cal_live = Some((err, unc)); if unc <= 0.25 && (p.cal_auto || p.calibration == 0.0) { p.calibration = err; From d184d64139c51055f49daeea82c3e3741cb880c6 Mon Sep 17 00:00:00 2001 From: borosf Date: Tue, 17 Nov 2026 20:55:49 +0000 Subject: [PATCH 18/20] Demote clock calibration to informational; quartz is authoritative The clock-based estimate measures the sound card against the local high-resolution timer, whose own drift is unknown and can be tens of s/day on some hardware (observed: -31.9 vs tg's quartz -7.5, a ~28 ppm local timer drift). It is no longer auto-applied: the bottom strip shows it as 'clock ...' in gray, and a side-panel button lets the user apply it explicitly. The quartz calibration remains the authoritative correction, matching tg. Co-authored-by: borosf --- crates/regulator-gui/src/main.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/crates/regulator-gui/src/main.rs b/crates/regulator-gui/src/main.rs index 0c343d7..3039887 100644 --- a/crates/regulator-gui/src/main.rs +++ b/crates/regulator-gui/src/main.rs @@ -174,12 +174,13 @@ impl RegulatorApp { let cc_est = clock_cal.lock().unwrap_or_else(|e| e.into_inner()).estimate(); if let Some((err, unc)) = cc_est { // `p` is already held here; re-locking params would - // deadlock (std Mutex is not reentrant). + // deadlock (std Mutex is not reentrant). The clock + // estimate is informational only: it measures the + // sound card against the local timer, whose own + // drift is unknown (tens of s/day on some hardware), + // so it is never auto-applied. The quartz calibration + // is the authoritative correction. p.cal_live = Some((err, unc)); - if unc <= 0.25 && (p.cal_auto || p.calibration == 0.0) { - p.calibration = err; - p.cal_auto = true; - } } drop(p); let p2 = params_arc.lock().unwrap_or_else(|e| e.into_inner()).clone(); @@ -351,10 +352,10 @@ impl eframe::App for RegulatorApp { strip_value(ui, "cal", &Some(format!("{:+.1} s/d{tag}", p.calibration))); } else if let Some((err, unc)) = p.cal_live { ui.label( - egui::RichText::new(format!("cal {err:+.1} ±{unc:.1}")) + egui::RichText::new(format!("clock {err:+.1} ±{unc:.1}")) .monospace() .size(14.0) - .color(egui::Color32::from_rgb(235, 200, 90)), + .color(egui::Color32::from_gray(140)), ); ui.add_space(12.0); } @@ -412,6 +413,12 @@ impl eframe::App for RegulatorApp { p.calibrating = true; p.cal_progress.clear(); } + if let Some((err, unc)) = p.cal_live { + if unc < 2.0 && ui.button(format!("use clock est {err:+.1}")).clicked() { + p.calibration = err; + p.cal_auto = true; + } + } ui.add_space(10.0); ui.separator(); ui.add_space(6.0); From 63df687e44e1e55a762552f08edb21b709ad979e Mon Sep 17 00:00:00 2001 From: borosf Date: Tue, 17 Nov 2026 21:00:15 +0000 Subject: [PATCH 19/20] Faster calibration: 0.2 s/d gate, editable cal field, persisted settings - Quartz calibration accepts at +/-0.2 s/d confidence (tg gates at 0.1), roughly halving convergence; the 900-sample count is only the worst-case cap, the early-exit fit typically finishes in a minute or two - Calibration is a typed, editable field in the side panel: a value measured once (here or in tg) can be entered directly - Settings (beat rate, lift angle, calibration, noise suppressor) now persist to %APPDATA%/regulator/config.txt and reload at startup, so calibration survives restarts; tg's startup 'auto cal' only catches device-forced rate mismatches and is ~0 in practice, so there was nothing faster to inherit Co-authored-by: borosf --- crates/regulator-core/src/calibrate.rs | 4 +- crates/regulator-gui/src/main.rs | 86 +++++++++++++++++++++++--- 2 files changed, 82 insertions(+), 8 deletions(-) diff --git a/crates/regulator-core/src/calibrate.rs b/crates/regulator-core/src/calibrate.rs index 279a2af..c76521d 100644 --- a/crates/regulator-core/src/calibrate.rs +++ b/crates/regulator-core/src/calibrate.rs @@ -147,7 +147,9 @@ impl CalibrationState { /// sound card's apparent rate error. fn fit(points: &[(f64, f64)]) -> Result { let (cal, delta) = Self::fit_with_delta(points)?; - if delta >= 0.1 { + // tg gates at 0.1 s/d; 0.2 is still far finer than the rate readout + // and roughly halves the convergence time. + if delta >= 0.2 { return Err(()); } Ok(cal) diff --git a/crates/regulator-gui/src/main.rs b/crates/regulator-gui/src/main.rs index 3039887..5e9ca9f 100644 --- a/crates/regulator-gui/src/main.rs +++ b/crates/regulator-gui/src/main.rs @@ -53,6 +53,65 @@ struct Params { /// Live clock-calibration estimate and uncertainty while converging. cal_live: Option<(f64, f64)>, cal_progress: String, + /// Settings changed since the last save. + dirty: bool, +} + +impl Params { + fn config_path() -> std::path::PathBuf { + let dir = if let Ok(a) = std::env::var("APPDATA") { + std::path::PathBuf::from(a).join("regulator") + } else if let Ok(x) = std::env::var("XDG_CONFIG_HOME") { + std::path::PathBuf::from(x).join("regulator") + } else if let Ok(h) = std::env::var("HOME") { + std::path::PathBuf::from(h).join(".config").join("regulator") + } else { + std::path::PathBuf::from(".") + }; + std::fs::create_dir_all(&dir).ok(); + dir.join("config.txt") + } + + fn load() -> Self { + let mut p = Params::default(); + if let Ok(text) = std::fs::read_to_string(Self::config_path()) { + for line in text.lines() { + let Some((k, v)) = line.split_once('=') else { continue }; + match k.trim() { + "bph" => { + if let Ok(n) = v.trim().parse() { + p.bph = n; + } + } + "lift_angle" => { + if let Ok(n) = v.trim().parse() { + p.lift_angle = n; + } + } + "calibration" => { + if let Ok(n) = v.trim().parse() { + p.calibration = n; + p.cal_auto = true; + } + } + "noise_suppressor" => p.noise_suppressor = v.trim() == "true", + _ => {} + } + } + } + p + } + + fn save(&self) { + let text = format!( + "bph={}\nlift_angle={:.1}\ncalibration={:.3}\nnoise_suppressor={}\n", + self.bph, + self.lift_angle, + self.calibration, + self.noise_suppressor + ); + let _ = std::fs::write(Self::config_path(), text); + } } impl Default for Params { @@ -67,6 +126,7 @@ impl Default for Params { cal_auto: false, cal_live: None, cal_progress: String::new(), + dirty: false, } } } @@ -102,7 +162,7 @@ struct RegulatorApp { impl RegulatorApp { fn new(ring: Option, clock_cal: Arc>) -> Self { - let params = Arc::new(Mutex::new(Params::default())); + let params = Arc::new(Mutex::new(Params::load())); let (tx, rx) = mpsc::channel::(); let params_arc = params.clone(); let clock_cal = clock_cal; @@ -140,6 +200,8 @@ impl RegulatorApp { CalStatus::Done(cal) => { p.calibration = cal; p.calibrating = false; + p.cal_auto = true; + p.dirty = true; p.cal_progress = format!("{cal:+.1} s/d"); } CalStatus::Failed => { @@ -182,6 +244,10 @@ impl RegulatorApp { // is the authoritative correction. p.cal_live = Some((err, unc)); } + if p.dirty { + p.save(); + p.dirty = false; + } drop(p); let p2 = params_arc.lock().unwrap_or_else(|e| e.into_inner()).clone(); analyzer.bph = p2.bph; @@ -379,6 +445,7 @@ impl eframe::App for RegulatorApp { ui.add_space(6.0); ui.style_mut().override_font_id = Some(egui::FontId::monospace(13.0)); let mut p = self.params.lock().unwrap_or_else(|e| e.into_inner()); + let before = (p.bph, p.lift_angle, p.calibration, p.noise_suppressor, p.demo); ui.label(egui::RichText::new("BEAT RATE").small().weak()); egui::ComboBox::from_id_salt("bph") .selected_text(if p.bph == 0 { "auto".into() } else { p.bph.to_string() }) @@ -403,6 +470,13 @@ impl eframe::App for RegulatorApp { ui.add_space(6.0); ui.checkbox(&mut p.noise_suppressor, "noise suppressor"); ui.checkbox(&mut p.demo, "demo signal"); + ui.add_space(6.0); + ui.label(egui::RichText::new("CALIBRATION s/d").small().weak()); + ui.add( + egui::DragValue::new(&mut p.calibration) + .speed(0.1) + .range(-100.0..=100.0), + ); ui.add_space(10.0); if p.calibrating { if ui.button("stop calibration").clicked() { @@ -413,13 +487,11 @@ impl eframe::App for RegulatorApp { p.calibrating = true; p.cal_progress.clear(); } - if let Some((err, unc)) = p.cal_live { - if unc < 2.0 && ui.button(format!("use clock est {err:+.1}")).clicked() { - p.calibration = err; - p.cal_auto = true; - } - } ui.add_space(10.0); + let after = (p.bph, p.lift_angle, p.calibration, p.noise_suppressor, p.demo); + if after != before { + p.dirty = true; + } ui.separator(); ui.add_space(6.0); ui.label(egui::RichText::new("WAVEFORM").small().weak()); From 147a07e26add6ee97be55633f56a4f27b8316eba Mon Sep 17 00:00:00 2001 From: borosf Date: Tue, 17 Nov 2026 21:10:41 +0000 Subject: [PATCH 20/20] Horizontal trace, JPEG result sheet, project files (CI, release, README, CONTRIBUTING) - Trace reworked to tg's orientation: time left-to-right, phase error vertical; SVG export matches. - New branded JPEG result sheet (regulator-gui/src/sheet.rs) with a hand-drawn 5x7 bitmap font, readouts, trace and timestamp; exported alongside SVG/CSV. Unit-tested. - snap_bph now includes 19800 and 43200 (auto mode previously snapped a 19800 bph watch to the wrong standard). - Event location calls vmax once instead of twice per tick. - README rewritten (GUI is the main frontend, TUI marked experimental), screenshot from the sheet renderer. - CI (ubuntu+windows full, headless build), release workflow attaching GUI binaries on v* tags, CONTRIBUTING.md, bug report template. Co-authored-by: borosf --- .github/ISSUE_TEMPLATE/bug_report.md | 23 +++ .github/workflows/ci.yml | 31 +++ .github/workflows/release.yml | 51 +++++ .gitignore | 1 + CONTRIBUTING.md | 43 ++++ Cargo.lock | 3 + README.md | 120 +++++++---- crates/regulator-core/src/analyze.rs | 7 +- crates/regulator-gui/Cargo.toml | 1 + crates/regulator-gui/src/chart.rs | 19 +- crates/regulator-gui/src/main.rs | 34 +-- crates/regulator-gui/src/sheet.rs | 299 +++++++++++++++++++++++++++ crates/regulator-tui/Cargo.toml | 2 +- docs/screenshot.jpg | Bin 0 -> 60657 bytes 14 files changed, 561 insertions(+), 73 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml create mode 100644 CONTRIBUTING.md create mode 100644 crates/regulator-gui/src/sheet.rs create mode 100644 docs/screenshot.jpg diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..d73dc86 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,23 @@ +--- +name: Bug report +about: Something doesn't measure, display, or build correctly +title: "" +labels: bug +assignees: "" +--- + +**Environment** +- OS: +- build: `cargo run -p regulator-gui` (debug/release), audio feature on/off + +**Watch / setup** +- beat rate (bph): +- lift angle: +- microphone type: + +**What happened** + +**What you expected** + +**Recording** +If possible, attach a WAV recording of the watch — it makes DSP issues reproducible. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..2c83859 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +name: CI + +on: + push: + branches: [master, main] + pull_request: + +jobs: + test: + name: Test (${{ matrix.os }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest] + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - name: Build (with audio) + run: cargo build --all-targets + - name: Test + run: cargo test --workspace + + build-headless: + name: Build without audio stack + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - run: cargo build --no-default-features + - run: cargo test --workspace --no-default-features diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..e13f6ff --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,51 @@ +name: Release + +on: + push: + tags: ["v*"] + +permissions: + contents: write + +jobs: + binaries: + name: Build binaries + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: windows-latest + target: x86_64-pc-windows-msvc + artifact: regulator-gui-windows-x86_64.zip + - os: ubuntu-latest + target: x86_64-unknown-linux-gnu + artifact: regulator-gui-linux-x86_64.tar.gz + - os: macos-latest + target: aarch64-apple-darwin + artifact: regulator-gui-macos-aarch64.tar.gz + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + - name: Build release binary + run: cargo build --release --target ${{ matrix.target }} -p regulator-gui + - name: Package + shell: bash + run: | + cd target/${{ matrix.target }}/release + if [[ "${{ matrix.os }}" == windows-latest ]]; then + 7z a ../../../${{ matrix.artifact }} regulator-gui.exe + else + tar czf ../../../${{ matrix.artifact }} regulator-gui + fi + - uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.artifact }} + path: ${{ matrix.artifact }} + + - name: Upload to release + uses: softprops/action-gh-release@v2 + with: + files: ${{ matrix.artifact }} diff --git a/.gitignore b/.gitignore index 16a3015..cb149a7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .* !.gitignore +!.github !.travis.yml !.valgrind.supp diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..327a07e --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,43 @@ +# Contributing to regulator + +Thanks for your interest in improving regulator! + +## Getting started + +```sh +git clone https://github.com/borosf/regulator.git +cd regulator +cargo test --workspace # everything should pass before you start +cargo run -p regulator-gui # demo mode, no hardware needed +``` + +## Ground rules + +- **License**: contributions are accepted under GPLv2, the project's + license. By submitting a pull request you agree your work is licensed + accordingly. +- **Scope of the core**: `regulator-core` must stay free of I/O and + platform dependencies. Audio capture, files and UI belong in the + frontend crates. +- **Tests**: the DSP core is unit-tested against a synthetic watch + generator (`crates/regulator-core/src/signal.rs`). If you change the + analysis, add or adjust a synthetic-signal test that demonstrates the + behavior. +- **Style**: follow the existing code style; no new dependencies unless + they're clearly justified. + +## Bug reports + +Open an issue and include: + +- your OS and how you built (release/debug, audio feature), +- the movement's beat rate and lift angle, +- what you expected vs. what happened, +- if possible, a recording of the watch (WAV preferred) — recordings make + DSP bugs reproducible. + +## Pull requests + +Keep PRs focused: one change per PR. Describe what changed and why, and +list the commands you ran to verify (`cargo test --workspace`, +`cargo build --no-default-features`). diff --git a/Cargo.lock b/Cargo.lock index 902b3bf..8cc90e0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1751,6 +1751,8 @@ dependencies = [ "num-traits", "png", "tiff", + "zune-core", + "zune-jpeg", ] [[package]] @@ -2941,6 +2943,7 @@ dependencies = [ "anyhow", "cpal", "eframe", + "image", "regulator-core", ] diff --git a/README.md b/README.md index 7a2ef8c..8b2f623 100644 --- a/README.md +++ b/README.md @@ -1,63 +1,97 @@ # regulator -A modern fork of [tg](https://github.com/xyzzy42/tg) — open-source watch -timing software for mechanical movements. regulator captures the ticking of -a watch with a microphone, analyzes the tick train, and reports the rate -error (s/day), balance amplitude, and beat error, with a cleaner interface -and a restructured, testable analysis core. - -## Status - -Early-stage Rust rewrite. The original C code (GPLv2) is kept at the root of -the repository as the reference implementation and for its build system; see -[docs/original-readme.md](docs/original-readme.md) for the original project's -documentation, including the microphone calibration procedure. - -## Layout - -- `crates/regulator-core` — pure DSP: noise suppression, FFT-based period - detection, waveform folding, rate/amplitude/beat-error computation. No I/O, - fully unit-tested against a synthetic watch signal generator. -- `crates/regulator-tui` — the terminal interface (ratatui), with live - microphone capture (cpal) and a `--demo` mode driven by a synthetic watch. -- `crates/regulator-gui` — the graphical interface (egui): big readouts, - waveform plot, settings panel; same demo/microphone sources. +A modern, free-software watch timing machine — a Rust rewrite of +[tg](https://github.com/xyzzy42/tg), the open-source mechanical-watch +timing program. Put a watch on a microphone and regulator measures the +rate error, balance amplitude, and beat error, live, with a clean +instrument-style interface. + +![screenshot](docs/screenshot.jpg) + +## Features + +- **Live measurement** of rate (s/day), amplitude (degrees) and beat + error (ms), with each value reported independently — a measurement that + fails is shown blank instead of breaking the whole readout. +- **Auto beat-rate detection** with snapping to standard rates + (12000–43200 bph, including 36000 and 43200 high-beat movements). +- **Strip chart trace**: time runs left to right, phase error moves up + and down, tic and toc in different colors — the classic timegrapher + view. +- **Sound-card calibration** against a quartz watch ticking once per + second, with live progress feedback and an early exit once the estimate + converges. +- **Export**: chart as SVG, raw trace as CSV, and a branded JPEG result + sheet with all readouts, ready to attach to a service record. +- **Demo mode**: a synthetic watch drives every feature with no hardware. ## Build & run ```sh -cargo run -p regulator-tui -- --demo # synthetic watch, no hardware needed -cargo run -p regulator-tui # live microphone (needs ALSA/CoreAudio/WASAPI) -cargo run -p regulator-gui # graphical interface (demo mode by default) +cargo run -p regulator-gui # graphical interface (demo mode by default) ``` -Useful keys: `←/→` beat rate preset (auto, 18000…36000 bph), `+/-` lift -angle, `n` noise suppressor, `q` quit. +Uncheck "demo signal" in the side panel to analyze the microphone. On +Linux you may need `libasound2-dev`; on Windows and macOS it just works. To build on a system without an audio stack: ```sh cargo build --no-default-features +cargo test ``` +## Using it + +1. Rest the watch on a microphone (a piezo contact mic or the watch + directly on a laptop mic both work). +2. Pick the beat rate, or leave it on auto. +3. Set the lift angle for the movement (52° is a safe default; check the + movement's spec). +4. Read the rate. The trace confirms it: a rising drift means fast, a + falling drift means slow, two horizontal bands mean beat error. +5. To calibrate the sound card, click "calibrate (quartz)" and place a + quartz watch (exactly 1 tick/s) on the microphone for a minute or two. + The correction persists between runs. + +## Layout + +- `crates/regulator-core` — pure DSP: filters, FFT-based period + detection, waveform folding, rate/amplitude/beat-error computation, + calibration. No I/O, fully unit-tested against a synthetic watch. +- `crates/regulator-gui` — the graphical interface (egui). **This is the + main frontend.** +- `crates/regulator-tui` — the terminal interface (ratatui). **Experimental:** + it lags behind the GUI in features and polish and may be removed or + reworked. + ## Improvements over tg -- Partial results: rate, beat error and amplitude are reported independently; - a missing measurement is shown blank rather than failing the whole readout. -- Sub-sample period refinement (parabolic interpolation of the autocorrelation - peak) for finer rate resolution than tg's integer-sample estimate. -- Robust amplitude estimation: the impulse duration is measured directly as - the region above 20% of the tic/toc peak, instead of tg's escalating - threshold heuristic. -- Cached FFT plans and reused scratch buffers: plans are built once per - block length instead of per call. - -## Portability - -The core crate has no platform dependencies (pure Rust, no C). Both -frontends use cpal for capture, which works on Linux (ALSA), macOS -(CoreAudio) and Windows (WASAPI); without the `audio` feature they build -anywhere Rust does. +- Partial results: rate, beat error and amplitude are reported + independently; a missing measurement is blank, not fatal. +- Sub-sample period refinement (parabolic interpolation of the + autocorrelation peak) for finer rate resolution. +- Cached FFT plans and reused scratch buffers. +- Faster calibration: the quartz fit exits early once the estimate + converges instead of always collecting the full 900-second window. +- Modern cross-platform GUI with a result-sheet export. + +The original C code (GPLv2) is kept at the root of the repository as the +reference implementation; see [docs/original-readme.md](docs/original-readme.md) +for the original project's documentation. + +## Known limitations + +- The passive clock estimate (sound card vs. local timer) is + informational only: many machines' timers drift by tens of s/day, so + only the quartz calibration is applied to measurements. +- Tick events are located by peak search around expected positions, not + template matching; very noisy recordings may drop events. + +## Contributing + +See [CONTRIBUTING.md](CONTRIBUTING.md). Bug reports and feature requests +are welcome via the issue tracker. ## License diff --git a/crates/regulator-core/src/analyze.rs b/crates/regulator-core/src/analyze.rs index adc2970..884e88d 100644 --- a/crates/regulator-core/src/analyze.rs +++ b/crates/regulator-core/src/analyze.rs @@ -65,7 +65,9 @@ impl FftCache { /// Snap a detected beats-per-hour value to the nearest standard beat rate. fn snap_bph(detected: f64) -> f64 { - const STANDARDS: [f64; 7] = [12000.0, 14400.0, 18000.0, 21600.0, 25200.0, 28800.0, 36000.0]; + const STANDARDS: [f64; 9] = [ + 12000.0, 14400.0, 18000.0, 19800.0, 21600.0, 25200.0, 28800.0, 36000.0, 43200.0, + ]; STANDARDS .iter() .copied() @@ -158,12 +160,11 @@ impl Analyzer { } // Only accept a peak that actually rises above the // local noise floor; otherwise the tick was missed. - let (peak, _) = vmax(&s, a, b + 1); + let (peak, i_max) = vmax(&s, a, b + 1); let med = median(&mut s[a..=b].to_vec()); if peak <= 0.0 || peak < 2.0 * med { continue; } - let (_, i_max) = vmax(&s, a, b + 1); events.push((i_max as f64, is_tic)); } } diff --git a/crates/regulator-gui/Cargo.toml b/crates/regulator-gui/Cargo.toml index c1536ad..9cdf644 100644 --- a/crates/regulator-gui/Cargo.toml +++ b/crates/regulator-gui/Cargo.toml @@ -18,4 +18,5 @@ audio = ["dep:cpal"] regulator-core = { path = "../regulator-core" } eframe = "0.33" anyhow = "1" +image = { version = "0.25", default-features = false, features = ["jpeg"] } cpal = { version = "0.15", optional = true } diff --git a/crates/regulator-gui/src/chart.rs b/crates/regulator-gui/src/chart.rs index cff5aae..bd082c8 100644 --- a/crates/regulator-gui/src/chart.rs +++ b/crates/regulator-gui/src/chart.rs @@ -116,8 +116,8 @@ pub fn export_chart( const WINDOW_MS: f64 = 25.0; let top = 60.0; let chart_h = H - top - 10.0; - let cx = W / 2.0; - let half_w = W / 2.0 - 20.0; + let cy = top + chart_h / 2.0; + let half_h = chart_h / 2.0; let wrap = |ms: f64| { ((ms + WINDOW_MS) % (2.0 * WINDOW_MS) + 2.0 * WINDOW_MS) % (2.0 * WINDOW_MS) - WINDOW_MS }; @@ -137,27 +137,26 @@ pub fn export_chart( p.lift_angle ); for ms in [-20.0, -10.0, 0.0, 10.0, 20.0] { - let x = cx + wrap(ms) / WINDOW_MS * half_w; + let y = cy - wrap(ms) / WINDOW_MS * half_h; let color = if ms == 0.0 { "#3a3a3a" } else { "#1c1c1c" }; let _ = writeln!( svg, - "", - top + chart_h + "", + W - 12.0 ); } let t_end = trace.last().map(|t| t.t).unwrap_or(0.0); for t in trace.iter().filter(|t| t_end - t.t <= 60.0) { - let y = top + chart_h - (t_end - t.t) / 60.0 * chart_h; - let x = cx + wrap(t.phase_ms) / WINDOW_MS * half_w; + let x = W - 12.0 - (t_end - t.t) / 60.0 * (W - 24.0); + let y = cy - wrap(t.phase_ms) / WINDOW_MS * half_h; let color = if t.tic { "#8ce68c" } else { "#f08cf0" }; let _ = writeln!( svg, - "", - x - 1.5, - x + 1.5 + "" ); } let _ = writeln!(svg, ""); std::fs::write(format!("{base}.svg"), svg).ok()?; + crate::sheet::export_jpeg(&base, trace, result, params)?; Some(base) } diff --git a/crates/regulator-gui/src/main.rs b/crates/regulator-gui/src/main.rs index 5e9ca9f..1865d2c 100644 --- a/crates/regulator-gui/src/main.rs +++ b/crates/regulator-gui/src/main.rs @@ -5,6 +5,7 @@ #[cfg(feature = "audio")] mod audio; mod chart; +mod sheet; use eframe::egui; use regulator_core::{CalStatus, CalibrationState, ClockCal, Analyzer, SyntheticWatch, TimingResult}; @@ -521,51 +522,52 @@ fn strip_value(ui: &mut egui::Ui, name: &str, value: &Option) { ui.add_space(12.0); } -/// The strip chart: each tick event is a short dash at its phase error; -/// time scrolls downward. Rate error drifts the dashes sideways, beat -/// error splits tic/toc into two columns, noise widens the scatter. +/// The strip chart: time runs left to right, phase error moves up and +/// down (tg's orientation). Rate error shows as a rising or falling drift, +/// beat error splits tic/toc into two horizontal bands, noise widens the +/// scatter. fn draw_trace(ui: &mut egui::Ui, trace: &[TracePoint]) { let (resp, painter) = ui.allocate_painter(ui.available_size(), egui::Sense::hover()); let rect = resp.rect; painter.rect_filled(rect, 0.0, egui::Color32::from_rgb(10, 11, 12)); // Phase-error window: +/- 25 ms, ticks wrap into it. const WINDOW_MS: f64 = 25.0; - let cx = rect.center().x; - let half_w = rect.width() / 2.0 - 8.0; - let to_x = |ms: f64| { + const SPAN_S: f64 = 60.0; + let cy = rect.center().y; + let half_h = rect.height() / 2.0 - 8.0; + let to_y = |ms: f64| { let wrapped = ((ms + WINDOW_MS) % (2.0 * WINDOW_MS) + 2.0 * WINDOW_MS) % (2.0 * WINDOW_MS) - WINDOW_MS; - cx + (wrapped / WINDOW_MS * half_w as f64) as f32 + cy - (wrapped / WINDOW_MS * half_h as f64) as f32 }; - // Grid: center line plus 10 ms steps. + // Grid: center line plus 10 ms steps, horizontal like tg's display. for ms in [-20.0, -10.0, 0.0, 10.0, 20.0] { - let x = to_x(ms); + let y = to_y(ms); let color = if ms == 0.0 { egui::Color32::from_gray(52) } else { egui::Color32::from_gray(28) }; painter.line_segment( - [egui::pos2(x, rect.top()), egui::pos2(x, rect.bottom())], + [egui::pos2(rect.left(), y), egui::pos2(rect.right(), y)], egui::Stroke::new(1.0_f32, color), ); } - let bottom = rect.bottom(); - let h = rect.height(); let t_end = trace.last().map(|q| q.t).unwrap_or(0.0); + let w = rect.width(); for p in trace { let age = t_end - p.t; - if age > 60.0 { + if age > SPAN_S { continue; } - let y = bottom - (age / 60.0 * h as f64) as f32; - let x = to_x(p.phase_ms); + let x = rect.right() - (age / SPAN_S * w as f64) as f32; + let y = to_y(p.phase_ms); let color = if p.tic { egui::Color32::from_rgb(140, 230, 140) } else { egui::Color32::from_rgb(240, 140, 240) }; painter.line_segment( - [egui::pos2(x - 1.5, y), egui::pos2(x + 1.5, y)], + [egui::pos2(x, y - 1.5), egui::pos2(x, y + 1.5)], egui::Stroke::new(1.6_f32, color), ); } diff --git a/crates/regulator-gui/src/sheet.rs b/crates/regulator-gui/src/sheet.rs new file mode 100644 index 0000000..3827c4d --- /dev/null +++ b/crates/regulator-gui/src/sheet.rs @@ -0,0 +1,299 @@ +// SPDX-License-Identifier: GPL-2.0 +//! Branded JPEG result sheet: renders the current readout and trace onto a +//! regulator-styled card and writes it next to the SVG/CSV exports. + +use crate::{Params, TracePoint}; +use image::{Rgb, RgbImage}; +use regulator_core::TimingResult; +use std::sync::{Arc, Mutex}; + +const BG: Rgb = Rgb([10, 11, 12]); +const CARD: Rgb = Rgb([16, 18, 20]); +const FG: Rgb = Rgb([238, 238, 238]); +const MUTED: Rgb = Rgb([120, 124, 128]); +const GRID: Rgb = Rgb([40, 42, 46]); +const GRID0: Rgb = Rgb([70, 74, 78]); +const GREEN: Rgb = Rgb([140, 230, 140]); +const MAGENTA: Rgb = Rgb([240, 140, 240]); +const ACCENT: Rgb = Rgb([235, 200, 90]); +const RED: Rgb = Rgb([235, 120, 100]); + +/// 5x7 bitmap font, one byte per row, bit 4 = leftmost column. +fn glyph(c: char) -> [u8; 7] { + match c.to_ascii_uppercase() { + '0' => [0x0E, 0x11, 0x13, 0x15, 0x19, 0x11, 0x0E], + '1' => [0x04, 0x0C, 0x04, 0x04, 0x04, 0x04, 0x0E], + '2' => [0x0E, 0x11, 0x01, 0x02, 0x04, 0x08, 0x1F], + '3' => [0x1F, 0x02, 0x04, 0x02, 0x01, 0x11, 0x0E], + '4' => [0x02, 0x06, 0x0A, 0x12, 0x1F, 0x02, 0x02], + '5' => [0x1F, 0x10, 0x1E, 0x01, 0x01, 0x11, 0x0E], + '6' => [0x06, 0x08, 0x10, 0x1E, 0x11, 0x11, 0x0E], + '7' => [0x1F, 0x01, 0x02, 0x04, 0x08, 0x08, 0x08], + '8' => [0x0E, 0x11, 0x11, 0x0E, 0x11, 0x11, 0x0E], + '9' => [0x0E, 0x11, 0x11, 0x0F, 0x01, 0x02, 0x0C], + 'A' => [0x0E, 0x11, 0x11, 0x1F, 0x11, 0x11, 0x11], + 'B' => [0x1E, 0x11, 0x11, 0x1E, 0x11, 0x11, 0x1E], + 'C' => [0x0E, 0x11, 0x10, 0x10, 0x10, 0x11, 0x0E], + 'D' => [0x1C, 0x12, 0x11, 0x11, 0x11, 0x12, 0x1C], + 'E' => [0x1F, 0x10, 0x10, 0x1E, 0x10, 0x10, 0x1F], + 'F' => [0x1F, 0x10, 0x10, 0x1E, 0x10, 0x10, 0x10], + 'G' => [0x0E, 0x11, 0x10, 0x17, 0x11, 0x11, 0x0F], + 'H' => [0x11, 0x11, 0x11, 0x1F, 0x11, 0x11, 0x11], + 'I' => [0x0E, 0x04, 0x04, 0x04, 0x04, 0x04, 0x0E], + 'J' => [0x07, 0x02, 0x02, 0x02, 0x02, 0x12, 0x0C], + 'K' => [0x11, 0x12, 0x14, 0x18, 0x14, 0x12, 0x11], + 'L' => [0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1F], + 'M' => [0x11, 0x1B, 0x15, 0x15, 0x11, 0x11, 0x11], + 'N' => [0x11, 0x19, 0x15, 0x13, 0x11, 0x11, 0x11], + 'O' => [0x0E, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0E], + 'P' => [0x1E, 0x11, 0x11, 0x1E, 0x10, 0x10, 0x10], + 'Q' => [0x0E, 0x11, 0x11, 0x11, 0x15, 0x12, 0x0D], + 'R' => [0x1E, 0x11, 0x11, 0x1E, 0x14, 0x12, 0x11], + 'S' => [0x0F, 0x10, 0x10, 0x0E, 0x01, 0x01, 0x1E], + 'T' => [0x1F, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04], + 'U' => [0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0E], + 'V' => [0x11, 0x11, 0x11, 0x11, 0x11, 0x0A, 0x04], + 'W' => [0x11, 0x11, 0x11, 0x15, 0x15, 0x15, 0x0A], + 'X' => [0x11, 0x11, 0x0A, 0x04, 0x0A, 0x11, 0x11], + 'Y' => [0x11, 0x11, 0x11, 0x0A, 0x04, 0x04, 0x04], + 'Z' => [0x1F, 0x01, 0x02, 0x04, 0x08, 0x10, 0x1F], + '+' => [0x00, 0x04, 0x04, 0x1F, 0x04, 0x04, 0x00], + '-' => [0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00], + '.' => [0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C], + ',' => [0x00, 0x00, 0x00, 0x00, 0x0C, 0x04, 0x08], + '/' => [0x01, 0x01, 0x02, 0x04, 0x08, 0x10, 0x10], + ':' => [0x00, 0x0C, 0x0C, 0x00, 0x0C, 0x0C, 0x00], + '(' => [0x02, 0x04, 0x08, 0x08, 0x08, 0x04, 0x02], + ')' => [0x08, 0x04, 0x02, 0x02, 0x02, 0x04, 0x08], + '\u{00b0}' => [0x06, 0x09, 0x09, 0x06, 0x00, 0x00, 0x00], + _ => [0; 7], + } +} + +fn text_width(s: &str, scale: u32) -> u32 { + s.chars().count() as u32 * 6 * scale +} + +fn draw_text(img: &mut RgbImage, x: i64, y: i64, s: &str, scale: u32, color: Rgb) { + let mut cx = x; + for c in s.chars() { + if c != ' ' { + let g = glyph(c); + for (row, bits) in g.iter().enumerate() { + for col in 0..5 { + if bits & (1 << (4 - col)) != 0 { + for dy in 0..scale as i64 { + for dx in 0..scale as i64 { + let px = cx + col as i64 * scale as i64 + dx; + let py = y + row as i64 * scale as i64 + dy; + if px >= 0 && py >= 0 { + img.put_pixel(px as u32, py as u32, color); + } + } + } + } + } + } + } + cx += 6 * scale as i64; + } +} + +fn rect_filled(img: &mut RgbImage, x: u32, y: u32, w: u32, h: u32, color: Rgb) { + for yy in y..y.saturating_add(h) { + for xx in x..x.saturating_add(w) { + if (xx as usize) < img.width() as usize && (yy as usize) < img.height() as usize { + img.put_pixel(xx, yy, color); + } + } + } +} + +fn hline(img: &mut RgbImage, x0: u32, x1: u32, y: u32, color: Rgb) { + for x in x0..=x1 { + if y < img.height() && x < img.width() { + img.put_pixel(x, y, color); + } + } +} + +fn vline(img: &mut RgbImage, x: u32, y0: u32, y1: u32, color: Rgb) { + for y in y0..=y1 { + if x < img.width() && y < img.height() { + img.put_pixel(x, y, color); + } + } +} + +fn civil_from_days(z: i64) -> (i64, u32, u32) { + let z = z + 719468; + let era = z.div_euclid(146097); + let doe = z.rem_euclid(146097); + let yoe = (doe - doe / 1460 + doe / 36524 - doe / 146096) / 365; + let doy = doe - (365 * yoe + yoe / 4 - yoe / 100); + let mp = (5 * doy + 2) / 153; + let d = (doy - (153 * mp + 2) / 5 + 1) as u32; + let m = if mp < 10 { mp + 3 } else { mp - 9 } as u32; + (if m <= 2 { yoe + era * 400 + 1 } else { yoe + era * 400 }, m, d) +} + +const W: u32 = 1200; +const H: u32 = 800; +const WINDOW_MS: f64 = 25.0; +const SPAN_S: f64 = 60.0; + +/// Render the result sheet and write `.jpg`. Returns the path on +/// success. +pub fn export_jpeg( + base: &str, + trace: &[TracePoint], + result: &Option, + params: &Arc>, +) -> Option { + let p = params.lock().unwrap_or_else(|e| e.into_inner()).clone(); + let mut img = RgbImage::from_pixel(W, H, BG); + + // Frame: a slightly raised card inset in the dark page. + let m = 24u32; + rect_filled(&mut img, m, m, W - 2 * m, H - 2 * m, CARD); + vline(&mut img, m, m, H - m, GRID0); + vline(&mut img, W - m, m, H - m, GRID0); + hline(&mut img, m, W - m, m, GRID0); + hline(&mut img, m, W - m, H - m, GRID0); + + // Header. + draw_text(&mut img, 56, 52, "REGULATOR", 4, FG); + draw_text(&mut img, 56, 92, "WATCH TIMING RESULT SHEET", 1, MUTED); + let now = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .ok()?; + let secs = now.as_secs(); + let (y, mo, d) = civil_from_days((secs / 86400) as i64); + let stamp = format!( + "{y:04}/{mo:02}/{d:02} {:02}:{:02} UTC", + secs % 86400 / 3600, + secs % 3600 / 60 + ); + let sw = text_width(&stamp, 1); + draw_text(&mut img, (W - 56 - sw) as i64, 60, &stamp, 1, MUTED); + hline(&mut img, m + 1, W - m - 1, 118, GRID); + + // Readouts. + let fmt = |v: Option, spec: &dyn Fn(f64) -> String| { + v.map(spec).unwrap_or_else(|| "---".into()) + }; + let (rate, amp, be) = match result { + Some(r) => ( + fmt(r.rate_sday, &|v: f64| format!("{v:+.1}")), + fmt(r.amplitude_deg, &|v: f64| format!("{v:.0} DEG")), + fmt(r.beat_error_ms, &|v: f64| format!("{v:+.2} MS")), + ), + None => ("---".into(), "---".into(), "---".into()), + }; + let rate_color = match result.as_ref().and_then(|r| r.rate_sday) { + Some(v) if v.abs() < 5.0 => GREEN, + Some(v) if v.abs() < 15.0 => ACCENT, + Some(_) => RED, + None => MUTED, + }; + draw_text(&mut img, 56, 150, "RATE S/DAY", 1, MUTED); + draw_text(&mut img, 56, 172, &rate, 8, rate_color); + let col_x = [520, 760, 900, 1020]; + let labels = ["AMPLITUDE", "BEAT ERROR", "LIFT ANGLE", "BPH"]; + let bph_s = match p.bph { + 0 => "AUTO".to_string(), + b => b.to_string(), + }; + let values = [ + amp, + be, + format!("{:.0} DEG", p.lift_angle), + bph_s, + ]; + for (i, &x) in col_x.iter().enumerate() { + draw_text(&mut img, x as i64, 150, labels[i], 1, MUTED); + draw_text(&mut img, x as i64, 168, &values[i], 2, FG); + } + if p.calibration != 0.0 { + let tag = if p.cal_auto { " AUTO" } else { "" }; + draw_text( + &mut img, + 56, + 252, + &format!("CALIBRATION {:+.1} S/D{}", p.calibration, tag), + 1, + MUTED, + ); + } + hline(&mut img, m + 1, W - m - 1, 286, GRID); + + // Chart area: horizontal time axis, vertical phase error. + let cx0 = 56u32; + let cx1 = W - 56; + let cy0 = 310u32; + let cy1 = H - 90; + let cy = (cy0 + cy1) / 2; + let half_h = (cy1 - cy0) as f64 / 2.0; + let wrap = |ms: f64| { + ((ms + WINDOW_MS) % (2.0 * WINDOW_MS) + 2.0 * WINDOW_MS) % (2.0 * WINDOW_MS) - WINDOW_MS + }; + let to_y = |ms: f64| cy as f64 - wrap(ms) / WINDOW_MS * half_h; + for ms in [-20.0, -10.0, 0.0, 10.0, 20.0] { + let y = to_y(ms) as u32; + let color = if ms == 0.0 { GRID0 } else { GRID }; + hline(&mut img, cx0, cx1, y, color); + let lab = format!("{ms:+.0}"); + draw_text(&mut img, cx0 as i64 - 8, y as i64 + 3, &lab, 1, MUTED); + } + for frac in [0.0, 0.25, 0.5, 0.75, 1.0] { + let x = cx0 as f64 + frac * (cx1 - cx0) as f64; + vline(&mut img, x as u32, cy0, cy1, GRID); + let lab = format!("-{:.0}S", (1.0 - frac) * SPAN_S); + draw_text(&mut img, x as i64 - 6, cy1 as i64 + 8, &lab, 1, MUTED); + } + let t_end = trace.last().map(|t| t.t).unwrap_or(0.0); + for t in trace.iter().filter(|t| t_end - t.t <= SPAN_S) { + let x = cx1 as f64 - (t_end - t.t) / SPAN_S * (cx1 - cx0) as f64; + let y = to_y(t.phase_ms); + let color = if t.tic { GREEN } else { MAGENTA }; + for dy in -1i64..=1 { + let py = y as i64 + dy; + if py >= 0 && (py as u32) < H { + img.put_pixel(x as u32, py as u32, color); + } + } + } + + // Footer. + hline(&mut img, m + 1, W - m - 1, H - 56, GRID); + draw_text(&mut img, 56, (H - 44) as i64, "REGULATOR - GPL-2.0 - GITHUB.COM/BOROSF/REGULATOR", 1, MUTED); + draw_text(&mut img, (W - 56 - text_width("TIC GREEN / TOC MAGENTA", 1)) as i64, (H - 44) as i64, "TIC GREEN / TOC MAGENTA", 1, MUTED); + + let path = format!("{base}.jpg"); + img.save_with_format(&path, image::ImageFormat::Jpeg).ok()?; + Some(path) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn renders_result_sheet() { + let trace: Vec = (0..600) + .map(|i| TracePoint { + t: i as f64 * 0.1, + phase_ms: (i as f64 * 0.05).sin() * 3.0, + tic: i % 2 == 0, + }) + .collect(); + let params = Arc::new(Mutex::new(Params::default())); + let dir = std::env::temp_dir().join("regulator-sheet-test"); + std::fs::create_dir_all(&dir).unwrap(); + let base = dir.join("sheet").to_string_lossy().into_owned(); + let path = export_jpeg(&base, &trace, &None, ¶ms).expect("export"); + let meta = std::fs::metadata(&path).unwrap(); + assert!(meta.len() > 10_000, "jpeg too small: {}", meta.len()); + std::fs::remove_file(&path).unwrap(); + } +} diff --git a/crates/regulator-tui/Cargo.toml b/crates/regulator-tui/Cargo.toml index a464aaf..2746cbc 100644 --- a/crates/regulator-tui/Cargo.toml +++ b/crates/regulator-tui/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "regulator-tui" -description = "Terminal UI for the regulator watch timing machine" +description = "Experimental terminal UI for the regulator watch timing machine" version.workspace = true edition.workspace = true license.workspace = true diff --git a/docs/screenshot.jpg b/docs/screenshot.jpg new file mode 100644 index 0000000000000000000000000000000000000000..351225bb913049622da9407029298e4946782246 GIT binary patch literal 60657 zcmeFa2Ut_t_BVVWR6!6#1?e56Ns$f#Q6VB7L7E^SP3cW)u%RLy0Vx6s2uPFOi;DD) z)BvIP-XS6RqH||PoyN?a`@Q$hAABUnoSd`wUcc4XUK`zq9s!PBz67}hU||CQ7UmCt zt_H{mKnyrUr0!Zo?T2zR6vqfP)OkOO|S?F35kh_DUTkd6kw!b z6!_CW=o)|?GfrHrFF(M)ez34XIJkKD1cXP3Fc%aY1F*3`AZ#2EE-nrZ=4vm@=Ku~F zE;%E=EZ%Xo8~9B26asfcUJ@{$&v|!3y<>$%(AeP~;gOT4D5*}fvaxe;o)J1HEFvl< zE_dPLC3ywNWev@%TH4oibWKcenweWzS~)s7ySUzQbHD%Kq3@%|Py9l|o`pw5K97oi zm6(+LIwdvjO>SO(L19sGN$L9!H6Ls1>Kht6yFPXI^!D`+jE;>@OioSD%+9T@t#52@ zZSU;veV!K<0QzBCnBPB4?7Mkk$bp58g9F0B|2!`&Y*)-*5E%|GBR?LwtQ!6e`{PUk zcL^xYhrG;rN60LwzH-9Yq2tI&7NJqr)z4G=GP8qC?A~9R*-sPud0qnmF$fC-BM=z? z23Fn}9|1Uk1Z;K?O5q#}f2^z@CM799hKk8MY-m2Aodo*C6x7&{Me{^9m zXdpTmaIhBPD{Y3GLeNPt8Yon!gnp2Me(FF2&(Hv>UxtqPihR*G|D|vP4G?dl0S$SS z1{y%z1nlXLRnnn>_xSrUXyCX?kyjDM{)mKfnYF|(3OiQ8lKJsJz#mnu#6c~gHC+o} zOo-4NnD8feBazAYGWIk=7N zH8ZTr!f-bdyf}>pEY&H!+pE@jp|CboX96kNYlZ|;oBfy2DSb3h6u+OWVE(v^42C?v z^AHUXPH)*FFQYze@rj_WOAaBnpt;4hZQl7i} zQe|71K}9*DhM`;GjE}y)1MrKFF-ZI$ko>11ujK^reP?nxZ!in#ITjG*D0|<=T`pSY zwT}a6dBaasG}|{x_JzwnAqP4`A^InVd}P)6%OnE@V*z>LFrJFoNWO}8e$7zIrrK)Z zPQ?u%c05h`K11-4c`NDG&?b(j&337jblNZ4>O^s{y5j8H+i}o9e?Pjh_<)ahZvy;&2R2lf<2xH z6Kxwh--opK1B$F)zvFn+S`tEBxGdUFa2uB|q=}@VuD1ZV$eLX4GPme3nyeLi%y=Z# zxQZX&msJHI>xwG|l7Fxiu;I}9^V6u(qIDsx>puo2_^zXYy3M+MXWMC+V_$3vFU3`& zu~SF}Xn)lz7s3_h3E#c5R(QJ~)nqQQU#d>&`Gu1R=)Z8%&=&kNCuPP6Lv#CE(SXe} zthH`_di5XJ?Kdy-wWnWcuiE571Cw%Spr9Qe!=m4E2YB=)bWR%$G(JKDw-P{K@d@xf zH~tZ?&KW*7JXSRdLSgjO6GK=fYzhrD)rIGowQcE%!52G&TbWU(Poa{b$W-W7DFFUi zvZ(%YT))Pa@(RRm%<$~DlUC)Q0 z+&~8k5&-|M%t^dd_<+W6%r&Yh5-O7YM7s}U>*ld>`>5wYI?E!<*%}$bV+^=UkOp>m zLffmL%fQ=n>^j`03XEELweLkd`>f%@DrxNg&U;4K;eejvq#kK5wE`u%UNh^5lQV=L zjK&Ku;Y+75fUL-&FZ1o|jt>CLP7Ulw%h*{0lj2^Wo&htPV&Pfk-H@KyqUN9yIbjI? zBy)+R)7FR)RsfXCZRx7yZhtgn#Wi?HW&vx9YQleH%!jGyMdoXA2K;-;dWoDk$Gj6l z>V&ZPKe4QbcZznXvp;0kU%YBmJ=GC1|F;VmLD(5W*-3_&^Ix!(v=ep+A+`G ziw3X7qX8HP=<)B~kMr>&8ki`Dej-IsqlP_~B~UxCATGE>naQ)WXu#JU4WuQa0Zufq zpX)>Vl^O=14R_E$D*cwoe);aO>;7sHopzpkItl zjD7mq*u>bU=0Dh{3g%?r8ea!6cxkJ?R^10y{wT$|eGE-Kh zNWWi9j66Bs_C=mNTDbmMo|J7bVC0E?K-|9N=f(V4VyRQrcuIY?bTFbf5@YFLtCm*iEL7Bjm-@eJU7RVV27L!Ci0#)?_KGNfIXNm4kDKTHH zxT`?K)@`Pr2U-hNEBnD}O6lJ(UA5j8Z7lPAQW4nA<0BxT%-`c9bV_z;>P2rrp83*v z!O)qdq3tf$rftDbD~%rQxP}Wm51$(BM)J{1=9pF?^> zk?sns)8@kip~CK~sBHS60zj*4(Woq>({keR8^M4O{Q9fh?r-ZrL9;R^VmVw06xozJ zKi~w}hxq~B*2lLSu%()=%q={^2!OIktCRaMo87w%fPMS)fDiqtN684$(3|Bt!s(R8 z1-$bmNi_F91Px7t7monGO1vB!ljZO`9i@3(JgI$WKgyU5y%VJ?ZgU6jt@ZQ_4-YHY zu!X!f7`=YXhj;4w%OEk`A1%j!fH3$uTy{|CC$p8f@-DsyKR;_5xoo3_v$+}4Mhj~P z0Ipn!9)di4-sfL;tTQUbc*v1~aIDvg>Nqm}KYGV`*v8E>P&t{Ck($P# z+&ynqrcRg(*y2XH0(G}Y?CPW|RK!@Y&sARQsL=|RXT~$+SByB)k3*b8OGqmi=LdYw zwBxS65wd8&%{a#FOOjT;)F@y+WzsHTLRUWJL$G;C?_xnj58*4-1pHy~Qw+!q@N}a0 zGob$*PQ;M$Eoze-9p>8&&v2jGuN#fz)XHvS0)P=N(V}EN*c2SaOCl$yS50Kdex~w2 zMyemsYx`#eg#IM`c(#!bc%k#@P(hg!Gyf_$0G(eG7AeB#LgiFFc5la#)^JbR-vZbA zkaAXNpb+%qGWgGi)6jrd&}ssx(N+@;RMzdZV@-;@fx=CY7Qk9eH+VS*B?P!B&Bbr` zp@GwYw8-%BoJl^HI-fKpYjKie6c=-_@03P6GyB4H`;o9 z@Va=rGE96v`Z%+mO@3@d+Gt0LkAENIt`46HU~<*xPOl(w_YXn7OThbWNc>y&>Zwa% zo~@~GZ5`u7Xmy_XC{u#MZ-d^w8`)C@qLs!kp(CsgWDSKXgTH9 zc)!UgsPLk7hN}_H@wP^IIKWdI<$8-+vcrcWxLQ2)>_-R#&D~ne)G09 zIlR8B=JG~f)hvO}u(W>6v;09REH=WTH%;W3y41+q+sY3Zfl$i(4@c;VXS_JD`Ckv7 zIzvnYDDJ>ee1MS04 z(iFkU%}XQq<0R-W19qLZL~qH}eRDyjVq;2(fq(=iEb^36%*|O$62qw8Ct3{k4 zB};{0JYFn>b>h346v^|8pypHC7LERn?ZFCYpj~BBhMXrU+nlwXaH94dWfTQXTs*IX z$JT<^Q9y||+>y9a)3@Ky{`~7X?lh`aZyRyfJyjeLt1G?W2AlI-tp{zH z++dCdv*Ho)uu3f!Yyvb8@f6m(3S>%s%pA(Vvt07-rnsH5Eqg!5<#q%&>8fMhv<%sG zC7i+@$Z>`1lzxy3fNHSiT|?V2bCHTSz}@6=%UL>sRZ#wDOIut+)4&SSKct+Vlg|C+Y@lYG#8))ux=cckAY5$SfoI2MoD8 zr_CBDMnU5aC-5ytHfJob*Q^S+hFv4>jkn(Ee-M%L%ICzp_W{-PQ3|5-u|cYMP3g=7 zPj8ozQD+aFKDVxT%4I&(<*gAxTeezoHF<#X0OyihAG?m`ZEE{T+#?~eaTKJZ%R8|XYcfA3!G6>#xG zANJeFaZb_?Cjd%T(bg@+ZvH{yl5YOMRXGxG8^S>^caIgoDso!2GFmk?CyF+V?2IsB zTeGHvcTzi!_IhSdqO+aPg9vTsqrEs`Er7uzt!tSh_l-Cra^KfAo`=OW*HW(GH&^UK zj}f+(P&eG6Q811h9R@$UN!D{!3gH$7i#3<@pYox$_j*038{^O=AJ5|-GH|IZ>dFhv zv!F+6v0DiQugmkot^|HkWZ-A!Xh||HYHcRjhef8=Q!V%S2&8_6eW83S z1{#XNJEcJ4t(EbQuF=V;DBEP)^0#ZKF8To`I>YB>VWE9upd2CK7CniicEYTqm3v(H zgwBVe=CDOFVS#t@M`|{i3jj>{$3waC>^&?@N_LPQX#hA3)CPGa%!OG-$I@M#knpVE zPB%G2>5vroz%}8B(80@2v0#`Q!I!JO`v4kPvmr(C`fv;&MOO``(x9*PX7!f2C9Cr5 zwjMu;8UhOL5UuH&mL%!>?dDT(kaO^zy7E#K6S4PI+^VIHP7anK(Kpy`Hgy;ik!~ireVsJt+G*-9Tg$NqXu5-+J&e#gygU;+hV`Vu6{T@ z*V&1!%>)v?I`OKS7#<#>wv%nSm~tEmlYSe|HlFa(T7k2dw<&6zMc^whEGs#?JnDiCU6kd2-hURh@A>Fz$&kUsY|8bV-q(P zMtY3xyS|U7@VvPH)N9Kye?O*WzfpSeZI<*}tk-x~j}Ph7VZL7IC})r7xvk}$XWrxc z^bIOY^6bN~vSr8KjRep~6ko3={#Z=g(K}X%1@Vg!ZF#U=PTrQ8T#@FvW{1|gQ1?Am ze4bTm`J8r7kF?onQ@V?>(%O-9TerNU8mY z;DOucvNsI#7uO0@UZCoVSWvUj9@|kjL`e%^V`yk`oo1yl{nboq-PZJ0Ti8^~mU$t9 zFLbo7u^(P$PeT?^u`WaHt#a3BrD%)iQD9}$R{SoZ(te1&WfZX|L629|#T^GUE@7wLE?|^40sj64jDp2z#G4m=z@r#tn;MV86csI`zQso} z&~F|`1NHR#;U_U4JOH6yL3c5RL+-0;dncd8udhz)1EG$Q?mfX+0i>wLrvUUl=H6;x zb#a;(v+9JHia0s&8fM#u$;E2$DCRZQ93_t-wM8*L5<{I$VhpV@*94pb zJx#*LFz#1hP#&RQiAMvU1knI98rTxj2ca;?*z<)>KvA_%eW355Xh5|M8H5JLe+`ITEU3mzcL*V=+ zk$4E4L*N_&=X+iAmsaG*kn(}I(f*SZ(9e_qqqRGfIDb~+w3i12EWT?*0~xksbop4M zhsB471(t^esfR_khlRy|MtA-+NjkwomoUv{ zg7_fJCVK;RMBQ#X=r4z7vDTqkVf*9A8LYoP^4+Rl2x=AO1T_A767K+m^MubQp#jX+ zV{zc-U#5Yy?Pe#m9Qpzf_#ExUvaOn6bo|n?C>qHA5gMnmq2qhwpBpqJ5PTUIy~y4y zco^L3L-pe&U(w_{p#6p$L>ja26u(SAEkpccyQDvzkHl|5m8xt9t^XV4oc{qd95kf( z-wA-flAK0e{qZK zx7Nvl)Dg&Vp(m5|-t66_tR#)+6OWBvv^5=_#sNr3DXF9s5{TZ)P%6xuPK}-vI0nOa z3tn!}WbhGuYg>1F(>nR?Bk$n4)FIYNVj`}`TZNYfV~w`Qf`8gO{AacDf50;QvqSg~ z*@*|D1dwoO7<_G2e-DQP8V29G2LB}hIDlXDi%b3kXgE;q%s-8-9z`@07yh%NaA3D-SgtM>%bpongX=73RN;?^WZGD~cW>I$ z_0+?{{OORYKc6e|C-v#ypMm(31NgEnqtEkbBjt;Oz zHk86!6izp}f@+(2)a%d_ABu=039;Imx}1FW1>t_$+ivCAYZXtbO4>RH;aq)b><>06 zIxoF?O~}lR_tCMKH1Fv>H^7K-v-J|5Wz$dvvWnI(bh2Vk4-K&OHJ5eS-ln@)S`Y!| zX}t=6JtSsE#mXI0Z)x+Mz}k|W=L~BShZyJK)pYnGwYfOLu_#C{FvP2t;qeA>k?J2&}WWnXT&Ud~59( z!&cSBSLHf{_bf;+z-AWL&B`%k=Gny0bz5kD!c?o^QVa1R9i2sm#)r8RR~o1<4eY)u zp%(~p6GisU$cj8TN5ErJY?)fxN1vb1pEDrIVFQB(l}#3`Q9HXP=j%c#oHkiV(?Aup zytLE{RzXMRtitk}DA)?P#bgY>aacu`xJaxYlp zctA@TN~*GJAHHOd+Ab1GT-F_i`i|Y3E+}1xPL!d6YObLjL+$(sCj_(d+h#^S{8l0= zx^vYuBjva8Ci2`qUc<$h zZQSHy^N;wPMFyId&nSiq?+I0IIw}9Db>S3w=nT%I8oT!TqR(Kl{5ypjdj-f);5}1H zDzUat$#0aLOA$pBUK7!C1BfDy>z0u{q-P9to9M$C1NyQw&vF+Jib^I1l1iu~vvfhW zS%o^iHqU5KeyxQ5B@+H!T}0}~$sWb%D;%mrd4`ENg53w8RbpFA$LrKK>(07MIQt1Y;JxGsEt5(^z?d39e-ZSL25<#{;QiGX4^Lz=zzx(&5$X0t=|8zB9b&CweM((8$rn+ERswy9n{m_y~82fU;%HU(aiHSy&GiUp6DlU>K?uaZI`k}LSWisSSGvz~K!4bEcR{o;xn&v}_hBUR z!``D%K6OQW+0$ho>YeG%AFq}i(O0-LC(qOQIH^QqIXgj?wK3k+brKB#*{M4&Q_T&m zd6|m|W`vTGOR8(Bw~1FSkPBau0cEm!a4mJ$WLv;pvTd8|UjI=B!@^RWXDJUHX?ao= zLSxHi7ZOFov?M*TK_z)S@F?3t%wlRxu5E6~OVTa2@LSA^m;(c;8!`>ZE@7WvyGW+B zB#=BsyDR%XPA;@NTcyesb@8%z!9)gf*>%T40Mpe7bFv9MW%2D3#a*>(JT;xy44^=Q zGqXT=O1U#GO>1xaWVD%I;2Ww;CG2GL(I=3Ez7w<+_Fx7Uo8(*q$5Y z$(qeEtfhHE17xZBPp&SPdVRo!c4y1gXHr{lT2}QgbLtdMcE3jHWk(q}5o{8KY&=bl zQ%a@7m(UkmJ2swzrxSI_?(Cy5_3T%3FvE!}8dhBC)_QA*=5!c!rugLI(x^r9rJD>J ztk=@s&B)xm5mGDr(kg6;NHhMD_8+V|X&@(?aZaKHF86u=SO5Z+!D8=IyA{B;CC&vU z)*DD~$eL5@cT>MWH>6-mOT0``=GE0?QfQqE6=O&Odn+RbUWxXv5EIy;1HMr1l_lsj}? zR}8C?AgOj0%roT`4C9W!AJXMVms!-SCZ%VaUbgue+l1CjSv>S!`D^cyo*g9`?})|S zkCA=?4FpDz1h}5Fmb{uaASWsDDncytdKWqSki5b;iwVu*6MV7Rt}wZt?Rnb|nj)FY zJxxoN+4W_h9b4T`@J;U^EX|MsAfx+NZ-pYey~huD_l7)@U=w#Rp+C< zEC1Gz5-&^9(`{8*?llD@Z(lVx){^&4O8Q}{>ZxdLR2f$QSHU#&oqpe4q{vIFGi(6` zzD3VNWosO63#QWA7gTk?c6>#gXUxYSi%uw<JZCKMwQ+UtXpnpIQk#3I|PKfJ$+X{x&}Qy=OA@8K0!)DuTD<{xHh(B%Z9SMcoks8xYPTQh;(g?>ujxgJ(%z>goG2z|lp`;3)w2(loAiQ>b*6Kx;wInrW2=iOb3sl@H0M=l8 z_=X&$$kbZzj<;yWR9SacL?<{8!a_j6#~s6j5#kqSJYw-$#qa7iY`7XapaCgt;oPwP zA7|~xUZv`vRAQ(Z z?d>|JUbae-?d7>0Hg|k?>0N)KEw>HzSs8r*>heP3Roth{vFd=YJUwr9XeiI1fY(>2Z53JsVS#h_S=Sn9}P?qgbjsL@T$h!ajoi7`(J zO`tg4EHH;mjs&XjB=>XiovRwwtXx@2F3K$uukSsj5sHUBG45xr zQ^kIx!J&k`qkk_-^U3!n=l6EVpRHOk%_G#DCixHt|wxcsH9ao!={IS8+?alc;8y^?ug1R|9)3VZZfS z^@Ct{EW|E}{imA&d=J4a8RfmZVM)e|9hhZBnS)(T9F048nt8~gS)!$eXen=AqZ{9w zaK?-2=zE>9xbMo<{zKaTSL6n_PT%0%DI(k?9&Z1};_LSvajB$$!A5~Q4HP`O2DRY> zenT#@gyQ4J`klxMn_D<{>!Vam(flrXQ+Ay#CIo73>5^`f)x^^EwmGmC-sn6H=G8R@ z!^dqnFU_@ORXI}VX?Zy#;*p?}I;L^v(UzwnrpB#H4%gx!ESo~C*2h>vbEz<_`x8TS z<@VS*#k6d7BA;?VId{)rc)TxRS{ucTvj`IE%2O#!RPOXIlX$fN?~BgNus(%U%w{aO z;4I21SVxf@^R|iNfy-nYvD+Cg%?j`R-d!A%H`kSyTel5;ea+I7^=G!TZ#kW^Grwwj z+jn4*in&sR*%?@c+&aNKru$K`GWiUKRKLDHpm9IQ^9;4Tw_3&&rX$#pJ%CX9efYxB z9Bn)fS02I6?nB)H1Vs3o~8Bv$!1feqs2FZHB6j z#FIVSx|*48Ha#6uwfHSK$@-;ay`aXByued*HH|Z+WhheQ6YUOXS14vL43{9?^Uu2B z+mPs2P1tJqroI!naX;}U1t+#^U0XUIwvn`U7Dj5;PNM{bt#Q?ruMbcdNULLrWBR&orU=A ziXAkFJja~dwc$qYF*8vcsGVPu+tp;h+nUOwBWw=5QoiOv9Ic=+Bb>RxTHaS3(w_J+rFxuCjbsARre$o>p; zc@1-F4!vm@q8$yuCq8d^m2P0)eu)OE8Zam9c!jDg%b@{i80I()1WWwzBNQ57$DGBp z1p!x(?xR#N2lOn2Lfz>R$au`DJ^d`G4e<8v=aYQ?_}*AKB-tKYD!JF6deon!Kf}-6 z@Vpule%7($%12+fT}^C$xr*qeE=1J`sO+g?y2=s;CNFtyZQC>{_Iuw1yDNRP^x%swdHB;nlNA1gbNO@YblPQ@x;V6X zSbtCtruU3Hu#0oprBRc_zUh2JL#x6_=gh!NC*tFle&nUdVf{}_iy2F-g)5`S^zf@o zE!!2(+$E%$X5J2tq^ujBDfdgUEhz&xt?=|)lnQqtt3W@~Lm~JNDMk`Ha4DqT;w?n7 zIdQKYxDz)$w;z~X9V6dIlVjc&i9g?%uS8^wK6Z$UzgqQKGzXFMGMyM z{9vGe@z$I7F23v9O`(*FZ=W`KEp}kR_RZzm$!&GOtb5>g$1vA0)STjq?V4Z#Dao9; zX)e$Ei#aqY(Yaag9965g-_9~W% z!|>L(y0xM8A7zNnIGY_2Y@;#*#Z9PgC~e^_#LNV^In5j3DB)HYR#q}8)F0%`05gYggV1FS2TC(hF%B9hFLr zzx=|+@8XpH1s0|DH+5vLlKVqT<0)8zVLfR}i@A!cXyBekkzip1U!6*G!_V;UJoewi z+ykzU?uK#}xb-yF=Xy?E7-ASYIg%(=AE-JqGC|_|C{NKTi`0^}6mxDilgA6qkLE{T zhuPX%VtS1Rx(d8>GwnZ9Kjcm(5jc%yA9%M+Co8aR$#6P#@|I}ki})74^-u5rAI}>1 zsd;4{Irk~DSM?cLubdcj{U0%lw)WnLOSJ!ZF0u5qi>qOG%P58P8MlZF`T0F;QN+r* zSq;$;_#Fme+5I&WU(v^(W+`_sV!8r!vMYRO9uB`*5sb64-hHEenE%SgC5PeOE4QAq-g8)!R3~SBYyw>tp1`wlI6nEVzD|G4hjXrpydp>9GyraH>lV@*VskSodCEx>Kp!3Zl5t3Ut07>8gm6Haliexa3!*$LJvY<#`s~*m zU^uXcV^Z|3idF{n_}aK1$2^wMaKyoVj1S_*^O_Ygh2MY-@EQc@K^K&m7q*W>YZ@mg zC(o`h)6cOC49Uw$nrAb3zKV_fNY6tbkHk)<_mk?(Tld(nRZdLRw~Fi>(ihg1cRfNl z5c9m`2%#vIvHg-|k;~*D%Wl%-V7h|r4}0W)GqTjz>HK^#(SzqQTUl2!Kc0V_2_f&A zhUC4g$@Rx$~~w*p}%ppH+Vw9hecSI=WQsXJ7+eSd>&aX%5}=F~03n5oqN6 zZkol;63m-cu!cX`EnI0h)wnjFD{Fn?^>f`GoFkKu$f=IJ*S{ZjcS?rR1jqYse%4|) z>%M30uFbBCCHubn^Nn9-6u&8yI?2PAm2q0DAnKJs%}PUHp#RxMdHbMV{8Wm#H`SY3 zsIr(9{cCqpR24mnPj;!6hTLnTJ1-PyZeIq(o(erNqx@;^OhK3z%y8v$kAurjGV4rs z)$a3CS|VEBI>iq|Os|^Syu8m;{Eo)_R$84}v01WJ))U?I?75GhV-R0Ew%77=N-8nI zqLa@)9B*M8e(WdEta4-DPCVp%cb}yJY;Vcwm{iey=M$j{BURnjQ>>R9X|DL*sh6C1 z@tzYO7=e(vmrrS8-Q6@i!wss2)rxnz_O`X41~-Zn*mGp*e%@))ZF~1jQtv`M`SA4}$XI8k%B+rr%pS}6!QQ`I)`X!aO z6R{6z#{I&f&J~?GM^N(~$+mh+#=n|n!w?0xLPV{&GkdhG&^C^fY%A2IvWEl&T)L!5 zvucYid&|SEYD~}Jiak{^fBYudlFj{uIJvG+X%l6YvB-$0Z74$Z z$d9}YI&PV$b+AT9wo}v#UgO;p{gR(12}x#q3$NJv*eQ3~E2RsUSsc|>4>C71@BA@* z_t(7F@1vH#Dj)G`pNw(6pqs;U(kr`QbiKz$t@pN{cHDjPhPo?-3PLaTY|ScHTrq1} z!F#Q!bECz4VP$q3Y*yh&bNvb$a30(xo1k+qYaTRzfOr)ft>5;_Fi5Q-xrHYbvR7F( zWjbV8RHzWDuiHdpOXI*5zI(Ztl|V`i)BhOG;vzI)L8FT*o4cCyuNWcr#}@&uFYVsy zp6{%0PJcKfa#k&@{b+L{yFUi_$%B>#shRz6Jta=WMQ!b0Msakny!}AMIus3S)#ys# zBab5;mJB3h>dN!DwVm+rMGR~h(Yxzk)jN)0U5ZH>$jo}-P%U~Rik4i5PBP9;CPa23 zKG-pkldIp*LuYs1o^2t!A_KWu^6=|$*Y7N$G^go3%?NgjiA%(Rk8l+xj(MCuUYKf` zzZ8)2$!SrGidy|iVin`y&?R8qaC^xW5YH>;YF|kSr(ns~V~Ixse%gK*R|yqA0oGi} z=qVx(5SZi9>Nn+2D%@eMKQ;{$R|c4t#;*}$_Wu07T05{j`@ ze-B#}(LNbK)CN{S){hP4yQi&xvJ<`0bcAUrY(9G^m!KgjUazVooo}6g**2?yIETK*-*zC|pykFd}(nSoBY->BAF7gr@! zN#mm@e$(xbne}OW@Gqap%FcB?ooip&Fbt0}9>3CcjxS%|Vq02^IFty2T1!}m18a8z zIqFs&kZ)gcR$kjItYYxjn+(zu-q%Kg1XVlvHeTJ^>VHMj$&|xzuYQsSTeRLte!`s$ zB9VlcV|}CYRp?OhL}ty*GBJ65+IG~j;3`fV`>uy38|ofvoui%8vbHaEEETq;8DehL zu0G3sJUNN&8mOwUK?Z3bpE7*z#AC_hE&(o1PRisBZ1K!SDI|+L&hl>9Qe@E+JxzZ` z_LL5m!qqh|%J-Dx@lki#&z;#)%(KM=*nBRR`l%#-{@2}?L0{wRTg8WY_uJWS3`uf& z`3C1#tfL_mQWGFzJfrgpbRl(&OCpf>e#z;OZEIwsZhpKAY!hSusaCBlVnlXDcUdMz zWOpcEr@MSgn^gfLvh_o%VXfkt>9d%0Twl1CL|Ij+i$L-pE9bs~mDWVZ*A=Lbez<08 zQ=vpB?xu)R&gRJCthn+@1jqR;H?8)uF1>~;dP|(@Tvu3uUE%I_roG4#)L3GVD2|qR zWUNW@GK6VHg%~bkVn|#;7k3LqlYP$yZl>#&?!Ju-beWpERiXufdt_Krih?FD9!U(6 zNzhD+s9}ky(X9PeLw@_tLT9cM_P%GGG=JcEzZMk%qn@dszW|AFenubd{%+FpEk3?# zWn_7}k_IBcZ9|D!^ApWX^u3Q1YiD43`d%x|Mg~dKqIi}PbWD;(y6KMRY%;SiwwF0V z95%zQKTVu7GUyw+CZy<0bm8U`wjik=vK;hT@~W6<<3#3F%;9rCXz=gts=sq*E>`-f z$D5*~*RDgwS$$w{>IENgp23PMCrql7sx!i6%ZlEB+C`V%DpOhN>-19j;2v{6QrzU4 zAcU#BaQdNqu{=JACc{hMw6eV>(+3mUn zaQGRCNT$(TNNAvUn+TD|-`A;~Q&Vn4L4DzOUd3GA*F&D@h36QP63sfyaot9-<^?kI z`!}B-;SdafLsOPiG4P9MS`7C(zGgdB>e*0L8t(*eaoP=EM1oUVw!HQh^Sv#DTwIVb z<^I!Ci_;J^;H{S;p`SlhbP;OEl$>&|AXlY(YZnI%toRS?Hjob3iV#YckX&lpoQpzK zZ7fXR@2DDjWoXH}=k83npG-H`)|48F;;Ah0mAIuamQ(m}@@xi(_{};u%++O}vG~lX zWD&EaGWZ5fv_ol^R&PYaKJk$YUq|h+WWL+G^(|NC-1Krz(NF%E)IyQkSRMEv9gm8Z zfcTBwoqCG6w5*X$B`33*N~TBZg?@0&oB&jtMPWOHfbp3;%}c?sp@~bP44(JzD=XzM zmKBYrOo$106)tAK(_6hTdvjE8E2i-idv1g!^U2jlfe^f6XX~24r=$^sMe1%+picFL z>>cQbAc#`(tEsL|81ltqrWI5?YkqEF+3moH0P&Zw2zwf3X2cLAq<5ZbJoSip@;VaS ztk%u8SG2<;y;6+1nsh+;R$-^xC8c86`r`U(P)t=A{XXh?xeaqR&tCeT8;yW49?oGdPIXo%4NE0=gJ>0yn zty9s%M(WC|c3nP@b(C2^%%ysp+f7Ug?+yj5%(n6+dkZ`7(v%nDm;CoH&6RJfo_;9E zhvlwHEs&nR9=}MW#Tr!zEdL@8+dJ;rL(BCb1sAD)mVOMQHlZK#okBR zLT$Vr5Np0((P+Unf#kw&eUe3id)|g)U=eo*TRmR*%H`N>m&i3V@D8zIIy*Xadh&Gy zJ((;8ovAVFbKbQeyH(T4M`!$U>F|%jGNouT3M(oN>MTm~3#W=2VW!rfSp@YRo=`3Y#(YKNkOYa9P%i%Z zxnZXY{_V1mXq(pgiYgq?JSD=H3+!^)=#rD{_DF z?q}hLQ`p-pY<%&a*~JhY1Nkozs@E=M#GBNC9J&%OQ_P+B^@j|P!{9s_?maQIJ^eH- zc0SyJLE@K(_}j?u-V+VpnC7~AGV&H5j}4EezBcC77TWGdtwIXdt$)9!DDkYo<=O<5 zR;cJJ(P_lu^mzQziuftEtc5bKeQ2|T)l!opm-}!VvSDPUHj+0XVtGtYblj4PxP}+N zv!h<#kiJY;wbt*IyO@66(z6WtsIervvQu$lZ;x*_Sax(@+K}D5%$oi=^U#Ybwq<6q z-Ks~eVc^Y=rH%#i*Y!4CHr6Smmh@&_dS5M_I<58O=GNoMZd3<@fEy1$t!EpTC_2=g z=(9?DC|BcZ8GXo9L^J0YB^^=ySNhjNQ_Lw334 z0Ax$a3lU9dKWd;1iCY@>5{H-t%G{VFQ~I#$2jCc8m<@X7NMA{%+tKAzxeZ-o>+y|A z-p15;hFqsTez~+DbWF;M!$r5eQZvEEQk~=ZXB9Ghkp|i%81QMLd#JpM7B!Z9tISDp z)dlJ@3dSJ6d@*`4KkizXjW817i8Pr)@v%uldvDIyj_Eq;B^G5rR~ecrEVOjbno>?a zqGuIpCoj-Kqan_n-cfA~A}OcKpU4=H3%#tw?vTlJ9+Rd%;I`Xuy#C*iHeWB_uUzso z-v4pk8~<#1%a?wQf5-l)uVWy8u>3#4{daZux0?L7-u(yA@OPSi--L#~UzYD3t)D72 zervMdR|_1t%KBG$;3p#B0>7r44?cu1SAJLce%O@dds-iWJ-&s*LF*iTC(Lp1G5q}q zIKX^=amn8=4h}cV{XXaaDnh;m!vUMJupPDwRQiieKe2vnuXxyjfb`$*)+v3huW_1d zJ81O?V19TS$zME;1iy)zN`KOO6~!n+y!IFG@$Yvv!T;Z;pVBvd#Sfs0ux{5`Rx(<3 z4c636?-P+ZUyF*D=VF8j?E)*-bWoWPq^v`j_mcLVP?2?8 z-2?u=_O3l1sXOgO%A=Y-|zeOerwnJv+efx>;2yOcm38{&w8G9-}kz&Yu(Rv zKXDr+->ptM?&aUwEEJ{kn~>WlgZ$?Ye)+HP=g0c|*Xb{SXzSgx{QoB{|6RuQ`St%5 z9(-gD9FYD6%z*>ae>JZ)Sl~ZS`8XbMK>BYRJJyQTIUxN5b*i2Cmii z{yA!X#M!MOGXk7G_Wysr-|uO$Pe0X{S2SAd$R7}_e*t5&Mv(qd0Qdswz^51bgX#Y6 zl#gEjzgKn$(&6-$_|xrOIC7O7xyr8s+jGdGo?qEVV7){S*B|fwCcq;fXIs46ajulH zk5pzKaHC$xG?Kjuk@^g$0(RyB^U9nc3@bL9OL@#{$*@!}2tz{z-p=IQt{`cALh#d> z!*!^9l-qE)jxUhhaJY_jWZ55Qw;ZnH1N^uav-}wAtc~kn6543N!$<#2Gf@ZcK*Io? zKhsOJNUKIhPx8++65X9~0GE~c-+e^?HIDcU_>$YwQEF}9{69@a*I0=l&Yjqxxvimg zSIytfwn%ij`i@J`mBG^UL|CHMRG51i7TDow7cCf+U|{5E(ev|;IINnX#7Oe!HKfcf zo@JiV9`Mn1J?vJ?B6mB|UCY=kOj=ii1qAMiw+2Fq+>-tcfy4$fYEBWQ;~Jgbx8Pb-A3osW~#gwo&OX-OC`^u1SGxt znRT835ZRo;B~6zI49U5eH+@b3*c+@_r_i8kW8^CGR-}Ol?fJtt{mTXW-3=!T<4o0# z+rzKvk(`{o7_G+qTa0_S5_LywoIFOk4$X*6!@Hm}1KqF$`eoqOE6)&%7?!BNJnfQ;R{-Q3|~14-f!>o#J0PlLW*J)NNsgt_Vr!6u4_{?B5{o);qUlCJ*W(;$ z#LM+H#dWnEbbiso3+)g|4T!B_3(O^~R)F$1SELrm)#~0YD4np~>)|4{M=J19FXOca z00}~Yo)W_X7qtoUd-1j|=^cTOg4A?DzzhsI8ZwE3Yik)Zjd!t5my4Fv8Cji$&t6`a zZ-WkR_qN5zBc(K~>}$p8E8lCs>*0R;EuWgFFt1LVUa683zfD_P8;_}eyYJg@Y0uMS z@X(&PePSjZLx=<`zWvtnn2anVKK}y&6wMqH?aM$*MhZRUWm0=$`ZfDOiZ;1B(rI0# ze0;nSs%|Wh{9ufhe@~U^j7V-jcB@p2@Z`jn(v;Eo{FEMuw^I7JL)a3{Ga-7&7;reF zB72~|gU++D0N=M+Te@txtrLqfGHcbBsda+d{gtor_UYReMwO2;#nLb)eTSV9`X>^^ zS0-lOBB{{{Y@hXh(aAq|)4UpVs&o8SM3&OFsNBexe zw_a zeD+>JE3A;ABkR?BVDT{#%sG*>JRGCoxB@3qd>!#oiY+Chz?aMJ@z~MxTi2X=whD>d zGr5JnhuMJHFAxJ%uYA$CuDhI7h2Wo>8}j$ly{YRd_24vd$TS=~SocGpvca-Z55%!hf^L&}D1(@`n<)|#XO8~I?=(?p*Lao5bE_=BQMR>cXHb?hcXO|uHzgf+SvJ~ zT7=Qf`WHTxnf}!y<9R21pNWCK$+w!u6}qGOZ)up#>wrkcJM76<&UFhY8u1;m&{7jc z7&J031XavaO99pAei*M9bmSw}{%@JIB+tZ#)z__*C_5@44vJMPjHRWqvu#^61>l{7 zc$LC-6Flz$J0fhHpE?ROB*U0P!4Y6--z{CPf-E56j&u+BmO3}3?mq6)trDiZCtiX^ z!-{bqK^tS_H!Ny=d;4iW!|ZH!%H{bM{g+rdli2YauhiZt5>&MdohmRl4-P!k1>XO4mBjn%%R|E?0NfDi!dm8`v#~;)e_I>;ZbSKcL1p} zBo>)F6L>CTL+M_*+@Jums;khLah!?u17NG^McO6Ji1gK+SE~Vn7F+{X8d+&Db3SJf zxP7>Ag+vUKk+g5tu~{s?aZ?o4!pO5OQSRx1r26f0JBbgQz-=7R@Q^)L9zga|*ZlFD zXL*MX0!q1N$B+Aj;_ZJzs{bfA9Fx$Vq;2Bx9BP0RoCm=lKkay<)ViJjfgSl#QZD}~ z!ZK@s>>Ge)Ux-ZFxzBD4Q^9-T`-&s&T3iiDY7e7hrI&i3!6EHiGMZxjsSs8|b!!6~ zc@*HVgurkxO7h9sp!WMqrdfd+T@Otv`%{mV`)JnD<+d3n-G5L4+7}$_SAaShWnR2{ zI=B9LL%Kj#t-o_nZeu;L^W837aC{*vlh@l+K|;k#qM?D_&VXw7UIr|C;R_kT^GBNX zQbJX|NOq~Q3>#_wg;|uiV3JtqLHnj>8jR>7R6lt~AHT!6x<-@*&LPmy2?BPA|DHQQ zt^;qdIo{5LE56PM$B?200EnU;SkYs();|Z#=6F_G$j#<47Z+HmsWoS5ZxZg@2E5k? z;@9)Lb`5L+cuYixXvaud^g=a7L6YbwNoD(c?t3G)-|MX0m|V^RD#+MfSP_xjHGB3xk*XTQW3;YE)f4 zBD2j*tRt}?v3G_;t}A)tIc9MyG~tsM6$WA5)n^dB)kNL^9c0XFO2wikY0fdjq_kx~ z5pSaqkBIIGHjM_l@0Ud=1Rzay%2?^s(1~5=hlOh(;XPpas<|}l5a!E7^foK2X_=b~ zNY6PF5RvD1lhmH9tehKx)ulK3%f}9&^foEg3cLqGdBVEFPoqRe{7Sqejjm)@$?fQK zX%oKH-tH@pFOu8-gAER{&pPy<}2BDIpzJDrGt`W(zV#0Rc5nlh)mzXKvEO}!PkHx_i$ zbO=^=*MTx`u>PZt5i{e3Ni3JYYx`*>a(N}rFS3)7#SFa(9W9es$hpDphh6O0P4xo2p_r{xHodCiev&AZ zfqfG`e}zC8rOVV3uzT3_kq)kW3;Og)uKP_DcLfGRRDMFUNIRBf0r+w;SN*-wsu>sefN}e)GE#@j0BnHbm@7!%YA~C%}l*r>(&aojNwTn}Y!k#x4g#%ZX%r5k_B%^X%4x(M`csD^rhnY4=QH`jpz*uo~y+C$Z zbY-qGznBO?I&RppV+1`ltpT8K9I!R)+}xaOjr5|z1rL4_lXc2q5+%}Ij5evMVp4I^ zB`$W$b)m0$kqaTlbS9CH-YAC!k704d+xSV8aN%;v_~G4)PR4u< zOLyuF7Fpess12DHQid+wuWrAg$smj%|63-Isp(fUAE6 zikV-zcKE15h@}c%Ln#G~#A@RTYvfaMgusA^TUUQCuQ0g5`S#=wU`JG&ytcH(64i`05oJ?=}Zis4S&XkWklXbC{U{0feGIshZC1E7u2{F=gCJ9$76 z_(1gHEA3bLPuT1+Uy*ZY&IFnmx2HO_^X$+m_d$IGL{?8PY96pHX+M=n|1bV>nSqR} z45ubM(DnS*BmI_c2{M^GB8);Ye+5#KF_`yO#aN(3>zD7k7G}6Gdjoi2#+wlD0V_S4 z3RmNlRvWWb>Arwk{6;UMXv=d$SWwxr|I=?e0o^|q-$Ykkn52@WVp;Cdm1iS_rDgg& z@qZ0sP1Sh+*Vge>jQ7bund;|i=T@VN*qYCASfQ$enC_=+rt39Z<$0=`^)7dHm8}Uq z62_Js+|8!K8d0#JJEruXFiUUQlF(=9%PWp-eP{tdE`Z(eAeY^7b#{yho_Ur#w_v)m z%odR5+?lf)9NXY{3MX#-XGKvESkp(nDNPxf+NuLw{krnBui{JmpZpN8_k({24!&U0 literal 0 HcmV?d00001