Subgraphs
Subgraphs are a powerful feature of the Switchboard SDK that allow you to nest audio graphs inside other audio graphs. This modular approach lets you encapsulate a group of interconnected nodes as a single unit, making your audio processing pipelines more organized, reusable, and maintainable.
A subgraph can represent a specific audio processing function—such as an effects chain, a signal router, or a synthesis module—and can be connected to the main graph just like any other node.
Why Use Subgraphs?
- Modularity: Break down complex graphs into manageable, reusable components.
- Encapsulation: Hide internal details and expose only the necessary inputs/outputs.
- Reusability: Use the same subgraph in multiple places or projects.
- Maintainability: Make changes to a subgraph without affecting the rest of your graph.
Subgraph Node Types
Switchboard SDK provides three types of subgraph nodes, each corresponding to a different role in the audio graph:
Node | Description |
---|---|
SubgraphSource | A source node that produces audio from a nested audio graph. Use this when your subgraph only has outputs. |
SubgraphProcessor | A processor node that processes audio using a nested audio graph. Use this when your subgraph has both inputs and outputs. |
SubgraphSink | A sink node that consumes audio with a nested audio graph. Use this when your subgraph only has inputs. |
Example: FX Chain as a Subgraph
Suppose you want to encapsulate an effects chain (e.g., reverb and delay) as a reusable subgraph. You can create a subgraph with its own input and output nodes, connect your effect nodes inside, and then use a SubgraphProcessor node to include it in your main graph.
How to Use Subgraphs
- Define the subgraph as a separate audio graph (with its own nodes and connections).
- Reference the subgraph in your main graph using one of the subgraph node types above.
- Connect the subgraph node to other nodes in your main graph as needed.
You can pass configuration to the subgraph via the graph
parameter in the subgraph node's configuration.
More Information
- See the SubgraphSource, SubgraphProcessor, and SubgraphSink documentation for details on configuration and usage.
- For advanced routing and format conversion, see Connecting Nodes.
Subgraphs make it easy to build scalable, maintainable, and reusable audio processing systems in Switchboard SDK.