diff --git a/docs/audio-field.md b/docs/audio-field.md index 379b83a..3b37f6c 100644 --- a/docs/audio-field.md +++ b/docs/audio-field.md @@ -55,10 +55,11 @@ deterministic order-3 de Bruijn symbol sequence over 32 chirp symbols. Any three consecutive correctly detected symbols identify the event index inside the current operating horizon, so a receiver can place its audio window on the canonical timeline without being handed Mimir's runtime clock. Mimir queues -half-second PCM segments ahead of the audio cursor, and each segment contains -short asymmetric chirplets chosen from separated high-frequency slots. The point -is not ornament. The timing code is carried by both frequency and rhythm, so it -behaves more like a quiet birdsong texture than a repeated sweep. +half-second PCM segments ahead of the audio cursor. Each symbol is a small +time/frequency constellation: start band, glide direction/range, duration, and +the following inter-chirp gap all carry code. The point is not ornament. The +timing code is carried by both frequency and rhythm, so it behaves more like a +quiet birdsong texture than a repeated sweep. `MimirAudioSynchronizationAnalyzer` resamples candidate mic windows into the loopback sample-rate timeline, uses cheap coarse chirplet energy for acquisition, @@ -130,13 +131,13 @@ watching delay change over time. Per-band energy over the same stream gives the normalization curve. The important constraint is that all three measurements must be tied to the same emitted timeline, not three separately invented probes. -The symbol layer is intentionally blunt. Chirp symbols use separated frequency -slots instead of subtle variants sharing the same center frequency, because a -wrong symbol is worse than a noisy delay. A synthetic runtime check rendered two -seconds of canonical timeline audio and decoded events 0, 1, and 2 back to a -window start within about 1.5 ms. Real device runs still depend on loopback -capture staying live; the local Scarlett loopback has intermittently stopped -advancing during short headless sniffs. +The symbol layer is intentionally redundant. It does not rely on one fixed +frequency shelf: timing gaps, chirp duration, start band, and glide shape all +contribute so poor mic frequency response does not erase the whole code. A +synthetic runtime check rendered two seconds of canonical timeline audio and +decoded events 9, 10, and 11 back to a zero-second window start. Real device +runs still depend on loopback capture staying live; the local Scarlett loopback +has intermittently stopped advancing during short headless sniffs. Next, replace the diagnostic bridge with native audio capture workers that append typed blocks into `Mimir.Runtime`, then expose buffer depth, clock state, diff --git a/docs/implementation-plan.md b/docs/implementation-plan.md index 944fee2..96c43c5 100644 --- a/docs/implementation-plan.md +++ b/docs/implementation-plan.md @@ -44,9 +44,11 @@ a named invariant that the native runtime cannot protect yet. adapter. - `MimirChirpletTimeline` owns the structured birdsong-like calibration stream, PCM segment rendering, matched timing trace, and per-band response kernels. - The default timeline is an order-3 de Bruijn symbol sequence over 32 separated - chirp symbols, so any three consecutive correctly detected symbols identify a - timeline event inside the current operating horizon. + The default timeline is an order-3 de Bruijn symbol sequence over 32 + time/frequency constellation symbols, so any three consecutive correctly + detected symbols identify a timeline event inside the current operating + horizon. Symbol identity is carried by start band, glide shape, duration, and + following inter-chirp gap. - `MimirAudioSynchronizationAnalyzer` ports the first live sync measurement: sample-bearing audio blocks are resampled into the Scarlett loopback timeline and compared by chirplet-energy delay estimation with fractional peak diff --git a/notes/current-system-map.md b/notes/current-system-map.md index 52480a0..853bcc8 100644 --- a/notes/current-system-map.md +++ b/notes/current-system-map.md @@ -92,12 +92,13 @@ not become the synchronized program authority. The six-microphone path is separate from the bridge. Scarlett speaker loopback is the current timing authority when calibration chirplets are playing. `MimirChirpletTimeline` owns the birdsong-like timeline fingerprint: an order-3 -de Bruijn sequence over 32 separated chirp symbols. Any three consecutive -correctly detected symbols identify the event index inside the current operating -horizon. Mimir continuously queues that timeline through Aquarium audio, uses -coarse chirplet energy for acquisition, refines delay from matched event -indices when the symbol decoder succeeds, and can build a provisional aligned -mono frame for channels that clear the confidence gate. +de Bruijn sequence over 32 time/frequency constellation symbols. Start band, +glide shape, duration, and following inter-chirp gap all carry code. Any three +consecutive correctly detected symbols identify the event index inside the +current operating horizon. Mimir continuously queues that timeline through +Aquarium audio, uses coarse chirplet energy for acquisition, refines delay from +matched event indices when the symbol decoder succeeds, and can build a +provisional aligned mono frame for channels that clear the confidence gate. Reports now carry fractional delay and per-band matched energy. The hub also owns smoothed per-source sync state with delay-slope/SRO in ppm. `MimirRuntime` runs the analysis online and can print live telemetry with diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 5f6ca76..2d82cc5 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -64,11 +64,12 @@ Get-Content .\state\evidence.jsonl -Tail 8 Kiyo and second PS3 Eye were absent, so six-camera viability is not proven. - Current chirplet-backed smoke uses Scarlett speaker loopback as timing authority. `MimirChirpletTimeline` owns the structured birdsong-like timeline - fingerprint: an order-3 de Bruijn sequence over 32 separated chirp symbols, - so any three consecutive correctly detected symbols identify the event index - inside the current operating horizon. The timeline owns Aquarium PCM segment - rendering, coarse acquisition, symbol/event decoding, and per-band response - hooks. Sync reports now include + fingerprint: an order-3 de Bruijn sequence over 32 time/frequency + constellation symbols. Start band, glide shape, duration, and following + inter-chirp gap all carry code, so any three consecutive correctly detected + symbols identify the event index inside the current operating horizon. The + timeline owns Aquarium PCM segment rendering, coarse acquisition, + symbol/event decoding, and per-band response hooks. Sync reports now include fractional delay and per-band matched energy. `MimirAudioSynchronizationState` now tracks smoothed delay and delay-slope/SRO ppm. Actual Mimir.App testing proves Aquarium audio wakes Scarlett loopback, keeps mic buffers live, and diff --git a/src/Mimir.Runtime/Synchronization/MimirChirpletTimeline.cs b/src/Mimir.Runtime/Synchronization/MimirChirpletTimeline.cs index 783b26f..47458d1 100644 --- a/src/Mimir.Runtime/Synchronization/MimirChirpletTimeline.cs +++ b/src/Mimir.Runtime/Synchronization/MimirChirpletTimeline.cs @@ -42,12 +42,15 @@ public sealed class MimirChirpletTimeline public static readonly int TimelinePeriod = (int)Math.Pow(SymbolCount, TimelineOrder); private const double FirstEventSeconds = 0.08; - private const double EventStrideSeconds = 0.118; - private const double MaxEventDurationSeconds = 0.082; + private const double MinEventGapSeconds = 0.088; + private const double MaxEventGapSeconds = 0.162; + private const double MaxEventDurationSeconds = 0.078; private const double Gain = 0.090; private static readonly int[] TimelineSymbols = RotateToDistinctOpening(BuildDeBruijn(SymbolCount, TimelineOrder)); private static readonly Dictionary TripleToIndex = BuildTripleIndex(TimelineSymbols); + private static readonly double[] PeriodEventStarts = BuildPeriodEventStarts(TimelineSymbols); + private static readonly double PeriodDurationSeconds = PeriodEventStarts[^1] + GapSecondsForSymbol(TimelineSymbols[^1]); private static readonly MimirChirpletTone[] SymbolTones = BuildSymbolTones(); private static readonly MimirChirpletTone[] CoarseTones = [ @@ -200,8 +203,8 @@ public sealed class MimirChirpletTimeline public IReadOnlyList EventsOverlapping(double startSeconds, double durationSeconds) { var endSeconds = startSeconds + durationSeconds; - var firstIndex = Math.Max(0, (long)Math.Floor((startSeconds - FirstEventSeconds - MaxEventDurationSeconds) / EventStrideSeconds) - 2); - var lastIndex = Math.Max(firstIndex, (long)Math.Ceiling((endSeconds - FirstEventSeconds) / EventStrideSeconds) + 2); + var firstIndex = Math.Max(0, (long)Math.Floor((startSeconds - FirstEventSeconds - MaxEventDurationSeconds) / MaxEventGapSeconds) - 2); + var lastIndex = Math.Max(firstIndex, (long)Math.Ceiling((endSeconds - FirstEventSeconds) / MinEventGapSeconds) + 2); var events = new List((int)(lastIndex - firstIndex + 1)); for (var eventIndex = firstIndex; eventIndex <= lastIndex; eventIndex++) { @@ -298,7 +301,7 @@ public sealed class MimirChirpletTimeline return []; } - var minimumSpacingSamples = EventStrideSeconds * sampleRate * 0.55; + var minimumSpacingSamples = MinEventGapSeconds * sampleRate * 0.55; var kept = new List(); foreach (var observation in observations.OrderByDescending(observation => observation.Energy)) { @@ -366,7 +369,7 @@ public sealed class MimirChirpletTimeline int sampleRate) { var seconds = (second.SampleOffset - first.SampleOffset) / sampleRate; - return seconds >= EventStrideSeconds * 0.55 && seconds <= EventStrideSeconds * 1.45; + return seconds >= MinEventGapSeconds * 0.55 && seconds <= MaxEventGapSeconds * 1.45; } private static MimirChirpletEventObservation PlaceObservation( @@ -457,22 +460,31 @@ public sealed class MimirChirpletTimeline TimelineSymbols[(int)(eventIndex % (ulong)TimelineSymbols.Length)]; private static double EventStartSeconds(ulong eventIndex) => - FirstEventSeconds + eventIndex * EventStrideSeconds; + FirstEventSeconds + + (eventIndex / (ulong)TimelineSymbols.Length) * PeriodDurationSeconds + + PeriodEventStarts[(int)(eventIndex % (ulong)TimelineSymbols.Length)]; private static MimirChirpletTone[] BuildSymbolTones() { var tones = new MimirChirpletTone[SymbolCount]; for (var symbol = 0; symbol < tones.Length; symbol++) { - var baseHz = 6_500.0 * Math.Pow(16_400.0 / 6_500.0, symbol / (double)(SymbolCount - 1)); - var duration = 0.055; - var width = 190.0; - var descending = (symbol & 1) != 0; - var low = Math.Clamp(baseHz - width * 0.5, 6_300.0, 16_200.0); - var high = Math.Clamp(baseHz + width * 0.5, 6_400.0, 16_500.0); - tones[symbol] = descending - ? new MimirChirpletTone(0.0, duration, high, low, 0.85) - : new MimirChirpletTone(0.0, duration, low, high, 0.85); + var startBand = symbol & 7; + var glideClass = (symbol >> 3) & 3; + var durationClass = (symbol >> 1) & 3; + var startHz = 6_500.0 * Math.Pow(15_800.0 / 6_500.0, startBand / 7.0); + var duration = 0.042 + durationClass * 0.009; + var glideSemitones = glideClass switch + { + 0 => 1.75, + 1 => -2.25, + 2 => 3.50, + _ => -4.00, + }; + var endHz = startHz * Math.Pow(2.0, glideSemitones / 12.0); + startHz = Math.Clamp(startHz, 6_300.0, 16_500.0); + endHz = Math.Clamp(endHz, 6_300.0, 16_500.0); + tones[symbol] = new MimirChirpletTone(0.0, duration, startHz, endHz, 0.82); } return tones; @@ -511,6 +523,31 @@ public sealed class MimirChirpletTimeline return sequence.ToArray(); } + private static double[] BuildPeriodEventStarts(IReadOnlyList symbols) + { + var starts = new double[symbols.Count]; + var cursor = 0.0; + for (var index = 0; index < symbols.Count; index++) + { + starts[index] = cursor; + cursor += GapSecondsForSymbol(symbols[index]); + } + + return starts; + } + + private static double GapSecondsForSymbol(int symbol) + { + var gapClass = (symbol >> 2) & 3; + return gapClass switch + { + 0 => 0.094, + 1 => 0.112, + 2 => 0.137, + _ => 0.158, + }; + } + private static int[] RotateToDistinctOpening(int[] sequence) { for (var index = 0; index < sequence.Length; index++) diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 438e1c2..c351c5a 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -40,3 +40,4 @@ {"ts":"2026-05-22T13:12:32+01:00","type":"verification","status":"partial","note":"Actual Mimir.App runtime test with MIMIR_RUNTIME_CONFIG=config/mimir-runtime.probes.example.json and MIMIR_SYNC_TELEMETRY_SECONDS enabled proved Aquarium WASAPI output wakes the Scarlett loopback in the real app path. Headless run showed loopbackCount rising to 57 with mic buffers live; visible-window run showed loopbackCount 77 with Focusrite/Kiyo/Kiyo Pro/PS3 Eye mic buffers live. The runtime now updates sync analysis on a 0.5s cadence and telemetry prints loopback, reports, states, and audio buffer counts. No confident acoustic sync state locked in these app runs: reports were absent until enough phrase audio accumulated, then a live report appeared with confidence 0.000. Treat this as online emission/capture proven, online acoustic lock not yet solved."} {"ts":"2026-05-22T13:34:00+01:00","type":"implementation","status":"ok","note":"Replaced the discrete 16-phrase chirplet cycle with MimirChirpletTimeline, a deterministic unbounded chirplet stream. MimirRuntime now continuously queues uncached 0.5-second PCM segments through Aquarium audio with 1 second of lead, and MimirAudioSynchronizationAnalyzer extracts continuous chirplet atom energy traces from loopback and mic windows rather than searching a finite phrase cycle. Short headless Mimir.App telemetry runs proved the actual runtime path now locks online: loopback and all six audio buffers were live, reports were produced, and sync states appeared for Focusrite, Kiyo, Kiyo Pro, and both PS3 Eye mics. Delay estimates are still jumpy enough that the fractional-delay/SRO actuator should wait for better state filtering."} {"ts":"2026-05-22T14:10:00+01:00","type":"implementation","status":"partial","note":"Changed MimirChirpletTimeline from anonymous deterministic texture to an explicit order-3 de Bruijn symbol timeline over 32 separated chirp symbols. Any three consecutive correctly detected symbols identify a timeline event within the current operating horizon; reports now expose timelineMatchedEvents and timelineConfidence when event-index refinement is used. A synthetic check rendered two seconds of canonical timeline audio and decoded events 0, 1, and 2 back to a window start of -0.0015 seconds. Real headless app sniff did not provide a clean physical proof because Scarlett loopback capture again stopped advancing early; build remains clean."} +{"ts":"2026-05-22T14:32:00+01:00","type":"implementation","status":"ok","note":"Reworked MimirChirpletTimeline symbols from fixed frequency slots into time/frequency constellations. The order-3 de Bruijn sequence still gives three-chirp timeline placement, but each symbol now carries identity through start band, glide shape, duration, and following inter-chirp gap. Event start times are precomputed over the de Bruijn period instead of using a fixed stride. Synthetic verification rendered two seconds of canonical timeline audio and decoded interior events 9, 10, and 11 back to a zero-second window start, proving placement does not rely on the opening triplet."} diff --git a/state/map.yaml b/state/map.yaml index 209b96e..1ebd3a4 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -67,10 +67,11 @@ accepted_design: - The diagnostic audio path can optionally carry base64 float sample payloads for sync smoke tests. `MimirChirpletTimeline` owns the structured birdsong-like timeline fingerprint: an order-3 de Bruijn sequence over 32 - separated chirp symbols, plus PCM segment rendering, matched timing atoms, - symbol/event decoding, and per-band response kernels. Any three consecutive - correctly detected symbols identify a timeline event within the current - operating horizon. `MimirAudioSynchronizationAnalyzer` now treats + time/frequency constellation symbols, plus PCM segment rendering, matched + timing atoms, symbol/event decoding, and per-band response kernels. Symbol + identity is carried by start band, glide shape, duration, and following + inter-chirp gap. Any three consecutive correctly detected symbols identify a + timeline event within the current operating horizon. `MimirAudioSynchronizationAnalyzer` now treats `loopback-scarlett-speakers` as timing authority, uses coarse chirplet energy for acquisition, and refines delay from matched timeline event indices when symbol decoding succeeds. Positive delay means the