Node Proxies¶
Live-coding proxies. NodeProxy owns a private bus plus a source and monitor
synth so the source can be hot-swapped without an audible gap; Ndef is the
named global registry over it.
nanosynth.proxy ¶
NodeProxy and Ndef -- live coding with hot-swappable synth definitions.
A NodeProxy owns a private audio bus, a source synth, and a monitor
synth. Hot-swapping replaces only the source synth while the monitor
stays in place, enabling seamless audio transitions.
Ndef is a global named proxy registry for concise live-coding::
from nanosynth.proxy import Ndef
Ndef(server, "pad", lambda: SinOsc.ar(440) * 0.3)
Ndef(server, "pad").play()
Ndef(server, "pad", lambda: Saw.ar(220) * 0.2) # hot-swap
Ndef(server, "pad").clear()
NodeProxy ¶
Hot-swappable synth node backed by a private audio bus.
The proxy owns:
- A private audio bus (allocated via server.audio_bus())
- A source synth (writes to the private bus)
- A monitor synth (reads from private bus, writes to hardware output)
Swapping the source replaces only the source synth. The monitor stays in place, so the output bus never changes.
Args: server: The Server instance. num_channels: Number of audio channels for the private bus.
source
property
writable
¶
source: Callable[..., Any] | SynthDef | None
The current source (callable, SynthDef, or None).
play ¶
play(out: int = 0, num_channels: int | None = None) -> None
Start monitoring (create monitor synth reading from private bus).
Args: out: Hardware output bus index. num_channels: Override channel count (defaults to proxy's channel count).
set ¶
set(**params: float) -> None
Set parameters on the running source synth.
Raises: EngineError: If no source synth is running.
Ndef ¶
Global registry of named NodeProxy instances.
Ndef is a factory that returns (or creates) a NodeProxy for a
given server + name pair. If a source is provided, it is assigned
to the proxy.
Usage::
Ndef(server, "pad", lambda: SinOsc.ar(440) * 0.3)
Ndef(server, "pad").play()
Ndef(server, "pad", lambda: Saw.ar(220) * 0.2) # hot-swap
Ndef(server, "pad").clear()
Ndef.clear_all(server)