Shape canary packets with intra-call anchors
This commit is contained in:
parent
4222d6533f
commit
880a7b5abf
7 changed files with 23482 additions and 8 deletions
23162
calibration/bioacoustic/scarlett-canary-packet-anchor-rich-192k.json
Normal file
23162
calibration/bioacoustic/scarlett-canary-packet-anchor-rich-192k.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -37,6 +37,10 @@ what did this room/mic path do to the spectrum?
|
|||
syllable onsets, bends, formants, rhythm offsets, payload ornaments, and
|
||||
speaker-colored spectral features all become anchors in log-mel space. One
|
||||
successful call can pin a cluster of time/frequency constraints at once.
|
||||
- The first anchor-rich canary packet explicitly shapes timing chips, formant
|
||||
pivots, harmonic-envelope notches, and payload ornaments. Calibration receipts
|
||||
now persist those intra-call anchors so path learning can discover which
|
||||
features survive each output/mic pair.
|
||||
- Runtime emission sends the left vocabulary to the left speaker and the right
|
||||
vocabulary to the right speaker, so microphones can learn each side of the
|
||||
room separately.
|
||||
|
|
@ -148,4 +152,6 @@ the first physical packet-song response model. The current Scarlett canary
|
|||
receipt clears 10x realtime and proves that a single song word can own local
|
||||
identity; the remaining work is to make each syllable/formant contour emit
|
||||
enough stable anchors that physical mic residuals collapse from tens of
|
||||
microseconds toward the one-microsecond target.
|
||||
microseconds toward the one-microsecond target. The first anchor-rich receipt
|
||||
improves loopback but not the physical mics, which means anchor observability is
|
||||
now present and anchor survivability is the next design problem.
|
||||
|
|
|
|||
|
|
@ -214,6 +214,15 @@ co-streamer shotgun to 37/37 payload with 34.083 us MAE, and improves the
|
|||
cardioid event count to 31/37 while still measuring 92.996 us MAE. The next
|
||||
precision cut must extract intra-call contour anchors, not only one offset per
|
||||
packet word.
|
||||
The first anchor-rich canary packet is persisted at
|
||||
`calibration/bioacoustic/scarlett-canary-packet-anchor-rich-192k.json`.
|
||||
It adds timing chips, formant pivots, harmonic-envelope notches, payload
|
||||
ornaments, renderer-level template caching, and per-event intra-call anchor
|
||||
measurements. It clears 10x realtime and improves loopback to about 2.23 us
|
||||
MAE, but physical mics do not improve yet: shotgun is 36/37 payload at
|
||||
56.365 us MAE and cardioid is 27/37 payload at 101.522 us MAE. Treat this as
|
||||
anchor observability, not a finished anchor geometry. The next cut should learn
|
||||
which anchor kinds survive each acoustic path and weight or reshape them.
|
||||
The first actuator proof now exists: `faust/mimir_alignment_actuator.dsp` owns
|
||||
six channels of bounded fractional delay/gain controls for Faust/native DSP,
|
||||
and `Mimir.BufferSmoke --bioacoustic-actuator-self-test --sample-rate 48000
|
||||
|
|
|
|||
|
|
@ -1762,7 +1762,7 @@ static int CalibrateContestantAsioFloat32(
|
|||
foreach (var channel in channelCalibrations)
|
||||
{
|
||||
Console.WriteLine(
|
||||
$"contestant-calibration-channel {channel.SourceId}: events={channel.DetectedEvents}/{channel.ExpectedEvents} payload={channel.PayloadAccuracy:0.000} confidence={channel.Confidence:0.000} polarity={channel.Polarity:+0;-0;0} scheduleOffsetSamples={channel.ScheduleOffsetSamples:0.000} offsetSamples={channel.SourceOffsetSamples:0.000000} offsetUs={channel.SourceOffsetSamples * 1_000_000.0 / sampleRate:0.000} maeSamples={channel.MeanAbsoluteErrorSamples:0.000000} maeUs={channel.MeanAbsoluteErrorSamples * 1_000_000.0 / sampleRate:0.000} rms={channel.Rms:0.000000} peak={channel.Peak:0.000000} usableBands={channel.Bands.Count(band => band.Usable)}/{channel.Bands.Length}");
|
||||
$"contestant-calibration-channel {channel.SourceId}: events={channel.DetectedEvents}/{channel.ExpectedEvents} payload={channel.PayloadAccuracy:0.000} confidence={channel.Confidence:0.000} polarity={channel.Polarity:+0;-0;0} scheduleOffsetSamples={channel.ScheduleOffsetSamples:0.000} offsetSamples={channel.SourceOffsetSamples:0.000000} offsetUs={channel.SourceOffsetSamples * 1_000_000.0 / sampleRate:0.000} maeSamples={channel.MeanAbsoluteErrorSamples:0.000000} maeUs={channel.MeanAbsoluteErrorSamples * 1_000_000.0 / sampleRate:0.000} anchors={channel.AnchorCount} anchorMeanResidualSamples={channel.MeanAnchorResidualSamples:0.000000} rms={channel.Rms:0.000000} peak={channel.Peak:0.000000} usableBands={channel.Bands.Count(band => band.Usable)}/{channel.Bands.Length}");
|
||||
}
|
||||
|
||||
foreach (var path in paths)
|
||||
|
|
@ -2617,6 +2617,14 @@ static BioacousticPhysicalChannelCalibration CalibrateContestantChannel(
|
|||
}
|
||||
|
||||
var residual = ComputeContestantResidual(samples, template, (int)Math.Round(refinedOffset), motifSamples, signedScore);
|
||||
var anchors = MeasureContestantAnchors(
|
||||
samples,
|
||||
template,
|
||||
renderer,
|
||||
eventIndex,
|
||||
sampleRate,
|
||||
refinedOffset,
|
||||
motifSamples);
|
||||
var delaySamples = refinedOffset - renderer.EventStartSeconds(eventIndex) * sampleRate;
|
||||
observations.Add(new BioacousticPhysicalEventCalibration(
|
||||
eventIndex,
|
||||
|
|
@ -2627,10 +2635,11 @@ static BioacousticPhysicalChannelCalibration CalibrateContestantChannel(
|
|||
Math.Clamp(Math.Abs(signedScore), 0.0, 1.0),
|
||||
polarity,
|
||||
residual,
|
||||
EstimateContestantEventBands(samples, template, renderer, eventIndex, sampleRate, (int)Math.Round(refinedOffset), motifSamples)));
|
||||
EstimateContestantEventBands(samples, template, renderer, eventIndex, sampleRate, (int)Math.Round(refinedOffset), motifSamples),
|
||||
anchors));
|
||||
}
|
||||
|
||||
var clock = FitContestantClockHypothesis(
|
||||
var wordClock = FitContestantClockHypothesis(
|
||||
observations
|
||||
.Select(observation => new CepstralWordObservation(
|
||||
observation.EventIndex,
|
||||
|
|
@ -2642,6 +2651,12 @@ static BioacousticPhysicalChannelCalibration CalibrateContestantChannel(
|
|||
renderer,
|
||||
sampleRate,
|
||||
expectedEvents.Count);
|
||||
var anchorClock = FitContestantClockFromAnchors(observations, renderer, sampleRate, expectedEvents.Count);
|
||||
var clock = anchorClock != null &&
|
||||
wordClock != null &&
|
||||
anchorClock.MeanAbsoluteErrorSamples <= wordClock.MeanAbsoluteErrorSamples * 0.82
|
||||
? anchorClock
|
||||
: wordClock ?? anchorClock;
|
||||
var sourceOffsetSamples = clock?.SourceOffsetSamples ?? 0.0;
|
||||
var meanAbsoluteErrorSamples = clock?.MeanAbsoluteErrorSamples ?? 0.0;
|
||||
var confidence = observations.Count == 0
|
||||
|
|
@ -2660,6 +2675,8 @@ static BioacousticPhysicalChannelCalibration CalibrateContestantChannel(
|
|||
sourceOffsetSamples * 1_000_000.0 / sampleRate,
|
||||
meanAbsoluteErrorSamples,
|
||||
meanAbsoluteErrorSamples * 1_000_000.0 / sampleRate,
|
||||
observations.Sum(observation => observation.Anchors.Length),
|
||||
observations.SelectMany(observation => observation.Anchors).DefaultIfEmpty().Average(anchor => anchor?.TimingResidualSamples ?? 0.0),
|
||||
samples.Length,
|
||||
RootMeanSquare(samples),
|
||||
samples.Length == 0 ? 0.0 : samples.Max(sample => Math.Abs(sample)),
|
||||
|
|
@ -2790,6 +2807,171 @@ static double RefineContestantExpectedPayloadOffset(float[] samples, float[] tem
|
|||
: bestOffset + Math.Clamp(0.5 * (left - right) / denominator, -0.5, 0.5);
|
||||
}
|
||||
|
||||
static BioacousticPhysicalAnchorCalibration[] MeasureContestantAnchors(
|
||||
float[] samples,
|
||||
float[] template,
|
||||
MimirBioacousticContestantRenderer renderer,
|
||||
ulong eventIndex,
|
||||
int sampleRate,
|
||||
double eventSampleOffset,
|
||||
int motifSamples)
|
||||
{
|
||||
var anchors = renderer.AnchorPlan(eventIndex);
|
||||
var output = new List<BioacousticPhysicalAnchorCalibration>(anchors.Count);
|
||||
foreach (var anchor in anchors
|
||||
.OrderByDescending(anchor => anchor.Weight)
|
||||
.Take(8)
|
||||
.OrderBy(anchor => anchor.StartSeconds))
|
||||
{
|
||||
var anchorSamples = Math.Clamp(
|
||||
(int)Math.Round(anchor.DurationSeconds * sampleRate),
|
||||
Math.Max(12, sampleRate / 24_000),
|
||||
Math.Max(16, motifSamples / 5));
|
||||
var expectedLocalOffset = (int)Math.Round(anchor.StartSeconds * sampleRate);
|
||||
var expectedObservedOffset = (int)Math.Round(eventSampleOffset) + expectedLocalOffset;
|
||||
var templateStart = Math.Clamp(expectedLocalOffset, 0, Math.Max(0, template.Length - anchorSamples));
|
||||
var observedStart = Math.Clamp(expectedObservedOffset, 0, Math.Max(0, samples.Length - anchorSamples));
|
||||
if (templateStart + anchorSamples > template.Length ||
|
||||
observedStart + anchorSamples > samples.Length)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var observedWindow = samples.AsSpan(observedStart, anchorSamples);
|
||||
var expectedWindow = template.AsSpan(templateStart, anchorSamples);
|
||||
var bestScore = ScoreAnchorWindow(observedWindow, expectedWindow);
|
||||
var refinedOffset = observedStart +
|
||||
EnergyCentroid(observedWindow) -
|
||||
EnergyCentroid(expectedWindow);
|
||||
var residual = refinedOffset - (eventSampleOffset + expectedLocalOffset);
|
||||
var observedEnergy = WindowMeanSquare(observedWindow);
|
||||
var expectedEnergy = WindowMeanSquare(expectedWindow);
|
||||
output.Add(new BioacousticPhysicalAnchorCalibration(
|
||||
anchor.Kind.ToString(),
|
||||
anchor.SyllableIndex,
|
||||
anchor.StartSeconds,
|
||||
anchor.DurationSeconds,
|
||||
anchor.CenterHz,
|
||||
refinedOffset,
|
||||
residual,
|
||||
Math.Clamp(Math.Abs(bestScore) * anchor.Weight, 0.0, 1.0),
|
||||
expectedEnergy <= 1.0e-12 ? 0.0 : Math.Sqrt(Math.Max(0.0, observedEnergy) / expectedEnergy)));
|
||||
}
|
||||
|
||||
return output.ToArray();
|
||||
}
|
||||
|
||||
static double ScoreAnchorWindow(ReadOnlySpan<float> observed, ReadOnlySpan<float> expected)
|
||||
{
|
||||
var count = Math.Min(observed.Length, expected.Length);
|
||||
if (count <= 0)
|
||||
{
|
||||
return double.NegativeInfinity;
|
||||
}
|
||||
|
||||
var dot = 0.0;
|
||||
var observedEnergy = 0.0;
|
||||
var expectedEnergy = 0.0;
|
||||
for (var index = 0; index < count; index++)
|
||||
{
|
||||
dot += observed[index] * expected[index];
|
||||
observedEnergy += observed[index] * observed[index];
|
||||
expectedEnergy += expected[index] * expected[index];
|
||||
}
|
||||
|
||||
return observedEnergy <= 1.0e-12 || expectedEnergy <= 1.0e-12
|
||||
? double.NegativeInfinity
|
||||
: dot / Math.Sqrt(observedEnergy * expectedEnergy);
|
||||
}
|
||||
|
||||
static double EnergyCentroid(ReadOnlySpan<float> samples)
|
||||
{
|
||||
var weighted = 0.0;
|
||||
var energy = 0.0;
|
||||
for (var index = 0; index < samples.Length; index++)
|
||||
{
|
||||
var value = samples[index] * samples[index];
|
||||
weighted += index * value;
|
||||
energy += value;
|
||||
}
|
||||
|
||||
return energy <= 1.0e-12
|
||||
? samples.Length * 0.5
|
||||
: weighted / energy;
|
||||
}
|
||||
|
||||
static MimirBioacousticClockHypothesis? FitContestantClockFromAnchors(
|
||||
IReadOnlyList<BioacousticPhysicalEventCalibration> observations,
|
||||
MimirBioacousticContestantRenderer renderer,
|
||||
int sampleRate,
|
||||
int expectedEventCount)
|
||||
{
|
||||
var wordAnchors = observations
|
||||
.Select(observation => new MimirBioacousticClockAnchor(
|
||||
observation.EventIndex,
|
||||
renderer.EventStartSeconds(observation.EventIndex),
|
||||
observation.SampleOffset,
|
||||
Math.Clamp(observation.Confidence, 0.001, 1.0)));
|
||||
var contourAnchors = observations.SelectMany(observation =>
|
||||
observation.Anchors
|
||||
.Where(anchor => anchor.Confidence >= 0.12)
|
||||
.Select(anchor => new MimirBioacousticClockAnchor(
|
||||
observation.EventIndex,
|
||||
renderer.EventStartSeconds(observation.EventIndex) + anchor.ExpectedStartSeconds,
|
||||
anchor.SampleOffset,
|
||||
Math.Clamp(anchor.Confidence, 0.001, 1.0))));
|
||||
var anchors = wordAnchors
|
||||
.Concat(contourAnchors)
|
||||
.OrderByDescending(anchor => anchor.Confidence)
|
||||
.Take(160)
|
||||
.ToArray();
|
||||
if (anchors.Length < 3)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var totalWeight = anchors.Sum(anchor => Math.Max(1.0e-6, anchor.Confidence));
|
||||
var meanTimeline = anchors.Sum(anchor => anchor.TimelineSeconds * Math.Max(1.0e-6, anchor.Confidence)) / totalWeight;
|
||||
var meanSample = anchors.Sum(anchor => anchor.SampleOffset * Math.Max(1.0e-6, anchor.Confidence)) / totalWeight;
|
||||
var covariance = 0.0;
|
||||
var variance = 0.0;
|
||||
foreach (var anchor in anchors)
|
||||
{
|
||||
var weight = Math.Max(1.0e-6, anchor.Confidence);
|
||||
var dt = anchor.TimelineSeconds - meanTimeline;
|
||||
covariance += weight * dt * (anchor.SampleOffset - meanSample);
|
||||
variance += weight * dt * dt;
|
||||
}
|
||||
|
||||
var effectiveRate = variance > 1.0e-12 ? covariance / variance : sampleRate;
|
||||
if (!double.IsFinite(effectiveRate) || effectiveRate < sampleRate * 0.98 || effectiveRate > sampleRate * 1.02)
|
||||
{
|
||||
effectiveRate = sampleRate;
|
||||
}
|
||||
|
||||
var sourceOffset = meanSample - effectiveRate * meanTimeline;
|
||||
var residual = anchors.Sum(anchor =>
|
||||
{
|
||||
var predicted = sourceOffset + anchor.TimelineSeconds * effectiveRate;
|
||||
return Math.Abs(anchor.SampleOffset - predicted) * Math.Max(1.0e-6, anchor.Confidence);
|
||||
}) / totalWeight;
|
||||
var residualConfidence = 1.0 / (1.0 + residual / Math.Max(1.0, sampleRate * 0.00025));
|
||||
var countConfidence = Math.Clamp(anchors.Length / 80.0, 0.0, 1.0);
|
||||
var anchorConfidence = Math.Clamp(anchors.Average(anchor => anchor.Confidence), 0.0, 1.0);
|
||||
var confidence = residualConfidence * 0.45 + countConfidence * 0.30 + anchorConfidence * 0.25;
|
||||
var coverage = expectedEventCount <= 0 ? 0.0 : observations.Count / (double)expectedEventCount;
|
||||
var score = confidence + Math.Min(anchors.Length, 80) * 0.015 - residual / Math.Max(1.0, sampleRate * 0.004);
|
||||
return new MimirBioacousticClockHypothesis(
|
||||
sourceOffset,
|
||||
effectiveRate,
|
||||
anchors.Length,
|
||||
coverage,
|
||||
residual,
|
||||
confidence,
|
||||
score,
|
||||
anchors);
|
||||
}
|
||||
|
||||
static int ClassifyContestantPayloadAt(
|
||||
float[] samples,
|
||||
int sampleRate,
|
||||
|
|
@ -4144,6 +4326,8 @@ public sealed record BioacousticPhysicalChannelCalibration(
|
|||
double SourceOffsetMicroseconds,
|
||||
double MeanAbsoluteErrorSamples,
|
||||
double MeanAbsoluteErrorMicroseconds,
|
||||
int AnchorCount,
|
||||
double MeanAnchorResidualSamples,
|
||||
int SampleCount,
|
||||
double Rms,
|
||||
double Peak,
|
||||
|
|
@ -4171,7 +4355,19 @@ public sealed record BioacousticPhysicalEventCalibration(
|
|||
double Confidence,
|
||||
int Polarity,
|
||||
double NormalizedResidual,
|
||||
BioacousticPhysicalBandCalibration[] Bands);
|
||||
BioacousticPhysicalBandCalibration[] Bands,
|
||||
BioacousticPhysicalAnchorCalibration[] Anchors);
|
||||
|
||||
public sealed record BioacousticPhysicalAnchorCalibration(
|
||||
string Kind,
|
||||
int SyllableIndex,
|
||||
double ExpectedStartSeconds,
|
||||
double DurationSeconds,
|
||||
double CenterHz,
|
||||
double SampleOffset,
|
||||
double TimingResidualSamples,
|
||||
double Confidence,
|
||||
double Gain);
|
||||
|
||||
public sealed record BioacousticPhysicalBandCalibration(
|
||||
double CenterHz,
|
||||
|
|
|
|||
|
|
@ -26,6 +26,22 @@ public sealed record MimirBioacousticContestantProfile(
|
|||
int PayloadBitsPerEvent,
|
||||
string BeautyNotes);
|
||||
|
||||
public enum MimirBioacousticAnchorKind
|
||||
{
|
||||
TimingChip,
|
||||
FormantPivot,
|
||||
HarmonicNotch,
|
||||
PayloadOrnament
|
||||
}
|
||||
|
||||
public sealed record MimirBioacousticContestantAnchor(
|
||||
MimirBioacousticAnchorKind Kind,
|
||||
int SyllableIndex,
|
||||
double StartSeconds,
|
||||
double DurationSeconds,
|
||||
double CenterHz,
|
||||
double Weight);
|
||||
|
||||
public static class MimirBioacousticContestants
|
||||
{
|
||||
public const double FirstEventSeconds = 0.08;
|
||||
|
|
@ -166,6 +182,8 @@ public static class MimirBioacousticContestants
|
|||
|
||||
public sealed class MimirBioacousticContestantRenderer(MimirBioacousticContestantProfile profile)
|
||||
{
|
||||
private readonly Dictionary<(ulong EventIndex, int SampleRate, int PayloadSymbol), float[]> eventCache = [];
|
||||
|
||||
public MimirBioacousticContestantProfile Profile { get; } = profile;
|
||||
|
||||
public double EventStartSeconds(ulong eventIndex) =>
|
||||
|
|
@ -178,11 +196,63 @@ public sealed class MimirBioacousticContestantRenderer(MimirBioacousticContestan
|
|||
|
||||
public float[] RenderEventMonoFloat(ulong eventIndex, int sampleRate, int payloadSymbol)
|
||||
{
|
||||
if (eventCache.TryGetValue((eventIndex, sampleRate, payloadSymbol), out var cached))
|
||||
{
|
||||
return cached;
|
||||
}
|
||||
|
||||
var samples = new float[Math.Max(1, (int)Math.Round(Profile.MotifDurationSeconds * sampleRate))];
|
||||
AddEvent(samples, sampleRate, eventIndex, payloadSymbol, EventStartSeconds(eventIndex), EventStartSeconds(eventIndex));
|
||||
eventCache[(eventIndex, sampleRate, payloadSymbol)] = samples;
|
||||
return samples;
|
||||
}
|
||||
|
||||
public IReadOnlyList<MimirBioacousticContestantAnchor> AnchorPlan(ulong eventIndex)
|
||||
{
|
||||
var payload = PayloadSymbolForEvent(eventIndex);
|
||||
var symbolId = SymbolForEvent(eventIndex);
|
||||
var root = RootForSymbol(symbolId);
|
||||
var rng = Mix(symbolId ^ (payload << 9), (uint)Profile.Kind);
|
||||
var anchors = new List<MimirBioacousticContestantAnchor>(Profile.SyllableCount * 3);
|
||||
for (var syllable = 0; syllable < Profile.SyllableCount; syllable++)
|
||||
{
|
||||
var contour = SyllableContour(symbolId, payload, syllable, root, rng);
|
||||
var centerHz = Math.Sqrt(contour.StartHz * contour.EndHz);
|
||||
anchors.Add(new MimirBioacousticContestantAnchor(
|
||||
syllable < 2 ? MimirBioacousticAnchorKind.TimingChip : MimirBioacousticAnchorKind.FormantPivot,
|
||||
syllable,
|
||||
contour.StartSeconds,
|
||||
Math.Min(contour.DurationSeconds, Profile.MotifDurationSeconds * 0.028),
|
||||
centerHz,
|
||||
syllable < 2 ? 1.25 : contour.Weight));
|
||||
if (Profile.Kind == MimirBioacousticContestantKind.CanaryPacketTrill)
|
||||
{
|
||||
anchors.Add(new MimirBioacousticContestantAnchor(
|
||||
MimirBioacousticAnchorKind.HarmonicNotch,
|
||||
syllable,
|
||||
contour.StartSeconds + contour.DurationSeconds * 0.46,
|
||||
Math.Min(contour.DurationSeconds * 0.24, Profile.MotifDurationSeconds * 0.018),
|
||||
centerHz * (syllable % 2 == 0 ? 1.50 : 2.00),
|
||||
0.72));
|
||||
if (syllable >= 2)
|
||||
{
|
||||
anchors.Add(new MimirBioacousticContestantAnchor(
|
||||
MimirBioacousticAnchorKind.PayloadOrnament,
|
||||
syllable,
|
||||
contour.StartSeconds + contour.DurationSeconds * 0.72,
|
||||
Math.Min(contour.DurationSeconds * 0.18, Profile.MotifDurationSeconds * 0.014),
|
||||
centerHz * (1.20 + 0.08 * (payload & 3)),
|
||||
0.58));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return anchors
|
||||
.Where(anchor => anchor.StartSeconds >= 0.0 && anchor.StartSeconds < Profile.MotifDurationSeconds)
|
||||
.OrderBy(anchor => anchor.StartSeconds)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
public float[] RenderSequenceMonoFloat(double seconds, int sampleRate)
|
||||
{
|
||||
var samples = new float[Math.Max(1, (int)Math.Round(seconds * sampleRate))];
|
||||
|
|
@ -320,7 +390,7 @@ public sealed class MimirBioacousticContestantRenderer(MimirBioacousticContestan
|
|||
return value;
|
||||
}
|
||||
|
||||
private static void AddSyllable(
|
||||
private void AddSyllable(
|
||||
float[] output,
|
||||
int sampleRate,
|
||||
double startSeconds,
|
||||
|
|
@ -346,8 +416,31 @@ public sealed class MimirBioacousticContestantRenderer(MimirBioacousticContestan
|
|||
phase += Math.Tau * (previousFrequency + frequency) * 0.5 / sampleRate;
|
||||
previousFrequency = frequency;
|
||||
var envelope = Math.Sin(Math.PI * Math.Clamp(t, 0.0, 1.0));
|
||||
var harmonic = 0.28 * Math.Sin(phase * 2.0 + 0.25) + 0.12 * Math.Sin(phase * 3.0 + 0.7);
|
||||
output[sample] += (float)(gain * envelope * (Math.Sin(phase) + harmonic));
|
||||
var harmonicEnvelope = ProfileAwareHarmonicEnvelope(t, startHz, endHz);
|
||||
var harmonic = harmonicEnvelope.Second * Math.Sin(phase * 2.0 + 0.25) +
|
||||
harmonicEnvelope.Third * Math.Sin(phase * 3.0 + 0.7) +
|
||||
harmonicEnvelope.Notch * Math.Sin(phase * 1.5 + 1.35);
|
||||
var anchorClick = 0.18 * Math.Exp(-Math.Pow((t - 0.08) / 0.035, 2.0)) -
|
||||
0.12 * Math.Exp(-Math.Pow((t - 0.52) / 0.045, 2.0)) +
|
||||
0.09 * Math.Exp(-Math.Pow((t - 0.76) / 0.035, 2.0));
|
||||
output[sample] += (float)(gain * envelope * (Math.Sin(phase) + harmonic + anchorClick * Math.Sin(phase * 2.5 + 0.4)));
|
||||
}
|
||||
}
|
||||
|
||||
private (double Second, double Third, double Notch) ProfileAwareHarmonicEnvelope(double t, double startHz, double endHz)
|
||||
{
|
||||
if (Profile.Kind != MimirBioacousticContestantKind.CanaryPacketTrill)
|
||||
{
|
||||
return (0.28, 0.12, 0.0);
|
||||
}
|
||||
|
||||
var sweep = Math.Abs(endHz - startHz) / Math.Max(1.0, startHz);
|
||||
var attack = Math.Exp(-Math.Pow((t - 0.13) / 0.075, 2.0));
|
||||
var pivot = Math.Exp(-Math.Pow((t - 0.48) / 0.060, 2.0));
|
||||
var tail = Math.Exp(-Math.Pow((t - 0.78) / 0.070, 2.0));
|
||||
return (
|
||||
Second: 0.18 + 0.26 * attack + 0.10 * sweep,
|
||||
Third: 0.08 + 0.22 * tail,
|
||||
Notch: 0.16 * pivot);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,3 +96,4 @@
|
|||
{"ts": "2026-05-24T23:22:46+01:00", "type": "experiment", "status": "partial", "note": "Promoted canary-packet physical ASIO calibration into a persisted bioacoustic response model at calibration/bioacoustic/scarlett-canary-packet-192k-rerun.json. The command clears the hot-loop budget at 10.7x realtime across four 192 kHz channels after template caching and two-sample coarse search with sub-sample refinement. Loopback channels remain 37/37 with 2.524 us MAE. Co-streamer shotgun reaches 37/37 payload=1.000 with 58.785 us MAE and 2.940 ms acoustic delay relative to loopback. Cardioid reaches 26/37 payload=0.703 with 90.558 us MAE and 4.636 ms acoustic delay. This is exact enough to build response normalization and propagation-delay profiles, but not yet true microsecond sync for physical mics."}
|
||||
{"ts": "2026-05-24T23:35:51+01:00", "type": "decision", "status": "ok", "note": "Active bioacoustic sync is no longer sequence-coded. The live receiver should keep its ear open for self-identifying song contours; one heard call carries enough log-mel contour, syllable timing, formant, rhythm, payload, and speaker-tint evidence to pin multiple time/frequency anchors at once. De Bruijn/triplet machinery is demoted to retained chirplet/chirp-bin reference artifacts only, not runtime authority."}
|
||||
{"ts": "2026-05-24T23:45:19+01:00", "type": "experiment", "status": "partial", "note": "Fresh 192 kHz canary-packet physical ASIO run after song-contour authority cut: persisted calibration/bioacoustic/scarlett-canary-packet-192k-contour-fresh.json. Decoder cleared the 10x realtime budget at about 10.0x over four channels. Loopback remains 37/37 payload=1.000 with 2.524 us MAE. Co-streamer shotgun improved to 37/37 payload=1.000 with 34.083 us MAE and 2.710 ms path delay relative to loopback. Cardioid improved to 31/37 payload=0.811 but still measures 92.996 us MAE and 4.636 ms path delay. Current physical ceiling is tens of microseconds on mics; true microsecond sync needs intra-call contour anchors instead of one offset per packet word."}
|
||||
{"ts": "2026-05-25T00:08:44+01:00", "type": "experiment", "status": "partial", "note": "Built the first anchor-rich canary packet: timing chips, formant pivots, harmonic-envelope notches, payload ornaments, renderer-level template caching, and per-event intra-call anchor measurements in the physical calibration receipt. Fresh 192 kHz ASIO receipt calibration/bioacoustic/scarlett-canary-packet-anchor-rich-192k.json clears 10x realtime and records hundreds of anchors per channel. Loopback improves to about 2.23 us MAE with anchor residuals under 0.3 samples. Physical mics did not improve yet: shotgun 36/37 payload=0.973 at 56.365 us MAE, cardioid 27/37 payload=0.730 at 101.522 us MAE. The new anchors expose path bias; the next cut should shape/weight anchors for acoustic survivability instead of trusting every formant feature equally."}
|
||||
|
|
|
|||
|
|
@ -193,6 +193,13 @@ accepted_design:
|
|||
payload with 34.083 us MAE, and improves the cardioid to 31/37 payload
|
||||
with 92.996 us MAE. The next precision cut is intra-call contour anchors,
|
||||
not more sequence machinery.
|
||||
`calibration/bioacoustic/scarlett-canary-packet-anchor-rich-192k.json`
|
||||
is the first anchor-rich receipt: timing chips, formant pivots,
|
||||
harmonic-envelope notches, payload ornaments, renderer template caching, and
|
||||
per-event intra-call anchor measurements. It clears 10x realtime and
|
||||
improves loopback to about 2.23 us MAE, but physical mics regress/hold at
|
||||
tens of microseconds, so anchor survivability and path weighting are now the
|
||||
problem.
|
||||
Acoustic robustness remains open.
|
||||
The old arbitrary-chirplet matcher is a diagnostic/reference artifact only,
|
||||
not the runtime hot path.
|
||||
|
|
|
|||
Loading…
Reference in a new issue