Skip to content

Worker kit: parallel audio workers, pausing, and app messages - #11

Merged
bdbarnett merged 1 commit into
mainfrom
ostinato/worker-kit-2
Oct 15, 2026
Merged

bdbarnett merged 1 commit into
mainfrom
ostinato/worker-kit-2

Conversation

@bdbarnett

Copy link
Copy Markdown
Contributor

Three additions to workers/, from using the kit in a real app:

  • Several audio workers in parallel. createAudio() now returns addStream(): give each audio worker its own stream and the worklet sums them, then applies a master gain (setGain) and a peak limiter. Rendering spreads over cores, and the wire protocol per stream is unchanged.
  • Pausing a stream. A worker that's about to be busy for a while (building an instrument, say) posts {pause: true} on its audio port, and {pause: false} when it's done. The worklet plays that stream as silence meanwhile, instead of counting dropouts and backing off its queue.
  • App messages. Python in a worker and the page can exchange {type: "app", ...} messages, for things only the page can do, such as the browser's file pickers. handle.send() on the page, js.self.onPageMessage in Python.

The adaptive queue now steps down while every stream's low point stays above 384 frames (512 before). docs/workers.md covers all three.

…es to and from the page

createAudio().addStream() gives each audio worker its own stream; the worklet
sums them, applies a master gain and a peak limiter. A worker about to be busy
posts {pause: true} so its stream plays as silence instead of counting
dropouts. Python and the page exchange {type: "app"} messages for things only
the page can do (file pickers). The adaptive queue steps down while every
stream's low point stays above 384 frames.
@bdbarnett
bdbarnett merged commit b4603e2 into main Oct 15, 2026
1 check passed
@bdbarnett
bdbarnett deleted the ostinato/worker-kit-2 branch October 15, 2026 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant