{"id":16284948,"url":"https://github.com/emlyn/sonic-pi-tool","last_synced_at":"2025-03-20T02:31:22.302Z","repository":{"id":56308537,"uuid":"138656271","full_name":"emlyn/sonic-pi-tool","owner":"emlyn","description":"🎻 Controlling Sonic Pi from the command line, in Python.","archived":false,"fork":false,"pushed_at":"2021-03-07T22:20:25.000Z","size":155,"stargazers_count":63,"open_issues_count":4,"forks_count":8,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-15T03:14:43.685Z","etag":null,"topics":["cli","command-line","python","sonic-pi","sonicpi"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/emlyn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-25T22:24:56.000Z","updated_at":"2024-12-31T17:46:55.000Z","dependencies_parsed_at":"2022-08-15T16:20:57.435Z","dependency_job_id":null,"html_url":"https://github.com/emlyn/sonic-pi-tool","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emlyn%2Fsonic-pi-tool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emlyn%2Fsonic-pi-tool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emlyn%2Fsonic-pi-tool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emlyn%2Fsonic-pi-tool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emlyn","download_url":"https://codeload.github.com/emlyn/sonic-pi-tool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244538588,"owners_count":20468745,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","command-line","python","sonic-pi","sonicpi"],"created_at":"2024-10-10T19:21:40.571Z","updated_at":"2025-03-20T02:31:22.034Z","avatar_url":"https://github.com/emlyn.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Sonic Pi Tool (Python)\n=============\n\n`sonic-pi-tool.py` is a rewrite of the Rust [sonic-pi-tool](https://github.com/lpil/sonic-pi-tool) in Python.\nIt is a handy command line utility for playing with the Sonic Pi\nserver. It can be used instead of the Sonic Pi GUI for all your music making\nneeds :)\n\nIt's ideal for use with [sonicpi.vim](https://github.com/dermusikman/sonicpi.vim)\n\n\n## Installation\n\nSonic Pi Tool doesn't currently have a proper installer.\nHowever it is just a simple Python script with a couple of dependencies,\nso it's not hard to install manually:\n\n```sh\n# Install dependencies:\npip install click oscpy psutil\n\n# Download script:\ncurl -O https://raw.githubusercontent.com/emlyn/sonic-pi-tool/master/sonic-pi-tool.py\n\n# Make it executable:\nchmod +x sonic-pi-tool.py\n\n# Copy it somewhere on the PATH:\nsudo cp sonic-pi-tool.py /usr/local/bin/\n```\n\n`sonic-pi-tool.py` should be compatible with Python 3.6+.\nThere is also a `python2` branch that maintains compatibility with Python 2.7,\nbut might not have all the latest features of the master branch.\n\n\n## Usage\n\n### Options\n\nOptions common to most or all commands:\n\n- `--host`: The host name or IP address to use when communicating with the Sonic Pi server.\n- `--cmd-port`: The port number on which the Sonic Pi server listens for incoming commands.\nIf this is negative, try to find the port number in the Sonic Pi server-log file,\nand fall back to the absolute value specified if it can't be found in the log file.\n- `--osc-port`: The port number on which the Sonic Pi server listens for incoming OSC cues.\n- `--preamble` / `--no-preamble`: Some versions of Sonic Pi, when started without the GUI,\nfail to initialise the OSC server. This adds a bit of code at the start of any evaluated code\nto initialise the OSC server if it has not already been initialised.\n- `--verbose` / `--no-verbose`: Print out more information to help with debugging.\n- `--help` (or `-h`): Display help information.\n\n### Commands\n\nThe available commands are:\n\n- [check](#check): Check if Sonic Pi is running.\n- [start-server](#start-server): Start Sonic Pi server process.\n- [logs](#logs): Follow logs from Sonic Pi server process.\n- [eval](#eval): Evaluate Sonic Pi code from command line.\n- [eval-file](#eval-file): Evaluate Sonic Pi code from a file.\n- [eval-stdin](#eval-stdin): Evaluate Sonic Pi code from stdin.\n- [run-file](#run-file): Run a file in Sonic Pi without sending contents.\n- [osc](#osc): Send an OSC message to Sonic Pi (or other OSC server).\n- [record](#record): Record Sonic Pi sound to a wav file.\n- [stop](#stop): Stop any running Sonic Pi code.\n- [shutdown](#shutdown): Shut down any running Sonic Pi processes.\n\n#### `check`\n\nUsed to check if the Sonic Pi server is running. If the server isn't running\nmany of the tool's commands (such as `eval`) will not work.\n\nThis command returns an exit code of zero if the server is running,\none if it is not running, or two if it cannot determine whether it is running.\n\n```sh\nsonic-pi-tool.py check\n# Sonic Pi is running, and listening on port 4557 for commands and 4560 for OSC\n```\n\n\n### `start-server`\n\nAttempts start the Sonic Pi server, if the executable can be found.\nSearches a few standard locations, first in the current directory,\nthen the users home directory\nand finally some standard install locations.\n\nIf it is unable to find your installation, you can pass the location in the `--path` option.\nPlease also consider raising an issue including the path to your install,\nand I will add it to the list of search paths.\n\nNot currently supported on Windows.\n\n```sh\nsonic-pi-tool.py start-server\n# Sonic Pi server booting...\n# Using protocol: udp\n# Detecting port numbers...\n# ...\n```\n\n\n### `logs`\n\nPrints out log messages emitted by the Sonic Pi server.\n\nThis command won't succeed if the Sonic Pi GUI is running as that will already\nbe consuming the logs itself.\n\n```sh\nsonic-pi-tool.py logs\n#\n# [Run 2, Time 32.7]\n#  └ synth :beep, {note: 65.0, release: 0.1, amp: 0.9741}\n#\n# [Run 2, Time 32.8]\n#  └ synth :beep, {note: 39.0, release: 0.1, amp: 0.9727}\n```\n\n\n### `eval`\n\nTake a string of Sonic Pi code and send it to the Sonic Pi server to be\nplayed.\n\n```sh\nsonic-pi-tool.py eval \"use_real_time; play :C4\"\n# *ding*\n```\n\n\n### `eval-file`\n\nRead Sonic Pi code from a file and send it to the Sonic Pi server to be\nplayed. If the file is too big, consider using `run-file` instead.\n\n```sh\nsonic-pi-tool.py eval-file path/to/code.rb\n# *music*\n```\n\n\n### `eval-stdin`\n\nRead Sonic Pi code from standard in and send it to the Sonic Pi server to be\nplayed.\n\n```sh\necho \"play :C4\" | sonic-pi-tool.py eval-stdin\n# *ding*\n```\n\n\n### `run-file`\n\nSend a command to the Sonic Pi server to load and play the specified file.\nThis avoids problems with files being too long since the entire content no longer\nneeds to fit in a single OSC message.\n\n```sh\nsonic-pi-tool.py run-file path/to/code.rb\n# *music*\n```\n\n\n### `osc`\n\nSend an OSC cue to Sonic Pi.\nAllows a running Sonic Pi script to receive data from or synchronise to an external system.\n\n``` sh\nsonic-pi-tool.py osc /trigger/foo 123\n# Triggers `sync \"/osc*/trigger/foo\"` command running in Sonic Pi\n```\n\n\n### `record`\n\nRecord the audio output of a Sonic Pi session to a local file.\nStop and save the recording when the Enter key is pressed.\n\n```sh\nsonic-pi-tool.py record /tmp/output.wav\n# Recording started, saving to /tmp/output.wav.\n# Press Enter to stop the recording...\n```\n\n\n### `stop`\n\nStop all jobs running on the Sonic Pi server, stopping the music.\n\n```sh\nsonic-pi-tool.py stop\n# *silence*\n```\n\n\n### `shutdown`\n\nShut down any Sonic Pi processes (started either with the GUI or the start-server command).\nCan be used to shut down any stray processes left if Sonic Pi fails to shut down correctly,\nas these can sometimes prevent Sonic Pi from starting up again.\n\n``` sh\nsonic-pi-tool.py shutdown\n# Sonic Pi has been shut down\n```\n\n\n## MPL 2.0 Licence\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femlyn%2Fsonic-pi-tool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femlyn%2Fsonic-pi-tool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femlyn%2Fsonic-pi-tool/lists"}