### Run Python Example Script Source: https://github.com/supriya-project/supriya/blob/main/docs/source/examples/index.rst Demonstrates how to execute a Python example script from the repository's examples directory. This command assumes you are in the correct working directory relative to the script. It requires Python to be installed. ```shell python -m examples.hello_world ``` -------------------------------- ### Install FFmpeg and LAME via apt (Ubuntu) Source: https://github.com/supriya-project/supriya/blob/main/docs/source/introduction/installation.rst Installs FFmpeg and LAME on Ubuntu systems using the apt package manager. These are necessary for converting audio output to formats compatible with web browsers. ```console josephine@laptop:~$ sudo apt-get install ffmpeg lame ``` -------------------------------- ### Verify Graphviz Installation Source: https://github.com/supriya-project/supriya/blob/main/docs/source/introduction/installation.rst Checks if the Graphviz installation is successful by running the 'dot -V' command to display the version information. This confirms that Graphviz is accessible from the command line. ```console josephine@laptop:~$ dot -V dot - graphviz version 13.1.0 (20250701.0955) ``` -------------------------------- ### Shell: Run Supriya Debugging Example Source: https://github.com/supriya-project/supriya/blob/main/docs/source/examples/hello_world_debugged.rst Command to execute the main Python script for the 'hello, world!' debugging example. This will launch Supriya, perform synth operations, and output detailed debugging information. ```shell python -m examples.hello_world_debugged ``` -------------------------------- ### Python: Supriya's 'hello, world!' main function Source: https://github.com/supriya-project/supriya/blob/main/docs/source/examples/hello_world.rst This Python code snippet, extracted from Supriya's 'hello, world!' example, defines the main function that orchestrates playing a sound. It includes steps for setting up a server, defining and allocating a SynthDef, creating synths, allowing them to play, and cleaning up resources. The code relies on external modules for server and SynthDef management. ```python def main(): """The main function for the 'hello, world!' example.""" # See the :si-icon:`octicons/mark-github-16` :github-tree:`full example # source code ` on GitHub. # We need a :doc:`server <../tutorials/servers>`, booted and online with server.bootServer(duration=15) as running_server: # We need to find (or define) a :doc:`SynthDef <../tutorials/synthdefs>` # to act as the template for the synths that actually make sound # We need to allocate that SynthDef on the running server, and we need to # wait for allocation to complete (because SynthDef allocation is an # asynchronous command) with SynthDef(running_server, lambda s: s.ref().add( synth=synth.Synth( server=running_server, synthdef=lambda s: s.filter(freq=440, form=0, amp=0.1, decay=0.4) ) )).wait_for_grant() as synthdef: # Once the SynthDef finishes allocating, we need to create one or more # :doc:`synths <../tutorials/nodes>` # We need to give those synths some time to play so we can actually hear # them with synthdef.program().wait_for_grant() as synth: # And we should be good and clean up after ourselves: release the # synths, wait for them to fade out, then quit the running server synth.wait(5) ``` -------------------------------- ### Basic reStructuredText Example with uqbar.sphinx.book Source: https://github.com/supriya-project/supriya/blob/main/docs/source/developers/documenting.rst Demonstrates a basic usage of the '.. book::' directive from the uqbar.sphinx.book extension, which functions similarly to Sphinx's '.. code-block::' for executing and displaying code examples. ```rst .. book:: >>> print("this is basically the same as a \`.. code-block::'\`") ``` -------------------------------- ### Install Graphviz via apt (Ubuntu) Source: https://github.com/supriya-project/supriya/blob/main/docs/source/introduction/installation.rst Installs the Graphviz library on Ubuntu systems using the apt package manager. Graphviz is utilized for generating visualizations of tree structures and class hierarchies. ```console josephine@laptop:~$ sudo apt-get install graphviz ``` -------------------------------- ### Python Asyncio Keyboard Input Run Function Source: https://github.com/supriya-project/supriya/blob/main/docs/source/examples/keyboard_input_async.rst The 'run' function in the asynchronous keyboard input example. It demonstrates the core differences from the synchronous version by incorporating 'async' keywords for operations like booting, syncing, and quitting. It also details the crucial interaction between threaded input handling and the asyncio event loop via an asyncio.Queue. ```python async def run( context_context: supriya.contexts.core.Context, realtime_buffer_count: int = 5, log_level: Union[int, str] = "INFO", ): """Runs the keyboard input example. :param context_context: The context context. :param realtime_buffer_count: The number of realtime buffers. :param log_level: The logging level. """ async with supriya.RealtimeBootedContext(realtime_buffer_count=realtime_buffer_count) as context: async with supriya.contexts.core.ContextScaffolding(context) as scaffolding: queue = asyncio.Queue() def callback(event): queue.call_soon_threadsafe(queue.put_nowait, event) input_handler = QwertyHandler(callback) polyphony_manager = PolyphonyManager() async with input_handler: async with polyphony_manager: async_task = asyncio.create_task(queue_consumer(queue, polyphony_manager)) await scaffolding.run_forever() await async_task ``` -------------------------------- ### Start Chord Performance Logic (Python) Source: https://github.com/supriya-project/supriya/blob/main/docs/source/examples/hello_world_contexts.rst This function encapsulates the logic for starting a musical chord. It takes a context object as input and returns a list of synths. It's designed to be context-agnostic, meaning it can work with different Supriya contexts without modification. Note that timestamp management is handled externally. ```python def play_synths(context): """Play the synths. Args: context: The Supriya context. Returns: A list of synths. """ synth_a = context.add_synth("A", "sin-wave") synth_b = context.add_synth("E", "square-wave") synth_c = context.add_synth("C", "triangle-wave") return [synth_a, synth_b, synth_c] ``` -------------------------------- ### Install Graphviz via Homebrew (OSX) Source: https://github.com/supriya-project/supriya/blob/main/docs/source/introduction/installation.rst Installs the Graphviz library on macOS using the Homebrew package manager. Graphviz is used for visualizing rhythm-trees and class hierarchies. ```console josephine@laptop:~$ brew install graphviz ``` -------------------------------- ### Install FFmpeg and LAME via Chocolatey (Windows) Source: https://github.com/supriya-project/supriya/blob/main/docs/source/introduction/installation.rst Installs FFmpeg and LAME on Windows using the Chocolatey package manager. These utilities are essential for ensuring audio files are websafe for use in web browsers and documentation. ```console josephine@laptop:~$ choco install ffmpeg lame ``` -------------------------------- ### Install Graphviz via Chocolatey (Windows) Source: https://github.com/supriya-project/supriya/blob/main/docs/source/introduction/installation.rst Installs the Graphviz library on Windows using the Chocolatey package manager. Graphviz is a dependency for creating visualizations within the project. ```console josephine@laptop:~$ choco install graphviz ``` -------------------------------- ### Create Buffer from Partial Sound File with Supriya Source: https://github.com/supriya-project/supriya/blob/main/docs/source/tutorials/buffers.rst Demonstrates allocating a buffer from a specific portion of a sound file, including specifying the frame count and starting frame. The example also includes plotting and playing the selected audio segment. ```python >>> buffer_ = server.add_buffer( ... file_path=file_path, frame_count=8192, starting_frame=33091 // 2 ... ) >>> supriya.plot(buffer_) >>> supriya.play(buffer_) ``` -------------------------------- ### Install FFmpeg and LAME via Homebrew (OSX) Source: https://github.com/supriya-project/supriya/blob/main/docs/source/introduction/installation.rst Installs FFmpeg and LAME on macOS using Homebrew. These tools are required for transcoding audio files into websafe formats (OGG, MP3) for IPython and Sphinx integrations. ```console josephine@laptop:~$ brew install ffmpeg lame ``` -------------------------------- ### Start and Configure Supriya Server Source: https://github.com/supriya-project/supriya/blob/main/docs/notebooks/supercollider-symposium-2025/presentation.ipynb This snippet boots a Supriya server and configures it with default synthdefs. It then adds a default synth to the server, effectively starting a basic sound-generating process within the Supriya environment. This is fundamental for any audio generation tasks. ```python # turn soundcheck on import supriya server = supriya.Server().boot() with server.at(): with server.add_synthdefs(supriya.default): server.add_synth(supriya.default) ``` -------------------------------- ### Booting Supriya Server and Creating Score (Python) Source: https://github.com/supriya-project/supriya/blob/main/docs/source/tutorials/contexts.rst This snippet demonstrates how to initialize and boot a Supriya server for realtime audio processing and create a Score object for non-realtime processing. It highlights the fundamental setup for both types of contexts. ```python >>> server = supriya.Server().boot() # realtime >>> score = supriya.Score() # non-realtime ``` -------------------------------- ### Install Supriya from source Source: https://github.com/supriya-project/supriya/blob/main/README.md This sequence of commands clones the Supriya repository from GitHub, navigates into the directory, and installs it in editable mode. This is useful for development or when using the latest unreleased version. ```bash git clone https://github.com/supriya-project/supriya.git cd supriya pip install -e . ``` -------------------------------- ### Create Buffer from Sound File with Supriya Source: https://github.com/supriya-project/supriya/blob/main/docs/source/tutorials/buffers.rst Shows how to allocate a buffer and populate it with the contents of a sound file. This example uses a specific WAV file and demonstrates plotting and playing the buffer's content. ```python >>> file_path = supriya.samples_path / "birds-01.wav" >>> buffer_ = server.add_buffer(file_path=file_path) >>> supriya.plot(buffer_) >>> supriya.play(buffer_) ``` -------------------------------- ### Boot and Quit Supriya Server Source: https://github.com/supriya-project/supriya/blob/main/docs/source/tutorials/servers.rst Demonstrates how to start and stop the Supriya server. Booting the server initiates its operation, while quitting safely shuts it down. These actions are fundamental for managing the server's lifecycle. ```python server.boot() server.quit() ``` -------------------------------- ### Install Supriya using pip Source: https://github.com/supriya-project/supriya/blob/main/README.md This command installs the Supriya library from the Python Package Index (PyPI). Ensure you have pip installed and accessible in your environment. ```bash pip install supriya ``` -------------------------------- ### Basic Pytest Test for Node Tree Source: https://github.com/supriya-project/supriya/blob/main/docs/source/developers/testing.rst A fundamental pytest test demonstrating the setup, execution, and assertion phases. It boots a server, queries the node tree, asserts expectations, and then quits the server. This example is illustrative and highlights potential teardown issues if assertions fail. ```python import pytest from supriya import Scsynth def test_basic(): server = Scsynth() server.boot() nodes = server.query_node_tree() assert nodes == { "nodeID": 0, "children": [], "targetNodeID": None, "synthDefs": {}, "index": 0, "action": None, "frame_rate": 44100.0, "sample_rate": 44100.0, "block_size": 512, "num_buffers": 0, "num_nodes": 1, "plugins": [], "offset_seconds": 0.0, } server.quit() ``` -------------------------------- ### Python Script: Main Function for Supriya Contexts Source: https://github.com/supriya-project/supriya/blob/main/docs/source/examples/hello_world_contexts.rst This Python code defines the main function for the `hello_world_contexts` example. It parses command-line arguments and calls appropriate `run_...()` functions based on user input, demonstrating context-agnostic performance logic. ```python def main(): arguments = parse_args() if arguments.realtime_threaded: run_realtime_threaded(**arguments.__dict__) elif arguments.realtime: run_realtime(**arguments.__dict__) else: run_offline(**arguments.__dict__) ``` -------------------------------- ### Boot SuperCollider Server with Supriya Source: https://github.com/supriya-project/supriya/blob/main/docs/source/index.rst This snippet demonstrates how to import the Supriya library and boot the SuperCollider server. It initializes a Server object and calls the boot() method to start the synthesis engine. No specific dependencies are required beyond the Supriya library itself. ```python >>> import supriya >>> server = supriya.Server().boot() ``` -------------------------------- ### Python Example Module Structure Source: https://github.com/supriya-project/supriya/blob/main/docs/source/developers/documenting.rst Shows the standard structure for an example Python module within the Supriya project. It includes a 'main' function and an 'if __name__ == "__main__":' block for execution. ```python def main() -> None: print("this is an *example* example.") if __name__ == "__main__": main() ``` -------------------------------- ### Create and Play a Musical Score with Supriya Source: https://github.com/supriya-project/supriya/blob/main/tests/book/roots/test-book/index.rst This example shows how to construct a musical score using the `supriya.Score` class. It demonstrates adding synth definitions, instantiating a synth, and scheduling events at specific times. The `score.add_synthdefs` and `score.add_synth` methods are used to define and add musical elements, while `score.at()` controls timing. Finally, the score is played back using `supriya.play()`. ```python score = supriya.Score() with score.at(0): with score.add_synthdefs(supriya.default): synth = score.add_synth(supriya.default) with score.at(10): score.do_nothing() supriya.play(score) ``` -------------------------------- ### Python Asyncio Keyboard Input Main Function Source: https://github.com/supriya-project/supriya/blob/main/docs/source/examples/keyboard_input_async.rst The 'main' function for the asynchronous keyboard input example. Similar to the synchronous version, it wraps the call to the 'run' function within 'asyncio.run'. This ensures that the coroutine returned by 'run' is properly executed and completed within an asyncio event loop. ```python def main(): """Runs the keyboard input example. """ import argparse parser = argparse.ArgumentParser() parser.add_argument( "--realtime-buffer-count", "-b", type=int, default=5, help="Number of realtime buffers.", ) parser.add_argument( "--log-level", "-l", default="INFO", help="Logging level." ) args = parser.parse_args() asyncio.run(run(supriya.realtime.Context(), **vars(args))) ``` -------------------------------- ### Using Completion Argument for Server SynthDefs (Python) Source: https://github.com/supriya-project/supriya/blob/main/docs/source/tutorials/contexts.rst This example demonstrates how to use the `on_completion` argument with a callable for loading SynthDefs on a realtime Server. The callable is executed once the SynthDef loading is complete, allowing for subsequent operations like adding a synth. ```python >>> server.add_synthdefs( ... supriya.default, ... on_completion=lambda context: context.add_synth(supriya.default), ... ) ``` -------------------------------- ### Instantiate Supriya Server Source: https://github.com/supriya-project/supriya/blob/main/docs/notebooks/supercollider-symposium-2025/presentation.ipynb This code example demonstrates the instantiation of a Supriya Server object. It creates a new instance of the Server class, which can then be used to interact with an audio server. ```python # instantiate the server server = Server() ``` -------------------------------- ### Using Completion Context with Buffer Allocation (Python) Source: https://github.com/supriya-project/supriya/blob/main/docs/source/tutorials/contexts.rst This example demonstrates using a Completion context manager to handle the result of a buffer allocation on a realtime server. The `with completion:` block ensures that subsequent operations dependent on the buffer are executed after the buffer is successfully allocated. ```python >>> with server.at(): ... completion = server.add_buffer(channel_count=1, frame_count=512) ... >>> with completion: ... ... ... ``` -------------------------------- ### Create Buffer from Subset of Channels with Supriya Source: https://github.com/supriya-project/supriya/blob/main/docs/source/tutorials/buffers.rst Illustrates allocating a buffer from a multi-channel sound file, selecting specific channels using the `channel_indices` parameter. This example uses an octophonic WAV file. ```python >>> file_path = supriya.samples_path / "sine_440hz_44100sr_16bit_octo.wav" >>> server.add_buffer(channel_indices=[0, 1], file_path=file_path) ``` -------------------------------- ### Test Philosophy: Simplicity and Fixtures Source: https://github.com/supriya-project/supriya/blob/main/docs/source/developers/testing.rst This section outlines a philosophy for writing tests, emphasizing simplicity. It suggests keeping tests simple and pushing setup logic into fixtures whenever possible to maintain clarity and reduce redundancy. ```text Whenever possible, keep tests simple: - some setup (pushed into fixtures if at all possible) ``` -------------------------------- ### Python Test Suite Reference Source: https://github.com/supriya-project/supriya/blob/main/docs/source/developers/testing.rst This note indicates that the provided test examples are located in the official test suite at 'tests/test_examples.py'. It emphasizes that these tests are subject to the same formatting, linting, and static-typing checks as the rest of the Supriya codebase. ```text .. note:: The test examples here are :si-icon:`octicons/mark-github-16` :github-blob:`in the official test suite `, which ensures that they continue to work and are subject to the same formatting, linting and static-typing checks as any other code in Supriya. ``` -------------------------------- ### Run Non-Realtime Score (Python) Source: https://github.com/supriya-project/supriya/blob/main/docs/source/examples/hello_world_contexts.rst This function demonstrates audio rendering using a non-realtime Supriya Score context. It explicitly defines moments with absolute timestamps for starting and stopping synths, ensuring precise control over the audio event timing for offline rendering. ```python from supriya.contexts.nonrealtime import Score def run_nonrealtime(): """Run with a non-realtime score. """ score = Score() score.at(0). add_input(play_synths, "context") score.at(4). add_input(stop_synths, "context", "synths") score.at(5). add_input(lambda context, synths: None, "context", "synths") score.render(duration=6) ``` -------------------------------- ### Using Completion Context for SynthDefs and Synths on Score (Python) Source: https://github.com/supriya-project/supriya/blob/main/docs/source/tutorials/contexts.rst This example demonstrates using nested Completion and Moment contexts to load SynthDefs and then allocate a synth using those definitions within a non-realtime Score. This ensures the SynthDef is available before the synth is created. ```python >>> with score.at(0): ... with score.add_synthdefs(supriya.default): ... score.add_synth(supriya.default, target_node=score_group) ... ``` -------------------------------- ### Python: Supriya Server Lifecycle Events Source: https://github.com/supriya-project/supriya/blob/main/docs/source/tutorials/servers.rst Demonstrates how to register and use lifecycle callbacks for Supriya Server events. This allows executing custom code before or after server boot, quit, or on server panic. Callbacks can be used for setup and cleanup tasks. ```python >>> for event in supriya.ServerLifecycleEvent: ... print(repr(event)) ... ``` ```python >>> def print_event(event): ... print(repr(event)) ... >>> callback = server.register_lifecycle_callback( ``` -------------------------------- ### Run Async Realtime Server (Python) Source: https://github.com/supriya-project/supriya/blob/main/docs/source/examples/hello_world_contexts.rst This function shows how to perform audio using an asynchronous Supriya server. It utilizes `async` and `await` keywords for server operations like booting and sleeping. The core logic for playing and stopping synths remains the same as the threaded version. ```python import asyncio from supriya.contexts.realtime import AsyncServer async def run_async(): """Run with an async server. """ async with AsyncServer() as server: synths = play_synths(server) await asyncio.sleep(1) stop_synths(server, synths) await asyncio.sleep(1) ``` -------------------------------- ### Pytest Fixture for Server Lifecycle Management Source: https://github.com/supriya-project/supriya/blob/main/docs/source/developers/testing.rst Demonstrates a pytest fixture named 'server' that handles the setup (booting Scsynth) and teardown (quitting Scsynth) of a server instance. The fixture yields the server to tests, ensuring cleanup even if test assertions fail. ```python import pytest from supriya import Scsynth @pytest.fixture def server(): server = Scsynth() server.boot() yield server server.quit() ``` -------------------------------- ### Booting a Supriya Server Source: https://github.com/supriya-project/supriya/blob/main/docs/source/tutorials/nodes.rst Boots a Supriya server instance, which is necessary before adding any nodes. This is the initial step in managing audio processing nodes. ```python >>> server = supriya.Server().boot() ``` -------------------------------- ### Create Patterns for Sequencing with Supriya Source: https://context7.com/supriya-project/supriya/llms.txt Shows how to create sequences of musical events using Supriya's pattern objects. Includes examples of `SequencePattern` for ordered events, `ChoicePattern` for random selection, and `EventPattern` for complex parameter variations. These patterns can then be played on a Supriya context. ```python from supriya.patterns import ( SequencePattern, ChoicePattern, NoteEvent, EventPattern ) # Sequence of note events melody = SequencePattern([ NoteEvent(frequency=261.63, duration=0.5, amplitude=0.1), NoteEvent(frequency=293.66, duration=0.5, amplitude=0.1), NoteEvent(frequency=329.63, duration=1.0, amplitude=0.1), ]) # Random choice pattern random_notes = ChoicePattern([220, 440, 880, 1760]) # Event pattern with parameters pattern = EventPattern( frequency=SequencePattern([220, 440, 330, 550], loop=True), duration=SequencePattern([0.25, 0.5, 0.25, 1.0]), amplitude=ChoicePattern([0.1, 0.15, 0.2]) ) # Play pattern on context server = supriya.Server().boot() clock = supriya.Clock(beats_per_minute=120) player = pattern.play(context=server, clock=clock) import time time.sleep(20) player.stop() server.quit() ``` -------------------------------- ### Inspect Server Options (Python) Source: https://github.com/supriya-project/supriya/blob/main/docs/notebooks/supercollider-symposium-2025/presentation.ipynb This Python snippet accesses and displays the 'options' attribute of the 'server' object. The options represent various configuration parameters for the SuperCollider server, such as buffer sizes, channel counts, and sample rates. These options can be directly mapped to command-line flags used when starting the scsynth executable. ```python # inspect the server's options server.options ``` -------------------------------- ### Supriya Composite Event Output Example Source: https://github.com/supriya-project/supriya/blob/main/docs/notebooks/supercollider-symposium-2025/presentation.ipynb This is an example of the output generated by iterating through a Supriya pattern. It shows `CompositeEvent` objects, which group related allocation and synthesis events. It includes `BusAllocateEvent`, `GroupAllocateEvent`, `SynthAllocateEvent`, and `NoteEvent`, detailing the setup and triggering of audio processes. ```python CompositeEvent([ BusAllocateEvent(UUID('6a8ce73c-7ea2-4e1a-8988-d5a2aeec7fdf'), calculation_rate=CalculationRate.AUDIO, channel_count=2), GroupAllocateEvent(UUID('a6e589b8-6511-4f48-ab50-029270d98078')), SynthAllocateEvent(UUID('f953c5d4-f93b-40ba-a751-0198b487039d'), , add_action=AddAction.ADD_AFTER, amplitude=1.0, fade_time=0.25, in_=UUID('6a8ce73c-7ea2-4e1a-8988-d5a2aeec7fdf'), target_node=UUID('a6e589b8-6511-4f48-ab50-029270d98078')), ]) CompositeEvent([ SynthAllocateEvent(UUID('a5d7d4ec-ad55-4e2a-9c39-416adfa0bd46'), , add_action=AddAction.ADD_TO_TAIL, out=UUID('6a8ce73c-7ea2-4e1a-8988-d5a2aeec7fdf'), target_node=UUID('a6e589b8-6511-4f48-ab50-029270d98078')) ]) CompositeEvent([ GroupAllocateEvent(UUID('a7e2b0eb-def9-451a-8a84-d631f06031d1'), target_node=UUID('a6e589b8-6511-4f48-ab50-029270d98078')) ]) CompositeEvent([ CompositeEvent([ BusAllocateEvent(UUID('88127afd-185d-4a08-b7c9-0d3ef21bb2e4'), calculation_rate=CalculationRate.AUDIO, channel_count=2), GroupAllocateEvent(UUID('1d8ac459-f43b-45e1-a439-8a171d5a11e6'), target_node=UUID('a7e2b0eb-def9-451a-8a84-d631f06031d1')), SynthAllocateEvent(UUID('b8ca0f04-da9d-4326-a2b2-399b9fa1aafc'), , add_action=AddAction.ADD_AFTER, amplitude=1.0, fade_time=0.25, in_=UUID('88127afd-185d-4a08-b7c9-0d3ef21bb2e4'), out=UUID('6a8ce73c-7ea2-4e1a-8988-d5a2aeec7fdf'), target_node=UUID('1d8ac459-f43b-45e1-a439-8a171d5a11e6')) ]), CompositeEvent([ SynthAllocateEvent(UUID('1de28430-5f31-4f0d-a2c3-b4a428675ba5'), , add_action=AddAction.ADD_TO_TAIL, out=UUID('88127afd-185d-4a08-b7c9-0d3ef21bb2e4'), target_node=UUID('1d8ac459-f43b-45e1-a439-8a171d5a11e6')) ]), NoteEvent(UUID('b34d2330-ad47-42cc-8330-4f52f9d21683'), delta=0.0, duration=0.0972398581484957, frequency=(1333.32, 1466.64), out=UUID('88127afd-185d-4a08-b7c9-0d3ef21bb2e4'), pan=0.3668548341040625, synthdef=, target_node=UUID('1d8ac459-f43b-45e1-a439-8a171d5a11e6')), CompositeEvent([ BusAllocateEvent(UUID('c3f439c9-bc03-4949-b5bc-e8fce1466c57'), calculation_rate=CalculationRate.AUDIO, channel_count=2), GroupAllocateEvent(UUID('8c7198f1-cd12-4858-95b5-ad92ebfe19cb'), target_node=UUID('a7e2b0eb-def9-451a-8a84-d631f06031d1')) ]), CompositeEvent([ SynthAllocateEvent(UUID('42195eb7-3e66-4e20-9b96-a5b82c0817a7'), , add_action=AddAction.ADD_AFTER, amplitude=1.0, fade_time=0.25, in_=UUID('c3f439c9-bc03-4949-b5bc-e8fce1466c57'), out=UUID('6a8ce73c-7ea2-4e1a-8988-d5a2aeec7fdf'), target_node=UUID('8c7198f1-cd12-4858-95b5-ad92ebfe19cb')) ]), CompositeEvent([ SynthAllocateEvent(UUID('426ba4c8-741b-49fc-8c0f-d1a9bba613d9'), , add_action=AddAction.ADD_TO_TAIL, out=UUID('c3f439c9-bc03-4949-b5bc-e8fce1466c57'), target_node=UUID('8c7198f1-cd12-4858-95b5-ad92ebfe19cb')) ]), NoteEvent(UUID('d896c5fa-9f19-4d87-85e1-dcc9b73dbb9e'), delta=0.0, duration=0.05167052075989334, frequency=345, out=UUID('c3f439c9-bc03-4949-b5bc-e8fce1466c57'), pan=-0.46135090343187124, synthdef=, target_node=UUID('8c7198f1-cd12-4858-95b5-ad92ebfe19cb')), CompositeEvent([ BusAllocateEvent(UUID('598d37bd-dc58-4ada-b0f4-ec0611d28875'), calculation_rate=CalculationRate.AUDIO, channel_count=2), GroupAllocateEvent(UUID('736f7f35-7fd1-4da5-a8ec-90d01a699aef'), target_node=UUID('a7e2b0eb-def9-451a-8a84-d631f06031d1')) ]), CompositeEvent([ SynthAllocateEvent(UUID('79ff6a84-a67c-4400-b15a-c4e78466f19c'), , add_action=AddAction.ADD_AFTER, amplitude=1.0, fade_time=0.25, in_=UUID('598d37bd-dc58-4ada-b0f4-ec0611d28875'), out=UUID('6a8ce73c-7ea2-4e1a-8988-d5a2aeec7fdf'), target_node=UUID('736f7f35-7fd1-4da5-a8ec-90d01a699aef')) ]), CompositeEvent([ SynthAllocateEvent(UUID('6c3631cd-320a-41bb-8946-aa104ce15ebe'), , add_action=AddAction.ADD_TO_TAIL, out=UUID('598d37bd-dc58-4ada-b0f4-ec0611d28875'), target_node=UUID('736f7f35-7fd1-4da5-a8ec-90d01a699aef')) ]), NoteEvent(UUID('8eb44765-30b1-4243-bcdc-0c831b18544a'), delta=0.0, duration=0.11848690846712988, frequency=1760, out=UUID('598d37bd-dc58-4ada-b0f4-ec0611d28875'), pan=-0.6416072525567891, synthdef=, target_node=UUID('736f7f35-7fd1-4da5-a8ec-90d01a699aef')), CompositeEvent([ BusAllocateEvent(UUID('97310c5c-c55b-4ba6-ad89-fdf36dcf5636'), calculation_rate=CalculationRate.AUDIO, channel_count=2) ``` -------------------------------- ### Python: Boot and Quit Supriya Server Source: https://github.com/supriya-project/supriya/blob/main/docs/source/tutorials/servers.rst Demonstrates the basic lifecycle management of a Supriya Server instance. This includes instantiating a server, booting it with default or custom settings, and quitting it. It highlights default IP and port settings and how to override them. ```python >>> server = supriya.Server() >>> server.boot() >>> server.quit() ``` ```python >>> server.boot(ip_address="0.0.0.0", port=56666) ``` ```python >>> server.boot(executable="scsynth") ``` ```python >>> server.boot(executable="supernova") ``` -------------------------------- ### Get a Range of Buffer Values Source: https://github.com/supriya-project/supriya/blob/main/docs/notebooks/supercollider-symposium-2025/presentation.ipynb Retrieves a contiguous range of values from a buffer. It accepts an `index` to start from and a `count` to specify the number of values to retrieve, returning a tuple of float values. ```python # get a range of values buffer.get_range(index=0, count=16) Result: (0.266357421875, -0.016357421875, 0.25126951932907104, -0.01762695237994194, 0.2346191555261612, -0.01860351487994194, 0.21669922769069672, -0.01928711123764515, 0.19780273735523224, -0.01967773400247097, 0.17822265625, -0.019775390625, 0.15825195610523224, -0.01958007737994194, 0.13818359375, -0.01909179799258709) ``` -------------------------------- ### Pytest Test Using Server Fixture Source: https://github.com/supriya-project/supriya/blob/main/docs/source/developers/testing.rst An example of a pytest test function that utilizes the 'server' fixture. By including 'server' as an argument, the test automatically receives a booted server instance and benefits from its managed lifecycle (setup and teardown). ```python import pytest from supriya import Scsynth @pytest.fixture def server(): server = Scsynth() server.boot() yield server server.quit() def test_fixtures(server): nodes = server.query_node_tree() assert nodes == { "nodeID": 0, "children": [], "targetNodeID": None, "synthDefs": {}, "index": 0, "action": None, "frame_rate": 44100.0, "sample_rate": 44100.0, "block_size": 512, "num_buffers": 0, "num_nodes": 1, "plugins": [], "offset_seconds": 0.0, } ``` -------------------------------- ### Boot Async Server Source: https://context7.com/supriya-project/supriya/llms.txt Initializes an asyncio-enabled real-time synthesis server. ```APIDOC ## Boot Async Server ### Description Initializes an asyncio-enabled real-time synthesis server. ### Method POST (Implicit) ### Endpoint / ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **options** (supriya.Options) - Optional - Custom server configuration. ### Request Example ```python import asyncio import supriya async def main(): # Boot async server server = await supriya.AsyncServer().boot() # Use async context manager for automatic cleanup async with supriya.AsyncServer().boot() as server: # Query status asynchronously status = await server.query_status() print(f"Server online: {status.node_count} nodes") # All operations are awaitable await asyncio.sleep(5) # Server automatically quits when exiting context asyncio.run(main()) ``` ### Response #### Success Response (200) - **server** (supriya.AsyncServer) - The initialized async server instance. #### Response Example ```json { "message": "Async server booted successfully" } ``` ``` -------------------------------- ### Get Buffer Data Source: https://github.com/supriya-project/supriya/blob/main/docs/source/tutorials/buffers.rst Retrieves data from a buffer. The `.get()` method can be used to fetch specific ranges of samples. It requires start index, channel index, and frame count as parameters. No external dependencies are needed beyond a valid buffer object. ```Python >>> buffer_.get(0, 2, 4) ``` -------------------------------- ### Run Threaded Realtime Server (Python) Source: https://github.com/supriya-project/supriya/blob/main/docs/source/examples/hello_world_contexts.rst This function demonstrates performing audio with a threaded Supriya server. It sets up a Server context, plays synths using the context-agnostic `play_synths` function, and then stops them using `stop_synths`. It includes a sleep to allow the audio to play. ```python import time from supriya.contexts.realtime import Server def run_threaded(): """Run with a threaded server. """ with Server() as server: synths = play_synths(server) time.sleep(1) stop_synths(server, synths) time.sleep(1) ``` -------------------------------- ### Start Threaded Clock Source: https://github.com/supriya-project/supriya/blob/main/docs/source/advanced/clocks.rst Starts a threaded clock. This initiates the clock's operation, allowing it to process scheduled callbacks. ```python >>> clock.start() ``` -------------------------------- ### Boot SuperCollider Server Source: https://context7.com/supriya-project/supriya/llms.txt Initializes and configures the real-time synthesis server with default or custom options. ```APIDOC ## Boot SuperCollider Server ### Description Initializes and configures the real-time synthesis server with default or custom options. ### Method POST (Implicit) ### Endpoint / ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **options** (supriya.Options) - Optional - Custom server configuration. ### Request Example ```python import supriya # Boot synchronous server with default options server = supriya.Server().boot() # Boot with custom options options = supriya.Options( port=57110, input_bus_channel_count=2, output_bus_channel_count=2, sample_rate=48000, block_size=64, memory_size=8192, maximum_node_count=1024, ) server = supriya.Server().boot(options=options) ``` ### Response #### Success Response (200) - **server** (supriya.Server) - The initialized server instance. #### Response Example ```json { "message": "Server booted successfully" } ``` ### Additional Operations #### Query Server Status ```python status = server.query_status() print(f"CPU: {status.average_cpu_usage}%") print(f"Synth count: {status.synth_count}") print(f"Sample rate: {status.sample_rate} Hz") ``` #### Query Node Tree ```python tree = server.query_tree() print(tree) ``` #### Shutdown Server ```python server.quit() ``` ``` -------------------------------- ### Example Coverage Report Output Source: https://github.com/supriya-project/supriya/blob/main/docs/source/developers/testing.rst This is an example of a code coverage report generated by pytest-cov. It displays statistics such as statements, missing lines, branches, and overall coverage percentage for various modules within the Supriya project. ```text Name Stmts Miss Branch BrPart Cover --------------------------------------------------------------------- supriya/__init__.py 21 4 2 1 78% supriya/_version.py 2 0 0 0 100% supriya/clocks/__init__.py 5 0 0 0 100% supriya/clocks/asynchronous.py 115 6 40 5 93% supriya/clocks/core.py 431 33 118 18 90% supriya/clocks/offline.py 97 12 14 4 86% supriya/clocks/threaded.py 72 3 22 4 93% supriya/contexts/__init__.py 5 0 0 0 100% supriya/contexts/allocators.py 154 10 42 8 91% supriya/contexts/core.py 532 32 186 22 91% supriya/contexts/entities.py 285 41 72 26 78% supriya/contexts/nonrealtime.py 113 8 36 5 91% supriya/contexts/realtime.py 791 28 262 25 95% supriya/contexts/requests.py 718 29 142 14 95% supriya/contexts/responses.py 356 12 64 5 96% supriya/contexts/scopes.py 94 16 30 15 75% supriya/conversions.py 20 5 0 0 75% supriya/enums.py 381 8 24 3 97% supriya/exceptions.py 36 0 0 0 100% supriya/ext/__init__.py 19 6 10 3 62% supriya/ext/book.py 99 2 2 0 98% supriya/ext/ipython.py 23 16 4 0 26% supriya/ext/mypy.py 63 49 18 0 17% supriya/io.py 78 25 8 2 64% supriya/osc/__init__.py 5 0 0 0 100% supriya/osc/asynchronous.py 89 8 30 8 85% supriya/osc/messages.py 279 35 116 16 85% supriya/osc/protocols.py 209 15 68 13 90% supriya/osc/threaded.py 115 10 36 7 89% supriya/osc/utils.py 26 5 12 1 84% supriya/patterns/__init__.py 7 0 0 0 100% supriya/patterns/eventpatterns.py 131 14 42 3 89% supriya/patterns/events.py 168 15 52 12 85% supriya/patterns/noise.py 114 7 38 8 90% supriya/patterns/patterns.py 252 6 54 2 97% ``` -------------------------------- ### Boot Supriya Server and Add SynthDef Source: https://github.com/supriya-project/supriya/blob/main/docs/notebooks/scopes/scopes.ipynb Boots a Supriya server and adds the previously defined SynthDef to it. It then adds an instance of the synthdef to the server for playback and synchronizes the server state. ```python from supriya import Server, SynthDefBuilder server = Server().boot() with server.at(): with server.add_synthdefs(synthdef): synth = server.add_synth(synthdef=synthdef) server.sync() ``` -------------------------------- ### Python: Configure Supriya Server Options Source: https://github.com/supriya-project/supriya/blob/main/docs/source/tutorials/servers.rst Shows how to configure scsynth server options using Supriya's Options class and pass them during server boot. This allows for detailed control over server parameters like input and output bus channel counts. ```python >>> supriya.Options() >>> server.boot(input_bus_channel_count=2, output_bus_channel_count=2) ``` ```python >>> for x in supriya.Options(): ... x ... ``` -------------------------------- ### Boot Synchronous SuperCollider Server with Supriya Source: https://context7.com/supriya-project/supriya/llms.txt Initializes and configures a synchronous SuperCollider real-time synthesis server using the Supriya library. It demonstrates booting with default options, custom options (port, channels, sample rate, block size, memory, node count), querying server status (CPU usage, synth count, sample rate), inspecting the node tree, and shutting down the server. ```python import supriya # Boot synchronous server with default options server = supriya.Server().boot() # Boot with custom options options = supriya.Options( port=57110, input_bus_channel_count=2, output_bus_channel_count=2, sample_rate=48000, block_size=64, memory_size=8192, maximum_node_count=1024, ) server = supriya.Server().boot(options=options) # Query server status status = server.query_status() print(f"CPU: {status.average_cpu_usage}%") print(f"Synth count: {status.synth_count}") print(f"Sample rate: {status.sample_rate} Hz") # Query node tree tree = server.query_tree() print(tree) # Output: # NODE TREE 0 group # 1 group # Shutdown server server.quit() ``` -------------------------------- ### Boot SuperCollider Server in Python Source: https://github.com/supriya-project/supriya/blob/main/README.md This Python code imports the Supriya library and boots the SuperCollider server instance. The `Server().boot()` method initializes the connection to the SuperCollider synthesis engine. ```python import supriya server = supriya.Server().boot() ``` -------------------------------- ### Python Server Bootstrapping and Callback Registration Source: https://github.com/supriya-project/supriya/blob/main/docs/notebooks/supercollider-symposium-2025/presentation.ipynb This snippet demonstrates how to initialize a Supriya server, register a callback for the 'booted' event, and add SynthDefs. The on_boot function is executed once the server is ready. ```python def on_boot(event): server.add_synthdefs(supriya.default, delay, reverb) server.sync() server = Server() server.register_lifecycle_callback("booted", on_boot) server.boot() clock = Clock() ``` -------------------------------- ### Get Group Children (Python) Source: https://github.com/supriya-project/supriya/blob/main/docs/source/tutorials/nodes.rst Iterates through and prints all direct child nodes of a given group. This is essential for managing and inspecting the structure of the node tree. ```python for node in group.children: node ``` -------------------------------- ### Inspect Buffer ID with Supriya Source: https://github.com/supriya-project/supriya/blob/main/docs/source/tutorials/buffers.rst Provides an example of how to retrieve the unique ID of a buffer object. This is useful for referencing the buffer in other operations or for debugging purposes. ```python >>> buffer_ = server.add_buffer(channel_count=2, frame_count=512) >>> buffer_.id_ ``` -------------------------------- ### Get Synth Parentage (Python) Source: https://github.com/supriya-project/supriya/blob/main/docs/source/tutorials/nodes.rst Iterates through and prints the parentage of a synth, showing its direct parent up to the root node. Useful for debugging and understanding node hierarchy. ```python for node in synth_a.parentage: node ``` -------------------------------- ### Create and Boot Server for Bus Operations (Python) Source: https://github.com/supriya-project/supriya/blob/main/docs/source/tutorials/buses.rst This snippet demonstrates how to create and boot a Supriya server instance, which is a prerequisite for adding buses to it. Buses can only be added to running servers. ```python server = supriya.Server().boot() ``` -------------------------------- ### Boot Asynchronous SuperCollider Server with Supriya Source: https://context7.com/supriya-project/supriya/llms.txt Initializes an asyncio-enabled asynchronous SuperCollider real-time synthesis server using Supriya. It shows how to boot the server, use an async context manager for automatic cleanup, query server status asynchronously, and highlights that all operations are awaitable. The server is automatically quit upon exiting the context. ```python import asyncio import supriya async def main(): # Boot async server server = await supriya.AsyncServer().boot() # Use async context manager for automatic cleanup async with supriya.AsyncServer().boot() as server: # Query status asynchronously status = await server.query_status() print(f"Server online: {status.node_count} nodes") # All operations are awaitable await asyncio.sleep(5) # Server automatically quits when exiting context asyncio.run(main()) ``` -------------------------------- ### Freeing Groups Source: https://github.com/supriya-project/supriya/blob/main/docs/notebooks/supercollider-symposium-2025/presentation.ipynb Removes a specified group (and its children) from the server's node tree, freeing up resources. The example shows freeing the original parent group. ```Python # free the original parent group group.free() print(server.query_tree()) ```