Optimize live chirplet decoder
This commit is contained in:
parent
b0dbf4bbff
commit
51780d8e7f
6 changed files with 131 additions and 33 deletions
|
|
@ -76,7 +76,7 @@ foreach (var state in hub.AudioSynchronizationStates)
|
|||
foreach (var trace in hub.AudioSynchronizationDecodeTraces.OrderBy(trace => trace.SourceId, StringComparer.Ordinal))
|
||||
{
|
||||
Console.WriteLine(
|
||||
$"sync-decode {trace.ReferenceSourceId}->{trace.SourceId}: status={trace.Status} compared={trace.ComparedSamples} rate={trace.SampleRate} refFrames={trace.ReferenceFrames} refAnchors={trace.ReferenceAnchors} refClock={trace.ReferenceClockConfidence:0.000} candFrames={trace.CandidateFrames} candAnchors={trace.CandidateAnchors} candClock={trace.CandidateClockConfidence:0.000} matched={trace.MatchedEvents} confidence={trace.Confidence:0.000}");
|
||||
$"sync-decode {trace.ReferenceSourceId}->{trace.SourceId}: status={trace.Status} compared={trace.ComparedSamples} rate={trace.SampleRate} refFrames={trace.ReferenceFrames} refAnchors={trace.ReferenceAnchors} refClock={trace.ReferenceClockConfidence:0.000} refEnergy={trace.ReferenceBestEnergy:0.000} candFrames={trace.CandidateFrames} candAnchors={trace.CandidateAnchors} candClock={trace.CandidateClockConfidence:0.000} candEnergy={trace.CandidateBestEnergy:0.000} matched={trace.MatchedEvents} confidence={trace.Confidence:0.000}");
|
||||
}
|
||||
|
||||
if (requireSamples && emptyBuffers.Count > 0)
|
||||
|
|
|
|||
|
|
@ -5,13 +5,14 @@ using Aquarium.Engine.Render;
|
|||
using Aquarium.Engine.Ui;
|
||||
using Aquarium.LocalCast;
|
||||
using Mimir.Runtime.Synchronization;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Mimir.Runtime;
|
||||
|
||||
public sealed class MimirRuntime : IAquariumRuntime
|
||||
{
|
||||
private const string DefaultAudioSyncReference = "loopback-scarlett-speakers";
|
||||
private const float AudioSyncUpdateIntervalSeconds = 0.1f;
|
||||
private const float DefaultAudioSyncUpdateIntervalSeconds = 0.1f;
|
||||
private const double CalibrationStartSeconds = 0.5;
|
||||
private const int CalibrationBatchSegments = 120;
|
||||
private const float DefaultCalibrationGain = 2.0f;
|
||||
|
|
@ -19,12 +20,14 @@ public sealed class MimirRuntime : IAquariumRuntime
|
|||
private readonly MimirSynchronizationHub synchronization;
|
||||
private readonly AquariumUiDocument ui;
|
||||
private readonly float telemetryIntervalSeconds;
|
||||
private readonly float audioSyncUpdateIntervalSeconds;
|
||||
private readonly float calibrationGain;
|
||||
private int lastPollCount;
|
||||
private float runtimeSeconds;
|
||||
private float nextAudioSyncSeconds = AudioSyncUpdateIntervalSeconds;
|
||||
private float nextAudioSyncSeconds;
|
||||
private float nextTelemetrySeconds;
|
||||
private ulong calibrationSegmentIndex;
|
||||
private double lastAudioSyncAnalysisMilliseconds;
|
||||
private IReadOnlyList<MimirAudioSynchronizationReport> lastAudioSynchronizationReports = [];
|
||||
|
||||
public MimirRuntime(AquariumRuntimeOptions options)
|
||||
|
|
@ -51,7 +54,9 @@ public sealed class MimirRuntime : IAquariumRuntime
|
|||
visualRuntime = new LocalCastRuntime(options);
|
||||
synchronization = new MimirSynchronizationHub(settings);
|
||||
telemetryIntervalSeconds = ParseTelemetryIntervalSeconds();
|
||||
audioSyncUpdateIntervalSeconds = ParseAudioSyncIntervalSeconds();
|
||||
calibrationGain = ParseCalibrationGain();
|
||||
nextAudioSyncSeconds = audioSyncUpdateIntervalSeconds;
|
||||
nextTelemetrySeconds = telemetryIntervalSeconds;
|
||||
foreach (var source in streamSources)
|
||||
{
|
||||
|
|
@ -193,9 +198,12 @@ public sealed class MimirRuntime : IAquariumRuntime
|
|||
return;
|
||||
}
|
||||
|
||||
var stopwatch = Stopwatch.StartNew();
|
||||
synchronization.AnalyzeAudioSynchronizationStep(DefaultAudioSyncReference);
|
||||
stopwatch.Stop();
|
||||
lastAudioSyncAnalysisMilliseconds = stopwatch.Elapsed.TotalMilliseconds;
|
||||
lastAudioSynchronizationReports = synchronization.AudioSynchronizationReports;
|
||||
nextAudioSyncSeconds += AudioSyncUpdateIntervalSeconds;
|
||||
nextAudioSyncSeconds = runtimeSeconds + audioSyncUpdateIntervalSeconds;
|
||||
}
|
||||
|
||||
private void EmitTelemetry()
|
||||
|
|
@ -209,7 +217,7 @@ public sealed class MimirRuntime : IAquariumRuntime
|
|||
string.Equals(buffer.Descriptor.SourceId, DefaultAudioSyncReference, StringComparison.Ordinal));
|
||||
var states = synchronization.AudioSynchronizationStates;
|
||||
Console.WriteLine(
|
||||
$"mimir-sync-telemetry t={runtimeSeconds:0.00}s loopbackCount={loopback?.Count ?? 0} loopbackEdgeNs={loopback?.EdgeNs ?? 0} reports={lastAudioSynchronizationReports.Count} states={states.Count} aligned={DescribeAlignedAudio()}");
|
||||
$"mimir-sync-telemetry t={runtimeSeconds:0.00}s loopbackCount={loopback?.Count ?? 0} loopbackEdgeNs={loopback?.EdgeNs ?? 0} reports={lastAudioSynchronizationReports.Count} states={states.Count} analyzeMs={lastAudioSyncAnalysisMilliseconds:0.0} aligned={DescribeAlignedAudio()}");
|
||||
Console.WriteLine($"mimir-sync-buffers {DescribeAudioBuffers()}");
|
||||
foreach (var report in lastAudioSynchronizationReports.OrderBy(report => report.SourceId, StringComparer.Ordinal))
|
||||
{
|
||||
|
|
@ -226,7 +234,7 @@ public sealed class MimirRuntime : IAquariumRuntime
|
|||
foreach (var trace in synchronization.AudioSynchronizationDecodeTraces.OrderBy(trace => trace.SourceId, StringComparer.Ordinal))
|
||||
{
|
||||
Console.WriteLine(
|
||||
$"mimir-sync-decode {trace.ReferenceSourceId}->{trace.SourceId} status={trace.Status} compared={trace.ComparedSamples} rate={trace.SampleRate} refFrames={trace.ReferenceFrames} refAnchors={trace.ReferenceAnchors} refClock={trace.ReferenceClockConfidence:0.000} candFrames={trace.CandidateFrames} candAnchors={trace.CandidateAnchors} candClock={trace.CandidateClockConfidence:0.000} matched={trace.MatchedEvents} confidence={trace.Confidence:0.000}");
|
||||
$"mimir-sync-decode {trace.ReferenceSourceId}->{trace.SourceId} status={trace.Status} compared={trace.ComparedSamples} rate={trace.SampleRate} refFrames={trace.ReferenceFrames} refAnchors={trace.ReferenceAnchors} refClock={trace.ReferenceClockConfidence:0.000} refEnergy={trace.ReferenceBestEnergy:0.000} candFrames={trace.CandidateFrames} candAnchors={trace.CandidateAnchors} candClock={trace.CandidateClockConfidence:0.000} candEnergy={trace.CandidateBestEnergy:0.000} matched={trace.MatchedEvents} confidence={trace.Confidence:0.000}");
|
||||
}
|
||||
|
||||
nextTelemetrySeconds += telemetryIntervalSeconds;
|
||||
|
|
@ -239,6 +247,13 @@ public sealed class MimirRuntime : IAquariumRuntime
|
|||
: 0.0f;
|
||||
}
|
||||
|
||||
private static float ParseAudioSyncIntervalSeconds()
|
||||
{
|
||||
return float.TryParse(Environment.GetEnvironmentVariable("MIMIR_AUDIO_SYNC_INTERVAL_SECONDS"), out var seconds)
|
||||
? Math.Clamp(seconds, 0.1f, 10.0f)
|
||||
: DefaultAudioSyncUpdateIntervalSeconds;
|
||||
}
|
||||
|
||||
private static float ParseCalibrationGain()
|
||||
{
|
||||
return float.TryParse(Environment.GetEnvironmentVariable("MIMIR_CHIRPLET_GAIN"), out var gain)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ namespace Mimir.Runtime.Synchronization;
|
|||
public sealed class MimirAudioSynchronizationAnalyzer
|
||||
{
|
||||
private const int MaxWindowSamples = 48_000 * 2;
|
||||
private const double MinDecodeWindowSeconds = 2.0;
|
||||
private readonly List<MimirAudioSynchronizationDecodeTrace> lastDecodeTraces = [];
|
||||
|
||||
public IReadOnlyList<MimirAudioSynchronizationDecodeTrace> LastDecodeTraces => lastDecodeTraces;
|
||||
|
|
@ -67,27 +68,46 @@ public sealed class MimirAudioSynchronizationAnalyzer
|
|||
candidateSamples = ResampleToRate(candidateSamples, candidateBlock.SampleRate, referenceBlock.SampleRate);
|
||||
|
||||
var compared = Math.Min(referenceSamples.Length, candidateSamples.Length);
|
||||
if (compared < 256)
|
||||
var minDecodeSamples = Math.Min(MaxWindowSamples, (int)Math.Ceiling(referenceBlock.SampleRate * MinDecodeWindowSeconds));
|
||||
if (compared < minDecodeSamples)
|
||||
{
|
||||
lastDecodeTraces.Add(new MimirAudioSynchronizationDecodeTrace(
|
||||
reference.Descriptor.SourceId,
|
||||
buffer.Descriptor.SourceId,
|
||||
referenceBlock.SampleRate,
|
||||
compared,
|
||||
0,
|
||||
0,
|
||||
0.0,
|
||||
0.0,
|
||||
0,
|
||||
0,
|
||||
0.0,
|
||||
0.0,
|
||||
0,
|
||||
0.0,
|
||||
"insufficient-window"));
|
||||
continue;
|
||||
}
|
||||
|
||||
var referenceWindow = referenceSamples.AsSpan(^compared..);
|
||||
var candidateWindow = candidateSamples.AsSpan(^compared..);
|
||||
var referenceDecode = MimirChirpletTimeline.Default.DecodeStreamWindow(referenceWindow, referenceBlock.SampleRate);
|
||||
var comparedReferenceDecode = MimirChirpletTimeline.Default.DecodeStreamWindow(referenceWindow, referenceBlock.SampleRate);
|
||||
var candidateDecode = MimirChirpletTimeline.Default.DecodeStreamWindow(candidateWindow, referenceBlock.SampleRate);
|
||||
var deterministicFit = EstimateDelayFromDecodedTimeline(referenceDecode, candidateDecode);
|
||||
var deterministicFit = EstimateDelayFromDecodedTimeline(comparedReferenceDecode, candidateDecode);
|
||||
lastDecodeTraces.Add(new MimirAudioSynchronizationDecodeTrace(
|
||||
reference.Descriptor.SourceId,
|
||||
buffer.Descriptor.SourceId,
|
||||
referenceBlock.SampleRate,
|
||||
compared,
|
||||
referenceDecode.Frames.Count,
|
||||
referenceDecode.Anchors.Count,
|
||||
referenceDecode.ClockFit?.Confidence ?? 0.0,
|
||||
comparedReferenceDecode.Frames.Count,
|
||||
comparedReferenceDecode.Anchors.Count,
|
||||
comparedReferenceDecode.ClockFit?.Confidence ?? 0.0,
|
||||
BestFrameEnergy(comparedReferenceDecode),
|
||||
candidateDecode.Frames.Count,
|
||||
candidateDecode.Anchors.Count,
|
||||
candidateDecode.ClockFit?.Confidence ?? 0.0,
|
||||
BestFrameEnergy(candidateDecode),
|
||||
deterministicFit.MatchedEvents,
|
||||
deterministicFit.Confidence,
|
||||
deterministicFit.MatchedEvents >= 3 ? "report" : "insufficient-anchors"));
|
||||
|
|
@ -118,6 +138,13 @@ public sealed class MimirAudioSynchronizationAnalyzer
|
|||
return reports;
|
||||
}
|
||||
|
||||
private static double BestFrameEnergy(MimirChirpletStreamDecode decode)
|
||||
{
|
||||
return decode.Frames.Count == 0
|
||||
? 0.0
|
||||
: decode.Frames.Max(frame => frame.BestCandidate.Energy);
|
||||
}
|
||||
|
||||
private static (double DelaySamples, double Confidence, int MatchedEvents) EstimateDelayFromDecodedTimeline(
|
||||
MimirChirpletStreamDecode reference,
|
||||
MimirChirpletStreamDecode candidate)
|
||||
|
|
|
|||
|
|
@ -8,9 +8,11 @@ public sealed record MimirAudioSynchronizationDecodeTrace(
|
|||
int ReferenceFrames,
|
||||
int ReferenceAnchors,
|
||||
double ReferenceClockConfidence,
|
||||
double ReferenceBestEnergy,
|
||||
int CandidateFrames,
|
||||
int CandidateAnchors,
|
||||
double CandidateClockConfidence,
|
||||
double CandidateBestEnergy,
|
||||
int MatchedEvents,
|
||||
double Confidence,
|
||||
string Status);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
namespace Mimir.Runtime.Synchronization;
|
||||
|
||||
using System.Numerics;
|
||||
|
||||
public sealed record MimirChirpletTone(
|
||||
double StartSeconds,
|
||||
double DurationSeconds,
|
||||
|
|
@ -35,6 +37,7 @@ public sealed class MimirChirpletTimeline
|
|||
private const double MaxEventDurationSeconds = 0.078;
|
||||
private const double Gain = 0.090;
|
||||
private const int MaxSymbolCandidatesPerFrame = 8;
|
||||
private const double CandidateOffsetBudgetMultiplier = 1.5;
|
||||
|
||||
private static readonly int[] TimelineSymbols = RotateToDistinctOpening(BuildDeBruijn(SymbolCount, TimelineOrder));
|
||||
private static readonly Dictionary<int, int> TripleToIndex = BuildTripleIndex(TimelineSymbols);
|
||||
|
|
@ -42,10 +45,12 @@ public sealed class MimirChirpletTimeline
|
|||
private static readonly double[] PeriodEventStarts = BuildPeriodEventStarts(TimelineSymbols);
|
||||
private static readonly double PeriodDurationSeconds = PeriodEventStarts[^1] + Codebook[TimelineSymbols[^1]].GapSeconds;
|
||||
private readonly IReadOnlyList<MimirChirpletToneKernel> symbolKernels;
|
||||
private readonly Dictionary<int, IReadOnlyList<MimirChirpletToneKernel>> symbolKernelsBySampleRate = [];
|
||||
|
||||
private MimirChirpletTimeline()
|
||||
{
|
||||
symbolKernels = Codebook.Symbols.Select(symbol => RenderToneKernel(symbol.Tone, SampleRate)).ToArray();
|
||||
symbolKernelsBySampleRate[SampleRate] = symbolKernels;
|
||||
}
|
||||
|
||||
public static MimirChirpletTimeline Default { get; } = new();
|
||||
|
|
@ -89,10 +94,11 @@ public sealed class MimirChirpletTimeline
|
|||
}
|
||||
|
||||
var responses = new List<MimirChirpletBandResponse>(Codebook.Symbols.Count);
|
||||
var kernels = GetSymbolKernels(sampleRate);
|
||||
for (var symbol = 0; symbol < Codebook.Symbols.Count; symbol++)
|
||||
{
|
||||
var tone = Codebook[symbol].Tone;
|
||||
var kernel = sampleRate == SampleRate ? symbolKernels[symbol] : RenderToneKernel(tone, sampleRate);
|
||||
var kernel = kernels[symbol];
|
||||
var energy = MaxMatchedEnergy(samples, kernel, Math.Max(1, sampleRate / 1_000));
|
||||
responses.Add(new MimirChirpletBandResponse(tone.CenterHz, energy));
|
||||
}
|
||||
|
|
@ -162,7 +168,7 @@ public sealed class MimirChirpletTimeline
|
|||
}
|
||||
|
||||
var frames = new List<MimirChirpletTransformFrame>();
|
||||
var candidateOffsets = new SortedSet<int>();
|
||||
var candidateScores = new Dictionary<int, double>();
|
||||
for (var frame = 1; frame < trace.Count - 1; frame++)
|
||||
{
|
||||
if (trace[frame] < 0.05 ||
|
||||
|
|
@ -172,7 +178,7 @@ public sealed class MimirChirpletTimeline
|
|||
continue;
|
||||
}
|
||||
|
||||
candidateOffsets.Add(frame * hopSamples);
|
||||
AddCandidateScore(candidateScores, frame * hopSamples, trace[frame]);
|
||||
}
|
||||
|
||||
var envelope = ContrastNormalize(BuildEnvelopeEnergyTrace(samples, sampleRate, hopSamples));
|
||||
|
|
@ -185,16 +191,23 @@ public sealed class MimirChirpletTimeline
|
|||
continue;
|
||||
}
|
||||
|
||||
candidateOffsets.Add(frame * hopSamples);
|
||||
AddCandidateScore(candidateScores, frame * hopSamples, envelope[frame]);
|
||||
}
|
||||
|
||||
foreach (var offset in candidateOffsets)
|
||||
var maxExpectedEvents = Math.Max(
|
||||
8,
|
||||
(int)Math.Ceiling(samples.Length / (double)sampleRate / MinEventGapSeconds * CandidateOffsetBudgetMultiplier));
|
||||
foreach (var offset in candidateScores
|
||||
.OrderByDescending(pair => pair.Value)
|
||||
.Take(maxExpectedEvents)
|
||||
.Select(pair => pair.Key)
|
||||
.Order())
|
||||
{
|
||||
var transformFrame = ClassifySymbolsAt(
|
||||
samples,
|
||||
sampleRate,
|
||||
offset,
|
||||
Math.Max(hopSamples * 3, sampleRate / 100));
|
||||
hopSamples * 3);
|
||||
if (transformFrame != null)
|
||||
{
|
||||
frames.Add(transformFrame);
|
||||
|
|
@ -204,17 +217,25 @@ public sealed class MimirChirpletTimeline
|
|||
return SuppressNearbyFrames(frames, sampleRate);
|
||||
}
|
||||
|
||||
private static void AddCandidateScore(Dictionary<int, double> candidateScores, int offset, double score)
|
||||
{
|
||||
if (!candidateScores.TryGetValue(offset, out var existing) || score > existing)
|
||||
{
|
||||
candidateScores[offset] = score;
|
||||
}
|
||||
}
|
||||
|
||||
private MimirChirpletTransformFrame? ClassifySymbolsAt(
|
||||
ReadOnlySpan<float> samples,
|
||||
int sampleRate,
|
||||
int predictedOffset,
|
||||
int searchRadiusSamples)
|
||||
{
|
||||
var kernels = GetSymbolKernels(sampleRate);
|
||||
var candidates = new List<MimirChirpletSymbolCandidate>(Codebook.Symbols.Count);
|
||||
for (var symbol = 0; symbol < Codebook.Symbols.Count; symbol++)
|
||||
{
|
||||
var tone = Codebook[symbol].Tone;
|
||||
var kernel = sampleRate == SampleRate ? symbolKernels[symbol] : RenderToneKernel(tone, sampleRate);
|
||||
var kernel = kernels[symbol];
|
||||
if (kernel.Length == 0 || samples.Length < kernel.Length)
|
||||
{
|
||||
continue;
|
||||
|
|
@ -618,6 +639,18 @@ public sealed class MimirChirpletTimeline
|
|||
return new MimirChirpletToneKernel(sine, cosine);
|
||||
}
|
||||
|
||||
private IReadOnlyList<MimirChirpletToneKernel> GetSymbolKernels(int sampleRate)
|
||||
{
|
||||
if (symbolKernelsBySampleRate.TryGetValue(sampleRate, out var kernels))
|
||||
{
|
||||
return kernels;
|
||||
}
|
||||
|
||||
kernels = Codebook.Symbols.Select(symbol => RenderToneKernel(symbol.Tone, sampleRate)).ToArray();
|
||||
symbolKernelsBySampleRate[sampleRate] = kernels;
|
||||
return kernels;
|
||||
}
|
||||
|
||||
private static void AddTone(
|
||||
float[] samples,
|
||||
int sampleRate,
|
||||
|
|
@ -655,9 +688,30 @@ public sealed class MimirChirpletTimeline
|
|||
var sineDot = 0.0;
|
||||
var cosineDot = 0.0;
|
||||
var sampleEnergy = 0.0;
|
||||
var sineEnergy = 0.0;
|
||||
var cosineEnergy = 0.0;
|
||||
for (var index = 0; index < count; index++)
|
||||
var index = 0;
|
||||
if (Vector.IsHardwareAccelerated)
|
||||
{
|
||||
var sineDotVector = Vector<float>.Zero;
|
||||
var cosineDotVector = Vector<float>.Zero;
|
||||
var sampleEnergyVector = Vector<float>.Zero;
|
||||
var width = Vector<float>.Count;
|
||||
for (; index <= count - width; index += width)
|
||||
{
|
||||
var sampleVector = new Vector<float>(samples.Slice(index, width));
|
||||
sineDotVector += sampleVector * new Vector<float>(kernel.Sine.AsSpan(index, width));
|
||||
cosineDotVector += sampleVector * new Vector<float>(kernel.Cosine.AsSpan(index, width));
|
||||
sampleEnergyVector += sampleVector * sampleVector;
|
||||
}
|
||||
|
||||
for (var lane = 0; lane < width; lane++)
|
||||
{
|
||||
sineDot += sineDotVector[lane];
|
||||
cosineDot += cosineDotVector[lane];
|
||||
sampleEnergy += sampleEnergyVector[lane];
|
||||
}
|
||||
}
|
||||
|
||||
for (; index < count; index++)
|
||||
{
|
||||
var sample = samples[index];
|
||||
var sine = kernel.Sine[index];
|
||||
|
|
@ -665,11 +719,9 @@ public sealed class MimirChirpletTimeline
|
|||
sineDot += sample * sine;
|
||||
cosineDot += sample * cosine;
|
||||
sampleEnergy += sample * sample;
|
||||
sineEnergy += sine * sine;
|
||||
cosineEnergy += cosine * cosine;
|
||||
}
|
||||
|
||||
var denominator = Math.Sqrt(sampleEnergy * Math.Max(sineEnergy, cosineEnergy));
|
||||
var denominator = Math.Sqrt(sampleEnergy * kernel.Energy);
|
||||
if (denominator <= 1.0e-12)
|
||||
{
|
||||
return 0.0;
|
||||
|
|
@ -680,10 +732,8 @@ public sealed class MimirChirpletTimeline
|
|||
|
||||
private IReadOnlyList<double> BuildChirpletEnergyTrace(ReadOnlySpan<float> samples, int sampleRate, int hopSamples)
|
||||
{
|
||||
var maxKernelLength = Codebook.Symbols
|
||||
.Select(symbol => sampleRate == SampleRate ? symbolKernels[symbol.SymbolId].Length : RenderToneKernel(symbol.Tone, sampleRate).Length)
|
||||
.DefaultIfEmpty(0)
|
||||
.Max();
|
||||
var kernels = GetSymbolKernels(sampleRate);
|
||||
var maxKernelLength = kernels.Select(kernel => kernel.Length).DefaultIfEmpty(0).Max();
|
||||
if (samples.Length < maxKernelLength || maxKernelLength == 0)
|
||||
{
|
||||
return [];
|
||||
|
|
@ -694,10 +744,9 @@ public sealed class MimirChirpletTimeline
|
|||
{
|
||||
var offset = frame * hopSamples;
|
||||
var best = 0.0;
|
||||
for (var symbol = 0; symbol < Codebook.Symbols.Count; symbol++)
|
||||
for (var symbol = 0; symbol < kernels.Count; symbol++)
|
||||
{
|
||||
var tone = Codebook[symbol].Tone;
|
||||
var kernel = sampleRate == SampleRate ? symbolKernels[symbol] : RenderToneKernel(tone, sampleRate);
|
||||
var kernel = kernels[symbol];
|
||||
if (offset + kernel.Length > samples.Length)
|
||||
{
|
||||
continue;
|
||||
|
|
@ -804,5 +853,9 @@ public sealed class MimirChirpletTimeline
|
|||
private sealed record MimirChirpletToneKernel(float[] Sine, float[] Cosine)
|
||||
{
|
||||
public int Length => Sine.Length;
|
||||
|
||||
public double Energy { get; } = Math.Max(
|
||||
Sine.Sum(sample => sample * sample),
|
||||
Cosine.Sum(sample => sample * sample));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,3 +50,4 @@
|
|||
{"ts":"2026-05-22T17:45:00+01:00","type":"implementation","status":"ok","note":"Replaced single-phase chirplet matching with quadrature sine/cosine kernels and fixed emitted timeline segment gain so canonical chirps are not amplitude-renormalized per half-second segment. Added `Mimir.BufferSmoke --chirplet-self-test` as a first-class synthetic invariant check. The check renders two seconds of canonical timeline audio, detects all 15 emitted chirps, keeps 13 triplet anchors for events 0-12, fits clock=47999.999990 Hz with confidence=1.000, and holds anchor MAE to 0.000014 samples. The next proof is the same deterministic anchor stability through actual loopback and microphone paths."}
|
||||
{"ts": "2026-05-22T15:52:26+00:00", "type": "implementation", "status": "ok", "note": "Restored the repo-local Python persistence helpers from the Epiphany-style helper family after checking VoidBot and sibling repos. Mimir now has tools/localcast_state.py for status/evidence/branch edits and tools/localcast_prepare_compaction.py for pre-compaction state audits; AGENTS.md points future agents at both helpers."}
|
||||
{"ts": "2026-05-22T17:34:45+01:00", "type": "verification", "status": "ok", "note": "Aquarium WASAPI resampler used int multiplication for source.Length * targetSampleRate; a 60s 48k chirplet batch overflowed and queued one 44.1k output frame. Switching to double-length arithmetic restored 2,646,000 output frames and audible chirplets."}
|
||||
{"ts": "2026-05-22T18:08:51+01:00", "type": "verification", "status": "partial", "note": "Release live chirplet decoder test: Scarlett loopback->Scarlett mic produced repeated runtime reports in ~230-335 ms per 2s analysis window, typically 3-5 matched timeline events. Pair tests also produced reports for Kiyo mic. Kiyo Pro and both USB Camera mics showed chirplet energy but failed to form valid triplet anchors in this pass. Six-audio-source fan-out exposed process-probe buffer continuity/overlap failures, with many candidates rejected as insufficient-window."}
|
||||
|
|
|
|||
Loading…
Reference in a new issue