Add physical packet ASIO smoke
This commit is contained in:
parent
4c15df11b3
commit
60fcb2c8f6
3 changed files with 175 additions and 2 deletions
|
|
@ -308,6 +308,42 @@ cut is an acquisition state that uses Faust/front-end band flux to find the
|
|||
first clock hypothesis, then switches to scheduled packet windows exactly like
|
||||
this receipt.
|
||||
|
||||
### First Physical ASIO Packet Receipt
|
||||
|
||||
The first physical run used the current Focusrite ASIO path:
|
||||
|
||||
```powershell
|
||||
dotnet run --no-build --project .\src\Mimir.BufferSmoke\Mimir.BufferSmoke.csproj -- --render-contestant-f32 --song canary-packet-trill --output artifacts/asio/canary-packet-192k-f32.raw --sample-rate 192000 --seconds 4
|
||||
.\native\probes\asio_audio_cadence\build\Release\asio_audio_cadence.exe --set-sample-rate 192000 --play-f32-mono artifacts\asio\canary-packet-192k-f32.raw --record-f32-interleaved artifacts\asio\scarlett-canary-packet-192k-f32.raw --play-gain 1.0
|
||||
dotnet run --no-build --project .\src\Mimir.BufferSmoke\Mimir.BufferSmoke.csproj -- --analyze-contestant-asio-f32 --input artifacts\asio\scarlett-canary-packet-192k-f32.raw --sample-rate 192000 --channels 4 --seconds 4 --song canary-packet-trill --schedule-offset-samples 1623
|
||||
```
|
||||
|
||||
The first ASIO attempt accidentally ran at the driver's existing `44100` Hz
|
||||
state despite the requested sample rate. The corrected run used
|
||||
`--set-sample-rate 192000`, captured `765,952` frames at 192 kHz across four
|
||||
inputs, and found the loopback packet by correlation at about `+1623` samples
|
||||
(`8.453 ms`). With that acquisition offset supplied, the streaming packet
|
||||
receiver decoded the loopback channels perfectly:
|
||||
|
||||
```text
|
||||
channel=2 events=37/37 payload=1.000 timing=1.000 confidence=1.000 delaySamples=1623.000000 delayUs=8453.125 maeSamples=0.000000
|
||||
channel=3 events=37/37 payload=1.000 timing=1.000 confidence=1.000 delaySamples=1623.000000 delayUs=8453.125 maeSamples=0.000000
|
||||
```
|
||||
|
||||
The acoustic inputs did not yet prove the room path:
|
||||
|
||||
```text
|
||||
channel=0 events=0/37 payload=0.000 timing=0.000 confidence=0.000
|
||||
channel=1 events=1/37 payload=0.000 timing=1.000 confidence=0.545 delaySamples=1587.500000 delayUs=8268.229
|
||||
```
|
||||
|
||||
Interpretation: the packet machine survives the real Focusrite digital loopback
|
||||
path at 192 kHz. The room/mic path needs either more acoustic level, better mic
|
||||
channel state, or a front-end acquisition pass that can lock before scheduled
|
||||
packet-local decoding takes over. The important architectural result still
|
||||
stands: acquisition and tracking are separate states. Once the clock offset is
|
||||
known, the streaming packet hot loop is tiny and exact.
|
||||
|
||||
### Obsolete Schedule-Entangled Receipt
|
||||
|
||||
The best current receipt is:
|
||||
|
|
|
|||
|
|
@ -136,6 +136,15 @@ if (args.Any(arg => string.Equals(arg, "--render-bioacoustic-f32", StringCompari
|
|||
ParseDoubleOption(args, "--seconds", 3.0));
|
||||
}
|
||||
|
||||
if (args.Any(arg => string.Equals(arg, "--render-contestant-f32", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
return RenderContestantFloat32(
|
||||
ParseStringOption(args, "--output", "artifacts/asio/canary-packet-f32.raw"),
|
||||
ParseIntOption(args, "--sample-rate", MimirBioacousticTimeline.SampleRate),
|
||||
ParseDoubleOption(args, "--seconds", 3.0),
|
||||
ParseStringOption(args, "--song", MimirBioacousticContestants.CanaryPacketTrill.Id));
|
||||
}
|
||||
|
||||
if (args.Any(arg => string.Equals(arg, "--analyze-asio-f32", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
return AnalyzeAsioFloat32(
|
||||
|
|
@ -147,6 +156,18 @@ if (args.Any(arg => string.Equals(arg, "--analyze-asio-f32", StringComparison.Or
|
|||
ParseStringOption(args, "--calibration", ""));
|
||||
}
|
||||
|
||||
if (args.Any(arg => string.Equals(arg, "--analyze-contestant-asio-f32", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
return AnalyzeContestantAsioFloat32(
|
||||
ParseStringOption(args, "--input", "artifacts/asio/scarlett-canary-packet-f32.raw"),
|
||||
ParseIntOption(args, "--sample-rate", MimirBioacousticTimeline.SampleRate),
|
||||
ParseIntOption(args, "--channels", 4),
|
||||
ParseIntOption(args, "--candidate-channel", -1),
|
||||
ParseDoubleOption(args, "--seconds", 3.0),
|
||||
ParseDoubleOption(args, "--schedule-offset-samples", 0.0),
|
||||
ParseStringOption(args, "--song", MimirBioacousticContestants.CanaryPacketTrill.Id));
|
||||
}
|
||||
|
||||
if (args.Any(arg => string.Equals(arg, "--calibrate-chirp-bin-asio-f32", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
return CalibrateChirpBinAsioFloat32(
|
||||
|
|
@ -1505,6 +1526,120 @@ static int RenderBioacousticFloat32(string outputPath, int sampleRate, double se
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int RenderContestantFloat32(string outputPath, int sampleRate, double seconds, string songId)
|
||||
{
|
||||
var profile = MimirBioacousticContestants.BuiltIn.FirstOrDefault(profile =>
|
||||
string.Equals(profile.Id, songId, StringComparison.OrdinalIgnoreCase));
|
||||
if (profile == null)
|
||||
{
|
||||
Console.Error.WriteLine($"contestant render failed: unknown song '{songId}'");
|
||||
return 1;
|
||||
}
|
||||
|
||||
var renderer = new MimirBioacousticContestantRenderer(profile);
|
||||
var samples = renderer.RenderSequenceMonoFloat(seconds, sampleRate);
|
||||
var outputDirectory = Path.GetDirectoryName(outputPath);
|
||||
if (!string.IsNullOrWhiteSpace(outputDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(outputDirectory);
|
||||
}
|
||||
|
||||
var bytes = new byte[samples.Length * sizeof(float)];
|
||||
Buffer.BlockCopy(samples, 0, bytes, 0, bytes.Length);
|
||||
File.WriteAllBytes(outputPath, bytes);
|
||||
Console.WriteLine($"contestant-render-f32 path={outputPath} song={profile.Id} sampleRate={sampleRate} seconds={seconds:0.000} samples={samples.Length} expectedEvents={renderer.ExpectedEventCount(seconds)}");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int AnalyzeContestantAsioFloat32(
|
||||
string inputPath,
|
||||
int sampleRate,
|
||||
int channels,
|
||||
int candidateChannel,
|
||||
double seconds,
|
||||
double scheduleOffsetSamples,
|
||||
string songId)
|
||||
{
|
||||
if (!File.Exists(inputPath))
|
||||
{
|
||||
Console.Error.WriteLine($"contestant-asio analysis failed: input not found: {inputPath}");
|
||||
return 1;
|
||||
}
|
||||
|
||||
var profile = MimirBioacousticContestants.BuiltIn.FirstOrDefault(profile =>
|
||||
string.Equals(profile.Id, songId, StringComparison.OrdinalIgnoreCase));
|
||||
if (profile == null)
|
||||
{
|
||||
Console.Error.WriteLine($"contestant-asio analysis failed: unknown song '{songId}'");
|
||||
return 1;
|
||||
}
|
||||
|
||||
var channelSamples = ReadInterleavedFloat32(inputPath, channels, out var frameCount);
|
||||
if (frameCount == 0)
|
||||
{
|
||||
Console.Error.WriteLine("contestant-asio analysis failed: capture file contains no complete frames");
|
||||
return 1;
|
||||
}
|
||||
|
||||
var renderer = new MimirBioacousticContestantRenderer(profile);
|
||||
var expectedEvents = renderer.ExpectedEvents(seconds > 0.0 ? seconds : frameCount / (double)sampleRate);
|
||||
var options = CepstralDecoderOptions.FromRuntime(MimirBioacousticDecoderConfiguration.PacketRazorIndex) with
|
||||
{
|
||||
ProposalMode = CepstralProposalMode.StreamingPacketRazor,
|
||||
ProposalBudgetMultiplier = 1.0,
|
||||
DenseStepSeconds = 0.0
|
||||
};
|
||||
|
||||
var firstChannel = candidateChannel < 0 ? 0 : candidateChannel;
|
||||
var lastChannel = candidateChannel < 0 ? channels - 1 : candidateChannel;
|
||||
var failures = 0;
|
||||
for (var channel = firstChannel; channel <= lastChannel; channel++)
|
||||
{
|
||||
if (channel < 0 || channel >= channels)
|
||||
{
|
||||
Console.Error.WriteLine($"contestant-asio channel {channel} outside capture channel count {channels}");
|
||||
failures++;
|
||||
continue;
|
||||
}
|
||||
|
||||
var observations = DecodeStreamingPacketRazorWords(
|
||||
channelSamples[channel],
|
||||
sampleRate,
|
||||
expectedEvents.Count,
|
||||
renderer,
|
||||
renderer.RenderEventMonoFloat(0, sampleRate).Length,
|
||||
scheduleOffsetSamples);
|
||||
var expectedObservations = observations
|
||||
.Where(observation => expectedEvents.Contains(observation.EventIndex))
|
||||
.ToArray();
|
||||
var payloads = ClassifyContestantPayloads(
|
||||
channelSamples[channel],
|
||||
sampleRate,
|
||||
options,
|
||||
renderer,
|
||||
expectedObservations,
|
||||
trustObservationPayload: true);
|
||||
var payloadCorrect = expectedObservations.Count(observation =>
|
||||
payloads.TryGetValue(observation.EventIndex, out var payload) &&
|
||||
payload == renderer.PayloadSymbolForEvent(observation.EventIndex));
|
||||
var clock = FitContestantClockHypothesis(expectedObservations, renderer, sampleRate, expectedEvents.Count);
|
||||
var payloadAccuracy = expectedEvents.Count == 0
|
||||
? 0.0
|
||||
: payloadCorrect / (double)expectedEvents.Count;
|
||||
var timingAccuracy = clock == null
|
||||
? 0.0
|
||||
: 1.0 / (1.0 + clock.MeanAbsoluteErrorSamples / Math.Max(1.0, sampleRate * 0.00025));
|
||||
var confidence = expectedObservations.Length == 0
|
||||
? 0.0
|
||||
: expectedObservations.Average(observation => observation.Confidence);
|
||||
Console.WriteLine(
|
||||
$"contestant-asio-f32 channel={channel} song={profile.Id} decoder=packet-razor-streaming-faust events={expectedObservations.Length}/{expectedEvents.Count} payload={payloadAccuracy:0.000} timing={timingAccuracy:0.000} confidence={confidence:0.000} " +
|
||||
$"delaySamples={(clock?.SourceOffsetSamples ?? 0.0):0.000000} delayUs={(clock?.SourceOffsetSamples ?? 0.0) * 1_000_000.0 / sampleRate:0.000} maeSamples={(clock?.MeanAbsoluteErrorSamples ?? 0.0):0.000000}");
|
||||
}
|
||||
|
||||
return failures == 0 ? 0 : 1;
|
||||
}
|
||||
|
||||
static IReadOnlyList<BioacousticTrainingHypothesis> BioacousticTrainingHypotheses()
|
||||
{
|
||||
var baseProfiles = MimirBioacousticDecoderConfiguration.BuiltInProfiles
|
||||
|
|
@ -2169,7 +2304,8 @@ static IReadOnlyList<CepstralWordObservation> DecodeStreamingPacketRazorWords(
|
|||
int sampleRate,
|
||||
int expectedEventCount,
|
||||
MimirBioacousticContestantRenderer contestant,
|
||||
int motifSamples)
|
||||
int motifSamples,
|
||||
double scheduleOffsetSamples = 0.0)
|
||||
{
|
||||
if (expectedEventCount <= 0 || samples.Length < motifSamples)
|
||||
{
|
||||
|
|
@ -2181,7 +2317,7 @@ static IReadOnlyList<CepstralWordObservation> DecodeStreamingPacketRazorWords(
|
|||
var observations = new List<CepstralWordObservation>(expectedEventCount);
|
||||
for (var eventIndex = 0; eventIndex < expectedEventCount; eventIndex++)
|
||||
{
|
||||
var center = (int)Math.Round(contestant.EventStartSeconds((ulong)eventIndex) * sampleRate);
|
||||
var center = (int)Math.Round(contestant.EventStartSeconds((ulong)eventIndex) * sampleRate + scheduleOffsetSamples);
|
||||
var start = Math.Max(0, center - searchRadius);
|
||||
var end = Math.Min(samples.Length - motifSamples, center + searchRadius);
|
||||
if (start > end)
|
||||
|
|
|
|||
|
|
@ -91,3 +91,4 @@
|
|||
{"ts": "2026-05-24T22:26:12+01:00", "type": "experiment", "status": "ok", "note": "Added log-mel-domain warp/blur damage and log-mel spectral-flux proposal decoder variants to the bioacoustic contestant arena. Canary packet plus packet-razor-index remains best: 92.522 language score on logmel-warp-light-blur. Naive flux proposals preserve anchors but lose to managed FFT overhead, so fuse flux into the existing feature pass before promoting it."}
|
||||
{"ts": "2026-05-24T22:46:18+01:00", "type": "experiment", "status": "ok", "note": "Built packet-razor-streaming-faust: schedule-owned local packet windows with four payload hypotheses and tiny timing refinement, plus Faust front-end lowering target. Arena result on canary-packet-trill: best language score 1121.012 on logmel-blur-light, 62.6x realtime, 6/6 events, 100% payload. Lesson: wide MFCC search is acquisition/reference; hot loop should lock clock then inspect scheduled local packet windows."}
|
||||
{"ts": "2026-05-24T22:47:10+01:00", "type": "verification", "status": "ok", "note": "Verified faust/mimir_packet_razor_frontend.dsp with Faust 2.85.5 C++ generation. The DSP front-end exposes 16 log-spaced resonant band-energy outputs plus 16 positive-flux outputs for the packet razor streaming receiver lowering target."}
|
||||
{"ts": "2026-05-24T23:04:57+01:00", "type": "experiment", "status": "partial", "note": "First real-world packet razor ASIO test: rendered canary-packet-trill at 192 kHz, played through Focusrite ASIO, captured four inputs. Corrected probe needed --set-sample-rate 192000; first run stayed at 44.1 kHz. Loopback channels 2/3 correlated at +1623 samples and decoded 37/37 events with payload=1.000, timing=1.000, delay=8453.125 us. Acoustic channel 1 decoded only 1/37 and channel 0 none, so room/mic path still needs acquisition/level/channel work."}
|
||||
|
|
|
|||
Loading…
Reference in a new issue