feat(sim): board-agnostic speaker seam — audio out plays on the host

setSpeakerMonitor mirrors setMicrophoneSource: a part that models a
board with an on-board speaker/jack (reSpeaker Lite) gets the peak of
each block the guest played, so it can light a meter, while the audio
itself goes to the host's sound card via the engine bridge. Nothing is
wired for it on the canvas — that is the point: a real board plugged
into your speakers has no wire to draw. No-op on bridges without an
audio path, which reads as a silent speaker.
This commit is contained in:
David Montero Crespo 2026-07-31 17:29:52 +02:00
parent e0a69fecae
commit 8ff8fdb292
1 changed files with 13 additions and 0 deletions

View File

@ -408,6 +408,19 @@ class Esp32BridgeShim {
).setMicrophoneSource?.(source); ).setMicrophoneSource?.(source);
} }
/**
* Watch the board's audio OUTPUT: the callback gets the peak level of each
* block the guest played (0..32767). The audio itself goes to the host's
* sound card a board with an on-board speaker/jack plays through YOUR
* speakers, so nothing is wired for it on the canvas; this is only the
* "is it making sound" signal a part needs to animate. Pass null to stop.
* No-op on bridges without an audio path (a silent speaker).
*/
setSpeakerMonitor(cb: ((peak: number) => void) | null): void {
(this.bridge as { setSpeakerMonitor?: (c: ((p: number) => void) | null) => void })
.setSpeakerMonitor?.(cb);
}
/** Remove a previously-registered virtual device. */ /** Remove a previously-registered virtual device. */
removeI2CDevice(addr: number, _bus: 0 | 1 = 0): void { removeI2CDevice(addr: number, _bus: 0 | 1 = 0): void {
this.i2cBusInstance.removeDevice(addr); this.i2cBusInstance.removeDevice(addr);