Phase 9 of the rebrand cascade. Sweep covers everything the Phase 8
frontend pass deliberately skipped: docs/, root markdown, scripts,
Cargo.toml descriptions, code comments that survived earlier
word-boundary sed, plus a handful of identifiers caught on the final
verify pass.
transcription-app changes:
- README.md, HANDOVER.md, KNOWN-ISSUES.md, run.sh — magnotia/Magnotia
-> lumotia/Lumotia.
- docs/ — sweep across all subdirs except docs/handovers/ (preserved
as immutable audit trail). Includes architecture-map references
to magnotia_core::*, magnotia_storage::*, etc. now pointing at
lumotia_*; dev-setup.md tracing output examples (lumotia_startup
target); brief/ + superpowers/ + issues/ + whisper-ecosystem/ +
audit/.
- Cargo.toml descriptions on 9 crates (core, audio, cloud-providers,
hotkey, llm, mcp, plus referenced others).
- crates/core/src/{error,hardware,recommendation,paths}.rs +
crates/audio/src/wav.rs + crates/llm/src/model_manager.rs +
crates/cloud-providers/src/keystore.rs + crates/mcp/src/lib.rs —
doc comments and a model-manager user-agent string.
- Caught on final pass: BroadcastChannel("magnotia_task_sync") -> ...
("lumotia_task_sync"); magnotia_locale i18n localStorage key
renamed + migration shim added; CSS keyframe names
magnotiaPulse / magnotiaBar / magnotiaFade renamed in the design-
system kit; magnotia_viewer_item / magnotia_viewer_mode handoff
keys renamed in HistoryPage + viewer/+page.svelte; src/assets/
wordmark.svg text.
- src-tauri/src/lib.rs comment cleanup ("magnotia era" was sed'd
to "lumotia era" earlier — restored).
Preserved (intentional):
- crates/core/src/paths.rs — keeps "magnotia" / "Magnotia" / ".magnotia"
legacy detection strings in legacy_and_target_paths() so the
migration shim can still find user data from the magnotia era.
- src/lib/stores/{page,focusTimer}.svelte.ts + src/lib/i18n/index.ts
— migration call sites reference the legacy magnotia keys
deliberately.
- docs/handovers/ — historical audit trail.
cargo build --workspace passes. npm run check: 0 errors / 0 warnings
(3958 files). cargo test --workspace: 339 pass / 0 fail.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4.1 KiB
4.1 KiB
name, type, slice, last_verified
| name | type | slice | last_verified |
|---|---|---|---|
| PCM bridge (AudioWorklet) | architecture-map-page | 03-audio-transcription | 2026/05/09 |
PCM bridge (AudioWorklet)
Where you are: Architecture map → Audio + Transcription → PCM bridge
Plain English summary. static/pcm-processor.js is a tiny browser-side AudioWorklet. It runs inside the Svelte frontend's AudioContext, naively downsamples the device's native rate to 16 kHz, and posts ~0.5 s batches of f32 samples back to the main thread. It only matters on a code path that goes browser-mic → frontend → Tauri command rather than the native cpal capture; today's primary path is MicrophoneCapture (Rust). Treat this file as a minimal fallback / web-context stub.
At a glance
- Runtime: browser AudioWorkletProcessor (not a Rust crate).
- Path:
static/pcm-processor.js - LOC: 44
- External deps: none (Web Audio API).
- Internal callers (best effort, slice 1 reconciles): the Svelte frontend instantiates it with
audioContext.audioWorklet.addModule("/pcm-processor.js")and listens forport.messageevents. The native cpal path inlumotia-audiois the production path; this exists for parity in dev/web contexts.
Public surface: registers the AudioWorklet processor name pcm-processor.
What's in here
The whole file:
class PcmProcessor extends AudioWorkletProcessor {
constructor() {
super();
this.buffer = [];
this.ratio = sampleRate / 16000;
this.needsResample = Math.abs(this.ratio - 1.0) > 0.01;
this.resamplePos = 0;
}
process(inputs) {
const input = inputs[0];
if (!input || input.length === 0) return true;
const samples = input[0]; // First channel (mono)
if (!samples) return true;
if (this.needsResample) {
// Simple downsampling to 16kHz
for (let i = 0; i < samples.length; i++) {
this.resamplePos += 1;
if (this.resamplePos >= this.ratio) {
this.buffer.push(samples[i]);
this.resamplePos -= this.ratio;
}
}
} else {
for (let i = 0; i < samples.length; i++) {
this.buffer.push(samples[i]);
}
}
if (this.buffer.length >= 8000) {
this.port.postMessage({ type: "pcm", samples: this.buffer });
this.buffer = [];
}
return true;
}
}
registerProcessor("pcm-processor", PcmProcessor);
sampleRate is the AudioWorklet global (the context's rate). The file picks the first channel and ignores the rest.
Data flow
mediaStream → MediaStreamAudioSourceNode → AudioWorkletNode("pcm-processor")
└─ process(inputs)
├─ if needsResample (ratio != 1): drop-sample downsample to 16 kHz
└─ else: passthrough
└─ buffer to ~0.5 s (8000 samples)
└─ postMessage({ type: "pcm", samples: f32[] })
└─ frontend receiver (slice 1) → Tauri command (slice 2)
Watch-outs
- Drop-sample downsampling, no anti-alias filter. Above ~8 kHz the result will alias. For ASR this is rarely a problem because Whisper expects 16 kHz inputs (so anything above 8 kHz Nyquist is already discarded), but if anyone repurposes this for non-ASR work it will show.
- Mono only. Reads channel 0, ignores channels 1+.
Math.abs(ratio - 1) > 0.01decides passthrough. A 16001 Hz context (rare but legal) would skip the resample loop.port.postMessageclones the array. No transferables in this implementation; large session lengths magnify the cost.- The native cpal path is the primary path. This worklet matters when the frontend captures audio itself (web build, dev preview without the Tauri shell). Slice 1 will know which routes mount it.
- Build artefacts mirror the source. Copies appear under
build/and.svelte-kit/output/client/after a build. The source-of-truth file isstatic/pcm-processor.js.
See also
- Audio capture pipeline — the production path using cpal, not this worklet.
- Audio resampling — the (much higher quality) sinc resampler used on the native path.
- Frontend Audio plumbing (slice 1) — the consumer of
port.postMessage.