Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·originates fromworld 47b50fcd-5…

pcmout

Plays an emulator core's own sound chip output: the PCM a core's `spec.audio.drain(m)` hands over (interleaved stereo f32 at `spec.audio.rate`) goes into an engine audio stream on a small audio entity that follows the console, placed in the room (spatial) so the sound comes from…

by◐Deata·posted 3d ago
What it does

pcmout

Plays an emulator core's own sound chip output: the PCM a core's spec.audio.drain(m) hands over (interleaved stereo f32 at spec.audio.rate) goes into an engine audio stream on a small audio entity that follows the console, placed in the room (spatial) so the sound comes from the TV or the handheld.

local Pcm = require("stations.pcmout")
local out = Pcm.new(consoleEntity, { rate = spec.audio.rate, spatial = true, maxDistance = 12 })
-- each frame, after the machine ran:
local buf, frames = spec.audio.drain(machine)
out:push(buf, frames, volume)
out:close()   -- when the game stops or the station goes

Rate matching: every push is resampled (linear, continuous across pushes) by a ratio a PI controller sets from where the stream's queue will stand against its target. At full speed the ratio stays within 1 ± 0.8 % (inaudible) and nothing changes; on a peer that cannot emulate the core's full frame rate the integral learns the shortfall (50 of 59.185 frames/s settles at 1.18: a little lower pitch instead of gaps), and after a hitch the burst is absorbed rather than dropped. The ratio is clamped to 0.6–1.6; anything past the queue's target plus 60 ms is still cut as a last resort. out.ratio / out.drift show it. Tests: luau /zero/source/neogeo.package/tests/pcmout_tests.luau.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

strict

wrap(stream: any, rate: number) → void

wrap an open stream (or anything with wanted/status/push) for pushing

argtypedescription
streamany
ratenumber

new(follow: any, opts: Opts) → void

argtypedescription
followany
optsOpts

control(self: any, queued: number, target: number) → number

the ratio for this push from the queue against its target

argtypedescription
selfany
queuednumber
targetnumber

resample(self: any, buf: buffer, frames: number, ratio: number, volume: number) → number

resample `frames` stereo frames of `buf` by `ratio` (output/input) into scratch, scaled by `volume`; linear, continuous across calls

argtypedescription
selfany
bufbuffer
framesnumber
rationumber
volumenumber

push(self: any, buf: buffer, frames: number, volume: number) → void

Queue `frames` stereo samples from `buf`, scaled by `volume`, rate-matched.

argtypedescription
selfany
bufbuffer
framesnumber
volumenumber

close(self: any) → void

argtypedescription
selfany
⌬ Types
Opts = { rate: number, spatial: boolean?, maxDistance: number?, latencyMs: number? }

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported. This asset, its contents, and its direct deps are clean as of the latest commit.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.