Files
workinf_Blender_Wasm/web/protocol/native-audio.ts
mes123456 f3e21c6b98
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
chore: checkpoint web Blender migration source, tools and docs
Accumulated uncommitted work: GHOST Web backend, WebGL/GPU web layer,
web workflow engine and protocol, tooling, docs and task records.
Large generated evidence, user-testing archives, build snapshots and
imported test assets remain untracked.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-10 11:18:01 +08:00

34 lines
1.6 KiB
TypeScript

/** PCM is produced exclusively by Blender's Audaspace device. */
export const NATIVE_AUDIO_RATE = 48000;
export const NATIVE_AUDIO_CHANNELS = 2;
export const NATIVE_AUDIO_FRAMES = 1024;
// Native mixer blocks, not a second decoder or playback clock. Keep both normal
// look-ahead and the temporary synchronous-call reserve strictly bounded.
export const NATIVE_AUDIO_BUFFER_BLOCKS = 6;
export const NATIVE_AUDIO_RECOVERY_BLOCKS = 12;
export const NATIVE_AUDIO_BUSY_BLOCKS = 24;
export type NativeAudioPull = { type: "pull"; generation: number; sequence: number; blocks: number };
export type NativeAudioPrepared = { type: "prepared"; generation: number; sequence: number };
/** Device-clock positions, in seconds on AudioContext's timeline. Frame offsets
* count only PCM produced by the native mixer in this generation. Gaps between
* scheduled blocks are silence and must not advance Blender's scene clock. */
export type NativeAudioSegment = { start: number; frames: number; firstFrame: number };
export type NativeAudioClock = {
type: "clock";
generation: number;
sequence: number;
sampledAtMs: number;
outputTime: number;
running: boolean;
completedFrames: number;
segments: NativeAudioSegment[];
};
export type NativeAudioInput = NativeAudioPull | NativeAudioClock | NativeAudioPrepared;
export type NativeAudioOutput =
| { type: "reset"; generation: number }
| { type: "prepare"; generation: number; sequence: number; expiresAtMs: number }
| { type: "clockAck"; generation: number; sequence: number }
| { type: "pcm"; generation: number; sequence: number; samples?: ArrayBuffer }
| { type: "error"; generation: number; message: string };