geigr / ipytone

Interactive audio in Jupyter
https://ipytone.readthedocs.io
BSD 3-Clause "New" or "Revised" License
60 stars 8 forks source link

High-level vs. low-level audio graph #64

Open benbovy opened 2 years ago

benbovy commented 2 years ago

It would be nice to have a high-level representation of the graph of audio nodes that doesn't contain all the internal nodes (and their connections) defined within the audio nodes.

By default, all new connections are considered as high-level. A context manager may help in temporarily disabling this behavior, e.g.,

class MyAudioNode(ipytone.PyAudioNode):

    def __init__(self, **kwargs):
        in_node = Gain()
        out_node = Gain()
        super().__init__(in_node, out_node, **kwargs)

        with self._graph.at_low_level():
            # all connections here will be at low-level
            in_node.connect(out_node)

For example, add a tag low_level=True to audio graph connections.

benbovy commented 2 years ago

Or use internal instead of low_level...