moontide

v2.4.3
io.github.konni-arcadia/moontide Checked 3 days ago Published 27 days ago

Early: Claude steers live music by writing Strudel code played in a browser page

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

get_code

Reads the Strudel code currently playing in the Moontide page, i.e. the last code the page confirmed, including edits the user evaluated by hand; returns 'Nothing is playing yet.' before anything played, with a template of a song structure to start from. Before Moontide is started it says so and starts nothing; after the start its reply also names the page address, the port and the tab title. Call it before every change.

get_strudel_reference

Returns the Strudel reference for @strudel/repl 1.3.0, the version the Moontide page loads: facts about what exists and how to write it, not what to choose. Topics: tidal-differences, mini-notation, functions, effects, sounds, theory, transitions, structure, midi, settings, motif. Call it without a topic for the index. Strudel is JavaScript, not TidalCycles: read tidal-differences before writing Strudel from Tidal habits.

ParameterTypeDescription
topicstringOne topic to return; omit it to get the index of topics

set_code

Replaces the music in the Moontide page with new Strudel code; the new pattern takes over within a fraction of a second, mid-cycle, without stopping the music. To change part of an existing piece, edit_code sends only the change; set_code is for a new piece or a rewrite of most of its lines. With at: 'bar' or at: 'phrase' the code is checked at once and takes over on the next bar line or the next phrase line instead (a bar is one cycle of 4 beats; a phrase is 4 cycles, or phraseCycles, counted from Play); the reply gives the cycle and about how many seconds, a newer change replaces a waiting o…

ParameterTypeDescription
code *stringComplete Strudel code to play
answeringstringThe id of the page request this change answers, from its request line; the page shows that request as applied only when the change names it here
atstringWhen the change takes over: 'now' (the default) within a fraction of a second, 'bar' on the next bar line, 'phrase' on the next phrase line (4 cycles, counted from Play). The code is checked at once;…
glideBarsintegerWhole bars, 1 to 64, to move the tempo smoothly from the tempo that plays to the one this code sets with setcps or setcpm; with at, it starts at the line. Refused when nothing plays, no tempo is set o…
labelstringA few words saying what this change is, for example "added a bass"; shown by list_history
phraseCyclesintegerHow many cycles one phrase lasts, for at: 'phrase' (2 to 64, default 4)

edit_code

Changes part of the code that will play by exact text replacement, sending only the change. Use it to change an existing piece; use set_code for a new piece or a rewrite of most of its lines. Each edit has old_string, new_string and optional replace_all, as in your own Edit tool. Every old_string must match exactly once (or set replace_all), and every edit is matched against the code as it is before this call, so edits must not overlap and one edit cannot match text another edit writes. An edit that matches nowhere, matches more than once, overlaps another edit or changes nothing refuses the w…

ParameterTypeDescription
edits *arrayThe replacements, 1 to 50, applied all together or not at all
answeringstringThe id of the page request this change answers, from its request line; the page shows that request as applied only when the change names it here
atstringWhen the change takes over: 'now' (the default) within a fraction of a second, 'bar' on the next bar line, 'phrase' on the next phrase line (4 cycles, counted from Play). The code is checked at once;…
baseintegerThe version number get_code shows (#N); the edit is refused when another version plays now
glideBarsintegerWhole bars, 1 to 64, to move the tempo smoothly from the tempo that plays to the one this code sets with setcps or setcpm; with at, it starts at the line. Refused when nothing plays, no tempo is set o…
labelstringA few words saying what this change is, for example "added a bass"; shown by list_history
phraseCyclesintegerHow many cycles one phrase lasts, for at: 'phrase' (2 to 64, default 4)

list_history

Lists the versions of the music that played, newest first, one per row: "#id — time (UTC) — origin — \"label\" — first line of code". Ids never change. Rows without "#" mark where a Claude session started. The newest version row is usually what plays now; "the previous version" is the next version row down, "3 changes ago" is three version rows below the newest. Pass limit to see more than 20. Pass filter to find a version by a word from its label, code or favorite name; pass favorites: true to list favorites.

ParameterTypeDescription
favoritesbooleantrue to list only favorites
filterstringOnly versions whose label, code or favorite name contains this text (case-insensitive)
limitintegerHow many versions to list, newest first (default 20)

favorite_version

Keeps a version as a named favorite, by its id from list_history (the version playing now is the one shown as v{id} in the page top bar). Favorites are never dropped from the history. Favoriting the same id again renames it. List favorites with list_history and favorites: true.

ParameterTypeDescription
id *integerVersion id from list_history
name *stringName to keep it under, in the user's words

restore_version

Plays a past version again, by its id from list_history, in one call: it takes over within a fraction of a second without stopping the music, with the same checks as set_code. The restore is added to the history as a new version ("restored from #id"); nothing is rewritten. Returns the code as confirmed by the page. A restore always takes over at once and replaces a change that waits for a bar or phrase line. The old version replaces the music at once; when the user asked for gradual changes this session, bring it in with set_code and a transition instead. Like set_code, it starts Moontide firs…

ParameterTypeDescription
id *integerVersion id from list_history, for example 41 for #41
answeringstringThe id of the page request this change answers, from its request line; the page shows that request as applied only when the change names it here

answer_request

Closes a request typed in the Moontide page without changing the music. Use outcome answered when the request was answered in words, declined when it will not or cannot be done. Give one sentence of at most 200 characters; the page shows it under the request. A change that answers a request names it with answering on set_code, edit_code or restore_version instead. An id that is not an open request is refused and nothing changes.

ParameterTypeDescription
id *stringThe id of the page request to close, from its request line
outcome *stringanswered when the request was answered in words, declined when it will not or cannot be done
text *stringOne sentence for the user, at most 200 characters; the page shows it under the request

stop

Stops all sound in the Moontide page right away, even when the current code is broken. The code stays in the editor; get_code still returns it, and the next set_code starts playing again. Before Moontide is started it says so and starts nothing.

get_midi_instruments

When the user has described their instruments, call this before writing MIDI code. Lists the MIDI instruments the user described in instruments.json, as facts: for each one its id, model, exact port name, whether it is connected right now, its channels and their roles, how many sounds it has, its bank select, its reset, whether it follows MIDI clock and its controls. Pass instrument (an id from that list) to get that instrument's full sound list, with the program number sent for each sound and its bank when it has one. A sound is chosen in the code with the sound option of .midi(). An instrume…

ParameterTypeDescription
instrumentstringAn instrument id from instruments.json, to list its sounds

search_midi_sounds

Searches the sound catalog of one instrument: a list of the model's sounds kept in the user's data folder, built from a patch-name file or a sound list the user owns. It finds sounds by words in the name or the category, in any order, with case and spaces ignored. It returns at most 25 matches: the exact name first, then names that start with the words, then names that contain them, then matches in the category only. Each match gives the name as the sound option of .midi() takes it, the program as sent (0-127), the bank when there is one, the category and, for an instrument whose model declare…

ParameterTypeDescription
instrument *stringAn instrument id from instruments.json whose model has a sound catalog
categorystringOnly sounds of this category; case and spaces do not matter
querystringWords to find in the sound name or its category, in any order; case and spaces do not matter

save_midi_model

Saves an instrument model that you drafted from a page of the instrument's manual the user pasted, into the user's Moontide data folder (models/<id>.json), never into Moontide itself. First call it with confirmed: false: it checks the model and returns a summary (channels, sounds with their program numbers as sent and as numbered in a manual from 1, controls, reset bytes, notes) and saves nothing. Show that summary to the user, and call it again with the same model and confirmed: true only after they say yes. It refuses an id of a model Moontide ships, and an existing model unless overwrite is…

ParameterTypeDescription
confirmed *booleanfalse to check and summarize without saving; true only after the user said yes to the summary
model *objectThe drafted model, as a JSON object
overwritebooleantrue to replace an existing user model with the same id

save_midi_catalog

Saves a sound catalog that you drafted from a sound list the user gave you (for example the maker's PDF list), into the user's Moontide data folder (catalogs/<model id>.json), never into Moontide itself. The catalog extends the model named by model. Send the sounds grouped as the list prints them, at most 500 per call: the first call starts the draft (source, programNumbering, and overwrite when it replaces a catalog), later calls add parts with append: true, with more: true while parts remain. The last part checks the whole draft and returns a summary that shows three sounds with their progra…

ParameterTypeDescription
model *stringThe id of the model the catalog extends: a model Moontide ships or one saved with save_midi_model
appendbooleantrue to add this part to the draft of the model; absent or false starts a new draft
banksarrayThe sounds of this part, grouped by bank and category; at most 500 sounds in the call
confirmedbooleantrue only after the user said yes to the summary; send it with model and nothing else
morebooleantrue while more parts remain; absent or false on the last part
overwritebooleantrue to replace an existing catalog of the model; read when a draft starts
programNumberingstringHow the list numbers programs: from-1 when the first program is printed as 1; required when a draft starts
sourcestringThe document title and version the list comes from; required when a draft starts

set_page_requests

Switches how requests the user types in the Moontide page reach you. State on returns the command to run now with your Monitor tool, so each request arrives as soon as it is sent. State off says how to stop that monitor, after which requests wait on the Moontide server and arrive in the reply of your next other Moontide tool. Call it when the user asks, in any words, to turn page requests on or off, to take requests from the Moontide page right away, or to stop. The page-requests-on and page-requests-off prompts do the same where the client offers MCP prompts.

ParameterTypeDescription
state *stringon to receive each page request right away, off to let them wait for the reply of your next other Moontide tool

start

Starts Moontide: its web server on this computer and its page, which opens in a new browser tab; one click in that tab turns the sound on. Call it when the user asks, in any words, to start or open Moontide, or asks which tab or port is yours. Calling it again is safe: it gives the page address, the port and the tab title, and opens a new tab only when no page is connected. set_code starts Moontide by itself, and so does restore_version for a version that exists, so there is no need to call it before them. edit_code changes music that already plays and starts nothing. The start prompt does the…