sound.run

sound

run(dev, mx, opts) -> task/fn

Run the audio writer task on the LEV event loop

Spawns (into the current lev.run) a coroutine that waits for the device to be writable and feeds it one period of mixed audio at a time — the recommended way to drive audio next to a frame loop. When no voices play it writes silence to keep the stream from underrunning.

opts fielddefaultdescription
timeout0.1poll/cancel-check interval, seconds
cancelnila lev.cancel_token — when fired the task exits
name"sound_writer"task name
spawntrueset false to get the loop body back as a function and drive it yourself

Requires LEV; with spawn ~= false it must be called inside lev.run().