Add Mimir Well daemon
This commit is contained in:
parent
a8b889d03d
commit
1778f2da78
12 changed files with 785 additions and 39 deletions
|
|
@ -6,6 +6,7 @@
|
|||
<Project Path="src/Mimir.EveDialogue/Mimir.EveDialogue.csproj" />
|
||||
<Project Path="src/Mimir.EveDashboard/Mimir.EveDashboard.csproj" />
|
||||
<Project Path="src/Mimir.EveSensorReceiver/Mimir.EveSensorReceiver.csproj" />
|
||||
<Project Path="src/Mimir.Well/Mimir.Well.csproj" />
|
||||
<Project Path="src/Mimir.VerseRecorder/Mimir.VerseRecorder.csproj" />
|
||||
<Project Path="src/Mimir.PsMoveProbe/Mimir.PsMoveProbe.csproj" />
|
||||
<Project Path="src/Mimir.WasapiLoopback/Mimir.WasapiLoopback.csproj" />
|
||||
|
|
|
|||
187
config/mimir-runtime.well.local.json
Normal file
187
config/mimir-runtime.well.local.json
Normal file
|
|
@ -0,0 +1,187 @@
|
|||
{
|
||||
"bufferSeconds": 5.0,
|
||||
"audioSync": {
|
||||
"mode": "passive",
|
||||
"referenceSourceId": "asio-ch2",
|
||||
"calibrationGain": 0.0,
|
||||
"watermarkGain": 0.0,
|
||||
"complexContourChannelModelPath": "../calibration/bioacoustic/complex-contour-channel-model.json",
|
||||
"enableComplexContourRuntime": true
|
||||
},
|
||||
"streams": [
|
||||
{
|
||||
"sourceId": "focusrite-asio",
|
||||
"displayName": "Starfire Scarlett ASIO",
|
||||
"kind": "Audio",
|
||||
"origin": "LocalDevice",
|
||||
"enabled": true,
|
||||
"adapter": "asio",
|
||||
"command": "../native/asio_capture/build/Release/mimir_asio_capture.dll",
|
||||
"sampleRate": 192000,
|
||||
"acceptSourceIds": [
|
||||
"asio-ch0",
|
||||
"asio-ch1",
|
||||
"asio-ch2",
|
||||
"asio-ch3"
|
||||
],
|
||||
"sourceLabels": {
|
||||
"asio-ch0": "Shotgun hero mic",
|
||||
"asio-ch1": "Cardioid hero mic",
|
||||
"asio-ch2": "Starfire/Raven loopback L",
|
||||
"asio-ch3": "Starfire/Raven loopback R"
|
||||
}
|
||||
},
|
||||
{
|
||||
"sourceId": "leap-stereo-ir",
|
||||
"displayName": "LeapUVC stereo IR / depth root",
|
||||
"kind": "Video",
|
||||
"origin": "LocalDevice",
|
||||
"enabled": true,
|
||||
"adapter": "ks-camera",
|
||||
"command": "../native/camera_capture/build/Release/mimir_camera_capture.dll",
|
||||
"pathNeedle": "vid_f182&pid_0003&mi_00",
|
||||
"width": 640,
|
||||
"height": 240,
|
||||
"inputFormat": "YUY2",
|
||||
"pixelFormat": "LeapStereoIr",
|
||||
"minimumFramesPerSecond": 100.0,
|
||||
"queueDepth": 8
|
||||
},
|
||||
{
|
||||
"sourceId": "kiyo-pro-rgb",
|
||||
"displayName": "Kiyo Pro AR program view",
|
||||
"kind": "Video",
|
||||
"origin": "LocalDevice",
|
||||
"enabled": true,
|
||||
"adapter": "ks-camera",
|
||||
"command": "../native/camera_capture/build/Release/mimir_camera_capture.dll",
|
||||
"pathNeedle": "vid_1532&pid_0e05&mi_00",
|
||||
"width": 640,
|
||||
"height": 480,
|
||||
"inputFormat": "YUY2",
|
||||
"pixelFormat": "YUY2",
|
||||
"minimumFramesPerSecond": 25.0,
|
||||
"queueDepth": 8
|
||||
},
|
||||
{
|
||||
"sourceId": "kiyo-basic-rgb",
|
||||
"displayName": "Kiyo RGB context",
|
||||
"kind": "Video",
|
||||
"origin": "LocalDevice",
|
||||
"enabled": true,
|
||||
"adapter": "ks-camera",
|
||||
"command": "../native/camera_capture/build/Release/mimir_camera_capture.dll",
|
||||
"pathNeedle": "vid_1532&pid_0e03&mi_00",
|
||||
"width": 640,
|
||||
"height": 480,
|
||||
"inputFormat": "YUY2",
|
||||
"pixelFormat": "YUY2",
|
||||
"minimumFramesPerSecond": 25.0,
|
||||
"queueDepth": 8
|
||||
},
|
||||
{
|
||||
"sourceId": "raven-display",
|
||||
"displayName": "Raven screen capture",
|
||||
"clockDomainId": "raven-sync",
|
||||
"kind": "Video",
|
||||
"origin": "Network",
|
||||
"enabled": true,
|
||||
"adapter": "ffmpeg-rawvideo",
|
||||
"command": "ffmpeg",
|
||||
"width": 1920,
|
||||
"height": 1080,
|
||||
"pixelFormat": "Bgra8",
|
||||
"arguments": [
|
||||
"-hide_banner",
|
||||
"-nostdin",
|
||||
"-loglevel",
|
||||
"warning",
|
||||
"-fflags",
|
||||
"nobuffer",
|
||||
"-flags",
|
||||
"low_delay",
|
||||
"-i",
|
||||
"srt://0.0.0.0:5210?mode=listener&latency=20000&timeout=5000000",
|
||||
"-an",
|
||||
"-f",
|
||||
"rawvideo",
|
||||
"-pix_fmt",
|
||||
"bgra",
|
||||
"-"
|
||||
]
|
||||
},
|
||||
{
|
||||
"sourceId": "raven-realtk-loopback",
|
||||
"displayName": "Raven Realtek loopback",
|
||||
"clockDomainId": "raven-sync",
|
||||
"kind": "Audio",
|
||||
"origin": "Network",
|
||||
"enabled": true,
|
||||
"adapter": "ffmpeg-pcmaudio",
|
||||
"command": "ffmpeg",
|
||||
"sampleRate": 48000,
|
||||
"channels": 2,
|
||||
"sampleFormat": "Float32",
|
||||
"blockFrames": 960,
|
||||
"arguments": [
|
||||
"-hide_banner",
|
||||
"-nostdin",
|
||||
"-loglevel",
|
||||
"warning",
|
||||
"-fflags",
|
||||
"nobuffer",
|
||||
"-f",
|
||||
"f32le",
|
||||
"-ar",
|
||||
"48000",
|
||||
"-ac",
|
||||
"2",
|
||||
"-i",
|
||||
"srt://0.0.0.0:5212?mode=listener&latency=20000&timeout=5000000",
|
||||
"-f",
|
||||
"f32le",
|
||||
"-"
|
||||
]
|
||||
},
|
||||
{
|
||||
"sourceId": "eve-camera",
|
||||
"displayName": "Eve iPad camera capture",
|
||||
"clockDomainId": "eve-local",
|
||||
"kind": "Video",
|
||||
"origin": "Network",
|
||||
"enabled": true,
|
||||
"adapter": "frame-events",
|
||||
"command": "../src/Mimir.EveSensorReceiver/bin/Debug/net10.0/Mimir.EveSensorReceiver.exe",
|
||||
"arguments": [
|
||||
"--port",
|
||||
"8793",
|
||||
"--path",
|
||||
"/eve/camera",
|
||||
"--source-id",
|
||||
"eve-camera",
|
||||
"--type",
|
||||
"video-frame"
|
||||
]
|
||||
},
|
||||
{
|
||||
"sourceId": "eve-mic",
|
||||
"displayName": "Eve iPad microphone capture",
|
||||
"clockDomainId": "eve-local",
|
||||
"kind": "Audio",
|
||||
"origin": "Network",
|
||||
"enabled": true,
|
||||
"adapter": "frame-events",
|
||||
"command": "../src/Mimir.EveSensorReceiver/bin/Debug/net10.0/Mimir.EveSensorReceiver.exe",
|
||||
"arguments": [
|
||||
"--port",
|
||||
"8794",
|
||||
"--path",
|
||||
"/eve/mic",
|
||||
"--source-id",
|
||||
"eve-mic",
|
||||
"--type",
|
||||
"audio-block"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -575,14 +575,22 @@ a named invariant that the native runtime cannot protect yet.
|
|||
serves a WebSocket subscriber lane on `/eve/periwinkle/subscribe`.
|
||||
`Mimir.VerseRecorder` subscribes to that lane and writes a timestamped
|
||||
`session.json` plus `observations.jsonl` under
|
||||
`C:\Users\Meta\Videos\Mimir\VerseCaptures` by default. The online supervisor
|
||||
`C:\Users\Meta\Videos\Mimir\VerseCaptures` by default. `Mimir.Well` is the
|
||||
long-running Starfire ingest/publish daemon: it loads
|
||||
`config/mimir-runtime.well.local.json`, creates every configured source it
|
||||
can, polls the `MimirSynchronizationHub` with a bounded daemon cadence,
|
||||
updates audio sync/probe state, and publishes `mimir.well_snapshot.v1`
|
||||
records with source buffers, composite controls, publication/stem contract,
|
||||
and synchronized-frame status. The online supervisor
|
||||
`scripts/start-online-verse-daemons.ps1` starts the relay, recorder,
|
||||
Nightwing Eyes/Move witness, music-synced Move gesture worker, and a local
|
||||
Starfire `Mimir.BufferSmoke` runtime capture worker from
|
||||
`config/mimir-runtime.mvp-leap-eyes-kiyo.local.json`. This cut records typed
|
||||
observation evidence and keeps local rolling capture alive; raw camera/audio
|
||||
payloads, aligned source windows, and stem descriptors still need a runtime
|
||||
publisher bridge from `MimirSynchronizationHub` into the same Verse surface.
|
||||
Nightwing Eyes/Move/builtin-camera/builtin-mic witness, music-synced
|
||||
de-Bruijn/microtonal Move gesture worker, and `Mimir.Well` from the broad
|
||||
Well profile. This cut records typed observation evidence and Well state;
|
||||
raw camera/audio payload publication into CultMesh remains a future heavy
|
||||
media surface. The current live scar is explicit: ASIO device timestamps and
|
||||
camera driver timestamps are different domains, so `Mimir.Well` publishes
|
||||
degraded sync status until a camera-clock/global-time correction owner maps
|
||||
those domains.
|
||||
Eve now follows the same rule for its own device body:
|
||||
`MimirDistributedWitnessConfigurations.EveLocalSensors` and the
|
||||
`eve-local-sensors` Perfect Machine profile make Eve responsible for local
|
||||
|
|
|
|||
|
|
@ -195,18 +195,23 @@ Get-Content .\state\evidence.jsonl -Tail 8
|
|||
Native program-output recording/streaming should replace those actuators
|
||||
behind the same owner.
|
||||
- OBS receives final program surfaces; it does not own synchronization.
|
||||
- The first online Verse capture daemon pair exists. `Mimir.EveSensorReceiver`
|
||||
now has a subscriber WebSocket path beside its observation ingest path, and
|
||||
`Mimir.VerseRecorder` writes subscribed observations to
|
||||
- The online Well stack exists. `Mimir.EveSensorReceiver` has a subscriber
|
||||
WebSocket path beside its observation ingest path, and `Mimir.VerseRecorder`
|
||||
writes subscribed observations to
|
||||
`C:\Users\Meta\Videos\Mimir\VerseCaptures\<session>\session.json` plus
|
||||
`observations.jsonl`. `scripts/start-online-verse-daemons.ps1` supervises
|
||||
the local relay, recorder, Nightwing typed Eyes/Move witness, the
|
||||
music-synced Move gesture worker, and a Starfire `Mimir.BufferSmoke`
|
||||
runtime capture host for the MVP Leap/Eyes/Kiyo config. Treat this as the
|
||||
typed observation/witness ledger. The next coherent cut is a
|
||||
`MimirSynchronizationHub` publisher that emits aligned source windows, stem
|
||||
descriptors, sync states, and actuator state into the same Verse surface
|
||||
instead of leaving raw media/stem truth in local process memory only.
|
||||
`observations.jsonl`. `Mimir.Well` loads
|
||||
`config/mimir-runtime.well.local.json`, starts every configured source it
|
||||
can, polls `MimirSynchronizationHub` with a bounded per-source budget, updates
|
||||
audio sync/probe state, and publishes `mimir.well_snapshot.v1` records with
|
||||
source buffers, composite controls, publication/stem contract, and sync
|
||||
status. `scripts/start-online-verse-daemons.ps1` supervises the relay,
|
||||
recorder, Nightwing typed Eyes/Move/builtin-camera/builtin-mic witness, the
|
||||
music-synced de-Bruijn/microtonal Move gesture worker, and `Mimir.Well`.
|
||||
Current live proof `online-verse-daemons-20260601-212502` wrote Well,
|
||||
Nightwing builtin camera/mic, and Eye/Move records. Raven and Eve lanes are
|
||||
configured but empty unless their producers are feeding the ports. Sync frame
|
||||
status is degraded until a camera-clock/global-time correction owner maps
|
||||
ASIO device time and camera driver time into one canonical timeline.
|
||||
|
||||
## Current Pressure
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ param(
|
|||
[string]$NightwingHost = "nightwing",
|
||||
[string]$WitnessUrl = "ws://192.168.1.66:8796/eve/periwinkle",
|
||||
[string]$SubscribeUrl = "ws://127.0.0.1:8796/eve/periwinkle/subscribe",
|
||||
[string]$ConfigPath = "E:\Projects\Mimir\config\mimir-runtime.mvp-leap-eyes-kiyo.local.json",
|
||||
[string]$ConfigPath = "E:\Projects\Mimir\config\mimir-runtime.well.local.json",
|
||||
[string]$WellPublishUrl = "ws://127.0.0.1:8796/eve/periwinkle",
|
||||
[string]$RecorderRoot = "C:\Users\Meta\Videos\Mimir\VerseCaptures",
|
||||
[int]$DurationSeconds = 0,
|
||||
[int]$MoveFps = 120,
|
||||
|
|
@ -70,6 +71,7 @@ $manifest = [ordered]@{
|
|||
runDir = $runDir
|
||||
witnessUrl = $WitnessUrl
|
||||
subscribeUrl = $SubscribeUrl
|
||||
wellPublishUrl = $WellPublishUrl
|
||||
recorderRoot = $RecorderRoot
|
||||
configPath = $ConfigPath
|
||||
startedAt = (Get-Date).ToString("o")
|
||||
|
|
@ -82,7 +84,12 @@ Write-Host "Online Verse daemon run: $runDir"
|
|||
|
||||
if (-not $DryRun) {
|
||||
Get-CimInstance Win32_Process |
|
||||
Where-Object { $_.CommandLine -match "Mimir.EveSensorReceiver" -and $_.CommandLine -match "--port 8796" } |
|
||||
Where-Object {
|
||||
($_.CommandLine -match "Mimir.EveSensorReceiver" -and $_.CommandLine -match "--port 8796") -or
|
||||
($_.CommandLine -match "Mimir.VerseRecorder") -or
|
||||
($_.CommandLine -match "Mimir.Well") -or
|
||||
($_.CommandLine -match "Mimir.BufferSmoke" -and $_.CommandLine -match "--poll-ms")
|
||||
} |
|
||||
ForEach-Object {
|
||||
try { Stop-Process -Id $_.ProcessId -Force -ErrorAction Stop } catch {}
|
||||
}
|
||||
|
|
@ -130,8 +137,16 @@ if (-not $SkipNightwing) {
|
|||
scp (Join-Path $repo "tools\nightwing_typed_witness_publisher.py") "${NightwingHost}:/tmp/nightwing_typed_witness_publisher.py" | Out-Null
|
||||
$remoteLog = "~/.local/state/gamecult/mimir-online-verse-witness-$runId.log"
|
||||
$remotePid = "~/.local/state/gamecult/mimir-online-verse-witness-$runId.pid"
|
||||
$remote = "mkdir -p ~/.local/state/gamecult; pkill -f '/tmp/nightwing_typed_witness_publisher.py.*--track-eyes' || true; nohup python3 /tmp/nightwing_typed_witness_publisher.py --url '$WitnessUrl' --track-eyes --interval 0.10 --eye-devices /dev/video2,/dev/video3 --eye-window-seconds 0.08 --tracking-stride 6 > $remoteLog 2>&1 < /dev/null & sleep 0.2; pgrep -n -f '/tmp/nightwing_typed_witness_publisher.py.*--track-eyes' > $remotePid; cat $remotePid"
|
||||
$nightwingPid = ssh $NightwingHost $remote
|
||||
$remoteScript = @"
|
||||
mkdir -p ~/.local/state/gamecult
|
||||
pkill -f '/tmp/nightwing_typed_witness_publisher.py.*--track-eyes' || true
|
||||
nohup python3 /tmp/nightwing_typed_witness_publisher.py --url '$WitnessUrl' --track-eyes --track-builtin-camera --track-builtin-mic --interval 0.10 --eye-devices /dev/video2,/dev/video3 --eye-window-seconds 0.08 --tracking-stride 6 > $remoteLog 2>&1 < /dev/null &
|
||||
sleep 0.5
|
||||
pgrep -n -f '/tmp/nightwing_typed_witness_publisher.py.*--track-eyes' > $remotePid
|
||||
cat $remotePid
|
||||
"@
|
||||
$remoteB64 = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($remoteScript))
|
||||
$nightwingPid = ssh $NightwingHost "printf '%s' '$remoteB64' | base64 -d | bash"
|
||||
$manifest.processes["nightwingWitnessPid"] = ($nightwingPid | Select-Object -First 1)
|
||||
$manifest.processes["nightwingWitnessLog"] = $remoteLog
|
||||
}
|
||||
|
|
@ -154,7 +169,10 @@ if (-not $SkipMoves) {
|
|||
"--fps", "$MoveFps",
|
||||
"--fft-size", "$MoveFftSize",
|
||||
"--onset-cooldown-seconds", "0.065",
|
||||
"--warmup-seconds", "0.25"
|
||||
"--warmup-seconds", "0.25",
|
||||
"--debruijn-polyrhythm",
|
||||
"--harmonic-base", "1.5",
|
||||
"--microtonal-cents", "17"
|
||||
)
|
||||
foreach ($spec in $Move) {
|
||||
$moveArgs += "--move"
|
||||
|
|
@ -167,17 +185,21 @@ if (-not $SkipMoves) {
|
|||
|
||||
if (-not $SkipRuntime) {
|
||||
$runtime = Start-LoggedProcess `
|
||||
-Name "mimir-runtime" `
|
||||
-Name "mimir-well" `
|
||||
-FilePath "dotnet" `
|
||||
-ArgumentList @(
|
||||
"run",
|
||||
"--project",
|
||||
(Join-Path $repo "src\Mimir.BufferSmoke\Mimir.BufferSmoke.csproj"),
|
||||
(Join-Path $repo "src\Mimir.Well\Mimir.Well.csproj"),
|
||||
"--",
|
||||
"--seconds", $(if ($DurationSeconds -gt 0) { "$DurationSeconds" } else { "31536000" }),
|
||||
"--poll-ms", "5",
|
||||
"--sync-reference", "asio-ch2",
|
||||
"--require-samples"
|
||||
"--publish-url", $WellPublishUrl,
|
||||
"--node-id", "starfire",
|
||||
"--publish-ms", "250",
|
||||
"--sync-ms", "250",
|
||||
"--presentation-delay-ms", "2500",
|
||||
"--max-samples-per-source", "4"
|
||||
) `
|
||||
-Environment @{
|
||||
"MIMIR_RUNTIME_CONFIG" = $ConfigPath
|
||||
|
|
|
|||
|
|
@ -214,8 +214,9 @@ internal sealed class EveSensorReceiver(EveSensorReceiverOptions options) : IDis
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!root.TryGetProperty("sourceId", out var sourceId)
|
||||
|| !string.Equals(sourceId.GetString(), options.SourceId, StringComparison.Ordinal))
|
||||
if (!string.Equals(options.ExpectedType, "cultmesh-observation", StringComparison.OrdinalIgnoreCase)
|
||||
&& (!root.TryGetProperty("sourceId", out var sourceId)
|
||||
|| !string.Equals(sourceId.GetString(), options.SourceId, StringComparison.Ordinal)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
16
src/Mimir.Well/Mimir.Well.csproj
Normal file
16
src/Mimir.Well/Mimir.Well.csproj
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<AssemblyName>Mimir.Well</AssemblyName>
|
||||
<RootNamespace>Mimir.Well</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Mimir.Runtime\Mimir.Runtime.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
390
src/Mimir.Well/Program.cs
Normal file
390
src/Mimir.Well/Program.cs
Normal file
|
|
@ -0,0 +1,390 @@
|
|||
using System.Net.WebSockets;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using Mimir.Runtime.Synchronization;
|
||||
|
||||
var options = MimirWellOptions.Parse(args);
|
||||
var runtimeConfig = MimirRuntimeConfiguration.Load();
|
||||
using var hub = new MimirSynchronizationHub(runtimeConfig.Settings);
|
||||
var sourceErrors = new List<object>();
|
||||
foreach (var factory in runtimeConfig.SourceFactories)
|
||||
{
|
||||
try
|
||||
{
|
||||
var source = factory.Create();
|
||||
if (source == null)
|
||||
{
|
||||
sourceErrors.Add(new { factory.Descriptor.SourceId, status = "not-created" });
|
||||
continue;
|
||||
}
|
||||
|
||||
hub.AddSource(source);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
sourceErrors.Add(new
|
||||
{
|
||||
factory.Descriptor.SourceId,
|
||||
status = "create-error",
|
||||
errorType = ex.GetType().Name,
|
||||
ex.Message,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
using var stopping = new CancellationTokenSource();
|
||||
if (options.Seconds > 0)
|
||||
{
|
||||
stopping.CancelAfter(TimeSpan.FromSeconds(options.Seconds));
|
||||
}
|
||||
|
||||
Console.CancelKeyPress += (_, eventArgs) =>
|
||||
{
|
||||
eventArgs.Cancel = true;
|
||||
stopping.Cancel();
|
||||
};
|
||||
|
||||
await using var publisher = new MimirWellPublisher(options.PublishUrl);
|
||||
await publisher.ConnectAsync(stopping.Token).ConfigureAwait(false);
|
||||
|
||||
var sequence = 0L;
|
||||
var startedAt = DateTimeOffset.UtcNow;
|
||||
var nextPublish = DateTimeOffset.MinValue;
|
||||
var nextSync = DateTimeOffset.MinValue;
|
||||
var presentation = new MimirPresentationControlState();
|
||||
Console.Error.WriteLine($"Mimir Well publishing to {options.PublishUrl}");
|
||||
Console.Error.WriteLine($"Mimir Well sources={runtimeConfig.SourceFactories.Count} buffers={hub.Buffers.Buffers.Count}");
|
||||
|
||||
while (!stopping.IsCancellationRequested)
|
||||
{
|
||||
hub.PollSources(options.MaxSamplesPerSource);
|
||||
var now = DateTimeOffset.UtcNow;
|
||||
if (now >= nextSync)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(runtimeConfig.Settings.Audio.ReferenceSourceId))
|
||||
{
|
||||
hub.AnalyzeAudioSynchronizationStep(
|
||||
runtimeConfig.Settings.Audio.ReferenceSourceId,
|
||||
runtimeConfig.Settings.Audio.Mode,
|
||||
options.SyncCandidatesPerStep);
|
||||
hub.AnalyzeComplexContourSynchronizationStep(
|
||||
runtimeConfig.Settings.Audio.ReferenceSourceId,
|
||||
(now - startedAt).TotalSeconds,
|
||||
options.SyncCandidatesPerStep);
|
||||
}
|
||||
|
||||
hub.UpdateBioacousticProbeSchedule(NowNs());
|
||||
nextSync = now + TimeSpan.FromMilliseconds(options.SyncIntervalMs);
|
||||
}
|
||||
|
||||
if (now >= nextPublish)
|
||||
{
|
||||
presentation.SyncFromBuffers(hub.Buffers.Buffers);
|
||||
var frame = BuildFrameOrEmpty(hub, TimeSpan.FromMilliseconds(options.PresentationDelayMs));
|
||||
var snapshot = MimirWellSnapshot.Build(
|
||||
options,
|
||||
runtimeConfig,
|
||||
hub,
|
||||
presentation,
|
||||
frame,
|
||||
sourceErrors,
|
||||
++sequence,
|
||||
startedAt);
|
||||
await publisher.PublishAsync(snapshot, stopping.Token).ConfigureAwait(false);
|
||||
if (sequence % Math.Max(1, options.MeterEvery) == 0)
|
||||
{
|
||||
Console.Error.WriteLine(
|
||||
$"mimir-well sequence={sequence} ingested={hub.IngestedSamples} ready={frame.Slices.Count(slice => slice.Status == MimirSynchronizedSliceStatus.Ready)}/{frame.Slices.Count}");
|
||||
}
|
||||
|
||||
nextPublish = now + TimeSpan.FromMilliseconds(options.PublishIntervalMs);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
await Task.Delay(Math.Max(1, options.PollMs), stopping.Token).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Console.Error.WriteLine($"Mimir Well complete sequence={sequence} ingested={hub.IngestedSamples}");
|
||||
|
||||
static long NowNs() => DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() * 1_000_000L;
|
||||
|
||||
static MimirSynchronizedBufferFrame BuildFrameOrEmpty(MimirSynchronizationHub hub, TimeSpan presentationDelay)
|
||||
{
|
||||
try
|
||||
{
|
||||
return hub.BuildSynchronizedBufferFrame(presentationDelay);
|
||||
}
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
Console.Error.WriteLine($"mimir-well synchronized-frame degraded: {ex.Message}");
|
||||
return new MimirSynchronizedBufferFrame(0, 0, 0, presentationDelay, []);
|
||||
}
|
||||
catch (OverflowException ex)
|
||||
{
|
||||
Console.Error.WriteLine($"mimir-well synchronized-frame degraded: {ex.Message}");
|
||||
return new MimirSynchronizedBufferFrame(0, 0, 0, presentationDelay, []);
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed record MimirWellOptions(
|
||||
Uri PublishUrl,
|
||||
string NodeId,
|
||||
double Seconds,
|
||||
int PollMs,
|
||||
int PublishIntervalMs,
|
||||
int SyncIntervalMs,
|
||||
int PresentationDelayMs,
|
||||
int MaxSamplesPerSource,
|
||||
int SyncCandidatesPerStep,
|
||||
int MeterEvery)
|
||||
{
|
||||
public static MimirWellOptions Parse(string[] args) => new(
|
||||
new Uri(ParseString(args, "--publish-url", "ws://127.0.0.1:8796/eve/periwinkle")),
|
||||
ParseString(args, "--node-id", Environment.MachineName.ToLowerInvariant()),
|
||||
ParseDouble(args, "--seconds", 0.0),
|
||||
ParseInt(args, "--poll-ms", 5),
|
||||
ParseInt(args, "--publish-ms", 250),
|
||||
ParseInt(args, "--sync-ms", 250),
|
||||
ParseInt(args, "--presentation-delay-ms", 2500),
|
||||
ParseInt(args, "--max-samples-per-source", 4),
|
||||
ParseInt(args, "--sync-candidates", 1),
|
||||
ParseInt(args, "--meter-every", 20));
|
||||
|
||||
private static string ParseString(IReadOnlyList<string> args, string name, string fallback)
|
||||
{
|
||||
for (var index = 0; index < args.Count - 1; index++)
|
||||
{
|
||||
if (string.Equals(args[index], name, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return args[index + 1];
|
||||
}
|
||||
}
|
||||
|
||||
return fallback;
|
||||
}
|
||||
|
||||
private static int ParseInt(IReadOnlyList<string> args, string name, int fallback) =>
|
||||
int.TryParse(ParseString(args, name, ""), out var value) ? value : fallback;
|
||||
|
||||
private static double ParseDouble(IReadOnlyList<string> args, string name, double fallback) =>
|
||||
double.TryParse(ParseString(args, name, ""), out var value) ? value : fallback;
|
||||
}
|
||||
|
||||
internal sealed class MimirWellPublisher(Uri url) : IAsyncDisposable
|
||||
{
|
||||
private readonly ClientWebSocket socket = new();
|
||||
|
||||
public async Task ConnectAsync(CancellationToken stopping)
|
||||
{
|
||||
await socket.ConnectAsync(url, stopping).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task PublishAsync(object document, CancellationToken stopping)
|
||||
{
|
||||
var json = JsonSerializer.Serialize(document);
|
||||
var bytes = Encoding.UTF8.GetBytes(json);
|
||||
await socket.SendAsync(bytes, WebSocketMessageType.Text, endOfMessage: true, stopping).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
if (socket.State == WebSocketState.Open)
|
||||
{
|
||||
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(1));
|
||||
try
|
||||
{
|
||||
await socket.CloseAsync(WebSocketCloseStatus.NormalClosure, "well-complete", cts.Token).ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
socket.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
internal static class MimirWellSnapshot
|
||||
{
|
||||
public static object Build(
|
||||
MimirWellOptions options,
|
||||
MimirRuntimeConfiguration runtimeConfig,
|
||||
MimirSynchronizationHub hub,
|
||||
MimirPresentationControlState presentation,
|
||||
MimirSynchronizedBufferFrame frame,
|
||||
IReadOnlyList<object> sourceErrors,
|
||||
long sequence,
|
||||
DateTimeOffset startedAt) => new
|
||||
{
|
||||
type = "cultmesh-observation",
|
||||
document = "mimir.well_snapshot.v1",
|
||||
sourceId = "mimir-well",
|
||||
nodeId = options.NodeId,
|
||||
sequence,
|
||||
wallClockUtc = DateTimeOffset.UtcNow.ToString("O"),
|
||||
elapsedSeconds = (DateTimeOffset.UtcNow - startedAt).TotalSeconds,
|
||||
ingestedSamples = hub.IngestedSamples,
|
||||
configuredSources = runtimeConfig.SourceFactories.Count,
|
||||
liveSources = hub.SourceCount,
|
||||
sourceErrors,
|
||||
buffers = hub.Buffers.Buffers.Select(BufferSnapshot).ToArray(),
|
||||
synchronizedFrame = new
|
||||
{
|
||||
frame.PresentationTimeNs,
|
||||
frame.WindowStartNs,
|
||||
frame.WindowEndNs,
|
||||
PresentationDelayMs = frame.PresentationDelay.TotalMilliseconds,
|
||||
frame.IsComplete,
|
||||
slices = frame.Slices.Select(SliceSnapshot).ToArray(),
|
||||
},
|
||||
audioSync = new
|
||||
{
|
||||
referenceSourceId = runtimeConfig.Settings.Audio.ReferenceSourceId,
|
||||
mode = runtimeConfig.Settings.Audio.Mode.ToString(),
|
||||
complexContour = hub.ComplexContourRuntimeEnabled,
|
||||
states = hub.AudioSynchronizationStates.Select(state => new
|
||||
{
|
||||
state.SourceId,
|
||||
state.ReferenceSourceId,
|
||||
state.SampleRate,
|
||||
state.SmoothedDelaySamples,
|
||||
state.SamplingRateOffsetPpm,
|
||||
state.Confidence,
|
||||
evidenceKind = "audio-sync",
|
||||
}).ToArray(),
|
||||
reports = hub.AudioSynchronizationReports.Select(report => new
|
||||
{
|
||||
report.SourceId,
|
||||
report.ReferenceSourceId,
|
||||
report.EvidenceKind,
|
||||
report.FractionalDelaySamples,
|
||||
report.Confidence,
|
||||
matchedEvents = report.TimelineMatchedEvents,
|
||||
report.ComparedSamples,
|
||||
report.AnalysisTimestampNs,
|
||||
}).ToArray(),
|
||||
probe = hub.LastBioacousticProbeSchedule is null
|
||||
? null
|
||||
: new
|
||||
{
|
||||
hub.LastBioacousticProbeSchedule.TimestampNs,
|
||||
hub.LastBioacousticProbeSchedule.ShouldEmit,
|
||||
hub.LastBioacousticProbeSchedule.ScheduledIntervalSeconds,
|
||||
hub.LastBioacousticProbeSchedule.AggregateSyncConfidence,
|
||||
hub.LastBioacousticProbeSchedule.AggregateFrequencyResponseConfidence,
|
||||
reason = hub.LastBioacousticProbeSchedule.Reason.ToString(),
|
||||
},
|
||||
},
|
||||
composite = new
|
||||
{
|
||||
video = presentation.VideoFeeds.Select(feed => new
|
||||
{
|
||||
feed.SourceId,
|
||||
feed.DisplayName,
|
||||
feed.Enabled,
|
||||
feed.Solo,
|
||||
feed.Opacity,
|
||||
feed.Layer,
|
||||
}).ToArray(),
|
||||
audio = presentation.AudioFeeds.Select(feed => new
|
||||
{
|
||||
feed.SourceId,
|
||||
feed.DisplayName,
|
||||
feed.Muted,
|
||||
feed.Solo,
|
||||
feed.Gain,
|
||||
}).ToArray(),
|
||||
postprocess = presentation.Postprocess,
|
||||
},
|
||||
publication = new
|
||||
{
|
||||
MimirObsPublicationConfigurations.NativeProgram.Id,
|
||||
MimirObsPublicationConfigurations.NativeProgram.VideoKind,
|
||||
MimirObsPublicationConfigurations.NativeProgram.VideoSourceName,
|
||||
MimirObsPublicationConfigurations.NativeProgram.AudioKind,
|
||||
MimirObsPublicationConfigurations.NativeProgram.TargetPresentationDelaySeconds,
|
||||
stems = MimirObsPublicationConfigurations.NativeProgram.AudioStems.Select(stem => new
|
||||
{
|
||||
stem.Id,
|
||||
stem.DisplayName,
|
||||
stem.ChannelCount,
|
||||
stem.UserMixable,
|
||||
stem.CarriesTimingWitness,
|
||||
stem.Notes,
|
||||
}).ToArray(),
|
||||
},
|
||||
};
|
||||
|
||||
private static object BufferSnapshot(MimirRollingStreamBuffer buffer) => new
|
||||
{
|
||||
buffer.Descriptor.SourceId,
|
||||
Kind = buffer.Descriptor.Kind.ToString(),
|
||||
Origin = buffer.Descriptor.Origin.ToString(),
|
||||
buffer.Descriptor.Label,
|
||||
buffer.Descriptor.EffectiveClockDomainId,
|
||||
buffer.Count,
|
||||
buffer.EdgeNs,
|
||||
buffer.WindowStartNs,
|
||||
hasLatest = buffer.Latest.HasValue,
|
||||
latest = buffer.Latest.HasValue ? SampleSnapshot(buffer.Latest.Value) : null,
|
||||
};
|
||||
|
||||
private static object SliceSnapshot(MimirSynchronizedStreamSlice slice) => new
|
||||
{
|
||||
slice.SourceId,
|
||||
Kind = slice.Kind.ToString(),
|
||||
Origin = slice.Origin.ToString(),
|
||||
Status = slice.Status.ToString(),
|
||||
slice.SourceTimestampNs,
|
||||
slice.CanonicalStartNs,
|
||||
slice.CanonicalEndNs,
|
||||
slice.PresentationTimeNs,
|
||||
slice.TimingOffsetNs,
|
||||
slice.DistanceFromPresentationNs,
|
||||
slice.TimingConfidence,
|
||||
slice.TimingEvidenceKind,
|
||||
sample = slice.Sample.HasValue ? SampleSnapshot(slice.Sample.Value) : null,
|
||||
};
|
||||
|
||||
private static object SampleSnapshot(MimirStreamSample sample) => new
|
||||
{
|
||||
sample.SourceId,
|
||||
Kind = sample.Kind.ToString(),
|
||||
Origin = sample.Origin.ToString(),
|
||||
sample.TimestampNs,
|
||||
sample.ArrivalNs,
|
||||
sample.Sequence,
|
||||
sample.PayloadHandle,
|
||||
sample.ByteLength,
|
||||
video = sample.VideoFrame is null ? null : new
|
||||
{
|
||||
sample.VideoFrame.Width,
|
||||
sample.VideoFrame.Height,
|
||||
PixelFormat = sample.VideoFrame.PixelFormat.ToString(),
|
||||
sample.VideoFrame.StrideBytes,
|
||||
sample.VideoFrame.DeviceTimestampNs,
|
||||
sample.VideoFrame.NativeHandle,
|
||||
sample.VideoFrame.NativeHandleKind,
|
||||
sample.VideoFrame.ResourceKey,
|
||||
sample.VideoFrame.ProducerFenceHandle,
|
||||
sample.VideoFrame.ProducerFenceValue,
|
||||
sample.VideoFrame.UnavoidableCopyCount,
|
||||
},
|
||||
audio = sample.AudioBlock is null ? null : new
|
||||
{
|
||||
sample.AudioBlock.SampleRate,
|
||||
sample.AudioBlock.Channels,
|
||||
SampleFormat = sample.AudioBlock.SampleFormat.ToString(),
|
||||
sample.AudioBlock.FrameCount,
|
||||
sample.AudioBlock.DeviceTimestampNs,
|
||||
sample.AudioBlock.NativeHandle,
|
||||
sample.AudioBlock.NativeHandleKind,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
@ -336,3 +336,4 @@
|
|||
{"ts": "2026-06-01T17:38:44+01:00", "type": "implementation", "status": "ok", "note": "2026-06-01: Eve/CultUI retained elements now carry typed CultCache/CultMesh binding descriptors (document schema/id, field path, value kind, access, authority, optional command id). Mimir binds editor output controls, selected-layer inspector fields, audio strips, and preview placement to those descriptors while native callbacks remain local lowering actuators."}
|
||||
{"ts": "2026-06-01T17:42:27+01:00", "type": "verification", "status": "ok", "note": "2026-06-01: Release builds passed for Fensalir Aquarium.Engine, Mimir.EveDashboard, and Mimir.App after adding typed Eve/CultUI binding descriptors. Mimir.BufferSmoke --scene-editor-smoke passed with preview/source placement interactions intact."}
|
||||
{"ts": "2026-06-01T21:06:07+01:00", "type": "implementation", "status": "ok", "note": "Added the first online Verse observation daemon stack: Mimir.EveSensorReceiver now serves a /eve/periwinkle/subscribe WebSocket lane, Mimir.VerseRecorder subscribes and writes session.json plus observations.jsonl under C:\\Users\\Meta\\Videos\\Mimir\\VerseCaptures, and scripts/start-online-verse-daemons.ps1 supervises relay, recorder, Nightwing Eyes/Move witness publication, music-synced Move gestures, and a local BufferSmoke runtime capture worker. Live run online-verse-daemons-20260601-210106 had relay, recorder, Move sync, BufferSmoke, and Nightwing witness running, with observations.jsonl past 1000 records and growing. This captures typed witness observations; raw aligned source windows/stems still need a MimirSynchronizationHub Verse publisher."}
|
||||
{"ts": "2026-06-01T21:27:15+01:00", "type": "implementation", "status": "partial", "note": "Added Mimir.Well as the long-running Starfire Well daemon and broad config/mimir-runtime.well.local.json. Live run online-verse-daemons-20260601-212502 started relay, recorder, Mimir.Well, music-synced de-Bruijn/microtonal Move gestures, and Nightwing witness PID 1116285. Recorder C:\\Users\\Meta\\Videos\\Mimir\\VerseCaptures\\20260601-212509 reached 292 records and included mimir.well_snapshot.v1, Nightwing builtin camera/mic witness records, and ps3-eye-0/1 Move observations. Well snapshots showed live Scarlett ASIO, Leap stereo IR, Kiyo Pro RGB, and Kiyo Basic RGB buffers; Raven and Eve lanes were configured but empty because their producers were not feeding. Sync frame remains degraded because ASIO device timestamps and camera driver timestamps are not yet mapped into one canonical timeline."}
|
||||
|
|
|
|||
|
|
@ -313,12 +313,18 @@ invariants:
|
|||
`/eve/periwinkle/subscribe` broadcasts normalized records to live
|
||||
subscribers. `Mimir.VerseRecorder` subscribes and writes a session manifest
|
||||
plus JSONL observation ledger under `C:\Users\Meta\Videos\Mimir\VerseCaptures`.
|
||||
`scripts/start-online-verse-daemons.ps1` supervises relay, recorder,
|
||||
Nightwing Eyes/Move witness publication, music-synced Move gestures, and a
|
||||
local `Mimir.BufferSmoke` runtime capture worker. This owns observation
|
||||
capture, not raw aligned media/stem publication yet; the next owner cut is
|
||||
a `MimirSynchronizationHub` Verse publisher for aligned source windows,
|
||||
sync states, stems, and actuator state.
|
||||
`Mimir.Well` is the Starfire Well daemon: it loads the broad Well runtime
|
||||
profile, starts every configured source it can, polls `MimirSynchronizationHub`
|
||||
with a bounded daemon budget, updates audio sync/probe state, and publishes
|
||||
`mimir.well_snapshot.v1` records containing buffer health, composite
|
||||
controls, publication/stem contract, and sync status. The online supervisor
|
||||
now starts relay, recorder, Nightwing Eyes/Move/builtin-camera/builtin-mic
|
||||
witness publication, de-Bruijn/microtonal music-synced Move gestures, and
|
||||
`Mimir.Well`. This owns typed state publication, not raw CultMesh media
|
||||
payloads yet. The live timestamp-domain scar is explicit: ASIO device time
|
||||
and camera driver time are not in one canonical timeline, so sync frame
|
||||
publication is degraded until a camera-clock/global-time correction owner
|
||||
exists.
|
||||
Eve follows the same distributed-witness rule for its own body:
|
||||
`eve-local-sensor-witness` / `eve-local-sensors` owns Eve camera, Eve mic,
|
||||
local flash/chirp decode, feature tracks, visual markers, and local frustum
|
||||
|
|
|
|||
|
|
@ -13,10 +13,12 @@ import argparse
|
|||
import base64
|
||||
import datetime as dt
|
||||
import glob
|
||||
import math
|
||||
import os
|
||||
import random
|
||||
import socket
|
||||
import struct
|
||||
import subprocess
|
||||
import time
|
||||
import urllib.parse
|
||||
|
||||
|
|
@ -213,6 +215,83 @@ def observations(sequence: int) -> list[bytes]:
|
|||
return docs
|
||||
|
||||
|
||||
def builtin_camera_observations(args: argparse.Namespace, sequence: int) -> list[bytes]:
|
||||
docs: list[bytes] = []
|
||||
for node, index, name in video_devices():
|
||||
lname = name.lower()
|
||||
is_eye = "gspca" in lname or "playstation" in lname or "eye" in lname
|
||||
if is_eye:
|
||||
continue
|
||||
docs.append(sensor_document(
|
||||
observation_id=f"nightwing:{node}:builtin-camera:{sequence}",
|
||||
device_id="nightwing",
|
||||
stream_id=f"nightwing-{node}",
|
||||
kind="mimir.nightwing_builtin_camera_witness.v1",
|
||||
sequence=sequence,
|
||||
values=[1.0, float(index), float(len(name)), float(args.interval)],
|
||||
accuracy=2,
|
||||
))
|
||||
if not docs:
|
||||
docs.append(sensor_document(
|
||||
observation_id=f"nightwing:builtin-camera:missing:{sequence}",
|
||||
device_id="nightwing",
|
||||
stream_id="nightwing-builtin-camera",
|
||||
kind="mimir.nightwing_builtin_camera_witness.v1",
|
||||
sequence=sequence,
|
||||
values=[0.0],
|
||||
accuracy=0,
|
||||
))
|
||||
return docs
|
||||
|
||||
|
||||
def builtin_mic_observation(args: argparse.Namespace, sequence: int) -> bytes:
|
||||
values = [0.0, 0.0, 0.0, float(args.mic_sample_rate)]
|
||||
accuracy = 0
|
||||
try:
|
||||
result = subprocess.run(
|
||||
[
|
||||
"timeout",
|
||||
str(max(0.05, args.mic_window_seconds)),
|
||||
"arecord",
|
||||
"-D",
|
||||
args.mic_device,
|
||||
"-f",
|
||||
"S16_LE",
|
||||
"-r",
|
||||
str(args.mic_sample_rate),
|
||||
"-c",
|
||||
"1",
|
||||
"-t",
|
||||
"raw",
|
||||
"-q",
|
||||
],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.DEVNULL,
|
||||
check=False,
|
||||
timeout=max(0.2, args.mic_window_seconds + 0.2),
|
||||
)
|
||||
data = result.stdout
|
||||
count = len(data) // 2
|
||||
if count > 0:
|
||||
samples = struct.unpack("<" + "h" * count, data[:count * 2])
|
||||
rms = math.sqrt(sum(float(sample) * float(sample) for sample in samples) / count) / 32768.0
|
||||
peak = max(abs(sample) for sample in samples) / 32768.0
|
||||
values = [1.0, rms, peak, float(args.mic_sample_rate), float(count)]
|
||||
accuracy = 2 if rms > 0.0 else 1
|
||||
except Exception:
|
||||
values = [0.0, 0.0, 0.0, float(args.mic_sample_rate)]
|
||||
accuracy = 0
|
||||
return sensor_document(
|
||||
observation_id=f"nightwing:builtin-mic:{sequence}",
|
||||
device_id="nightwing",
|
||||
stream_id="nightwing-builtin-mic",
|
||||
kind="mimir.nightwing_builtin_mic_witness.v1",
|
||||
sequence=sequence,
|
||||
values=values,
|
||||
accuracy=accuracy,
|
||||
)
|
||||
|
||||
|
||||
def eye_tracking_observations(args: argparse.Namespace, sequence: int) -> list[bytes]:
|
||||
if nw_eye_cap is None or nw_move_hint is None:
|
||||
return []
|
||||
|
|
@ -297,6 +376,11 @@ def run(args: argparse.Namespace) -> None:
|
|||
while True:
|
||||
for payload in observations(sequence):
|
||||
ws.send_binary(payload)
|
||||
if args.track_builtin_camera:
|
||||
for payload in builtin_camera_observations(args, sequence):
|
||||
ws.send_binary(payload)
|
||||
if args.track_builtin_mic:
|
||||
ws.send_binary(builtin_mic_observation(args, sequence))
|
||||
if args.track_eyes:
|
||||
for payload in eye_tracking_observations(args, sequence):
|
||||
ws.send_binary(payload)
|
||||
|
|
@ -318,6 +402,8 @@ def main() -> int:
|
|||
parser.add_argument("--reconnect-seconds", type=float, default=2.0)
|
||||
parser.add_argument("--once", action="store_true")
|
||||
parser.add_argument("--track-eyes", action="store_true", help="Publish compact Nightwing-local PS3 Eye Move-sphere observations.")
|
||||
parser.add_argument("--track-builtin-camera", action="store_true", help="Publish compact status for Nightwing-local non-Eye camera devices.")
|
||||
parser.add_argument("--track-builtin-mic", action="store_true", help="Publish compact ALSA microphone level observations.")
|
||||
parser.add_argument("--eye-devices", default="/dev/video2,/dev/video3")
|
||||
parser.add_argument("--eye-width", type=int, default=320)
|
||||
parser.add_argument("--eye-height", type=int, default=240)
|
||||
|
|
@ -325,6 +411,9 @@ def main() -> int:
|
|||
parser.add_argument("--eye-window-seconds", type=float, default=0.12)
|
||||
parser.add_argument("--tracking-stride", type=int, default=6)
|
||||
parser.add_argument("--min-confidence", type=float, default=0.25)
|
||||
parser.add_argument("--mic-device", default="default")
|
||||
parser.add_argument("--mic-sample-rate", type=int, default=16000)
|
||||
parser.add_argument("--mic-window-seconds", type=float, default=0.08)
|
||||
args = parser.parse_args()
|
||||
run(args)
|
||||
return 0
|
||||
|
|
|
|||
|
|
@ -239,6 +239,18 @@ class OnlineAnalyzer:
|
|||
return best_f0, (float(bands[0]), float(bands[1]), float(bands[2]))
|
||||
|
||||
|
||||
DEBRUIJN_2_3 = "00010111"
|
||||
|
||||
|
||||
def debruijn_accent(frame_phase: float, move_index: int, args: argparse.Namespace) -> float:
|
||||
if not args.debruijn_polyrhythm:
|
||||
return 1.0
|
||||
lane_rate = args.debruijn_rate + move_index
|
||||
cursor = int(math.floor(frame_phase * max(1, lane_rate))) % len(DEBRUIJN_2_3)
|
||||
bit = 1.0 if DEBRUIJN_2_3[(cursor + move_index) % len(DEBRUIJN_2_3)] == "1" else 0.0
|
||||
return 0.58 + 0.42 * bit
|
||||
|
||||
|
||||
def move_rgb(move: Move, move_index: int, move_count: int, state: dict[str, object], args: argparse.Namespace) -> tuple[int, int, int]:
|
||||
level = float(state["level"])
|
||||
beat = float(state["beat_phase"])
|
||||
|
|
@ -246,10 +258,13 @@ def move_rgb(move: Move, move_index: int, move_count: int, state: dict[str, obje
|
|||
base_h, base_s, _ = rgb_to_hsv01(move.base_rgb)
|
||||
spectral = state["color_balance"]
|
||||
assert isinstance(spectral, tuple)
|
||||
phase = (beat + move_index / max(1, move_count)) % 1.0
|
||||
gesture = 0.52 + 0.48 * (0.5 + 0.5 * math.sin(2.0 * math.pi * phase)) ** 1.7
|
||||
accent = min(1.0, level * gesture + hit * 0.55)
|
||||
hue = (base_h + 0.045 * math.sin(2.0 * math.pi * phase)) % 1.0
|
||||
harmonic = args.harmonic_base ** (move_index / max(1, move_count))
|
||||
micro = 2.0 ** ((move_index - (move_count - 1) * 0.5) * args.microtonal_cents / 1200.0)
|
||||
phase = (beat * harmonic * micro + move_index / max(1, move_count)) % 1.0
|
||||
poly = debruijn_accent(beat, move_index, args)
|
||||
gesture = poly * (0.42 + 0.58 * (0.5 + 0.5 * math.sin(2.0 * math.pi * phase)) ** 2.1)
|
||||
accent = min(1.0, level * gesture + hit * (0.48 + 0.18 * poly))
|
||||
hue = (base_h + args.hue_bend * math.sin(2.0 * math.pi * phase) + math.log2(harmonic * micro) * 0.0833) % 1.0
|
||||
sat = min(1.0, max(0.72, base_s) + 0.18 * hit)
|
||||
val = min(1.0, accent ** 0.55)
|
||||
rr, gg, bb = colorsys.hsv_to_rgb(hue, sat, val)
|
||||
|
|
@ -296,6 +311,11 @@ def main() -> int:
|
|||
parser.add_argument("--tempo-max-bpm", type=float, default=260.0)
|
||||
parser.add_argument("--fundamental-min", type=float, default=55.0)
|
||||
parser.add_argument("--fundamental-max", type=float, default=880.0)
|
||||
parser.add_argument("--debruijn-polyrhythm", action="store_true")
|
||||
parser.add_argument("--debruijn-rate", type=int, default=3)
|
||||
parser.add_argument("--harmonic-base", type=float, default=1.5)
|
||||
parser.add_argument("--microtonal-cents", type=float, default=17.0)
|
||||
parser.add_argument("--hue-bend", type=float, default=0.075)
|
||||
args = parser.parse_args()
|
||||
|
||||
out_dir = Path(args.out_dir)
|
||||
|
|
|
|||
Loading…
Reference in a new issue