Skip to content

Audio: node graph with explicit port routing - #302

Draft
catilac wants to merge 2 commits into
audio-devicesfrom
audio-graph
Draft

catilac wants to merge 2 commits into
audio-devicesfrom
audio-graph

Conversation

@catilac

@catilac catilac commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Adds a generic audio node graph.

  • audio_node_create: volume, volume/pan, mix, SVF and one-pole filters (1 to 8 channels), freeverb, white and pink noise.
  • audio_node_set / audio_node_set_variant / audio_node_get: set or read any numeric or enum parameter by field name, using reflection.
  • audio_connect / audio_disconnect: always explicit (source_port, destination_port) pairs.
  • audio_input / audio_output: the graph's I/O, with one port per device channel (at least 8).

No implicit routing. Every node gets seedling's NoAutoConnect, so nothing is sent to a MainBus and there is no automatic up/down-mixing. A signal on channel 5 stays on channel 5, which matters for DC-coupled CV as much as for audio.

Review notes

  • All the graph logic is in graph.rs.
  • The for_channels! macro maps a runtime channel count onto the filters' const-generic width.

Testing: cargo test -p processing_audio (graph width, exact edges, port checks, parameters, no auto-connect).


Stack created with GitHub Stacks CLI • Give Feedback 💬

@catilac
catilac added this pull request to stack #306 December 1, 2026 05:13
@catilac catilac changed the title processing_audio: node graph with explicit port routing Audio: node graph with explicit port routing Dec 1, 2026
A sketch enables audio with ConfigKey::AudioEnabled before init(). Seedling then builds the context and graph at startup and we open the stream during init(); without the flag no device is opened and the audio functions return AudioNotEnabled.

We manage the cpal stream ourselves instead of seedling's CpalPlatformPlugin:
- one output and one optional input device (none by default, so no microphone prompt), by name or index;
- a named output is never swapped for another device: if it disappears the stream stops, and it resumes on the same graph when the device returns;
- device, sample rate and block size can change while running;
- status, info and stream events (lost/restored devices, xruns, restarts).

Tests run on a mock backend that pulls blocks without audio hardware, including restarts at changing block sizes.
Create filters, gains, mixers, reverb and noise; set any numeric or enum parameter by name through reflection; and wire nodes with explicit (source_port, destination_port) pairs.

There is no implicit routing or channel mixing anywhere: nodes use NoAutoConnect so nothing is sent to a MainBus, and every edge is one the sketch made. A signal on channel 5 stays on channel 5, which matters for DC-coupled CV as much as for audio. The graph input and output have one port per device channel (at least 8).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant