FreestyleDevelopers Open the app

MCP live editing

The MCP tools an AI agent (or an MCP-driven editor) uses for live, manual editing: monitoring, waveforms, time-range and sample edits, region effects, tempo and meter maps, automation and the interactive session channel. Media never passes through the connector: live audio flows Mozart → client over WebRTC. Direct edits use the interactive budget, not the Mozart AI quota.

Building an app or a DAW user interface? Use the Studio API v1 and its DAW UI guide: the same engine contracts as REST resources, with ETags, idempotency keys and cursor pagination. Every tool on this page that has a REST equivalent is cross-linked in the MCP tools reference. This page documents the MCP form for agents.

Live audio monitoring (scope audio:listen)

  1. start_audio_monitor opens the project's live Mozart session and returns it plus short-lived TURN credentials (about 10 minutes).
  2. Create a receive-only audio RTCPeerConnection with those credentials, then send its SDP offer with rick_webrtc_offer and apply Mozart's answer.
  3. stop_audio_monitor (same client_id) closes the peer when you are done; set_audio_monitor_quality changes its bitrate live. Projects with no recordings yet, or nothing at all, can be monitored too.
  4. Refresh relay credentials with get_turn_credentials (pass the session's dawBaseUrl as mozart_origin) before expiresAt.

The native REST monitoring routes stay Firebase-only by design; an OAuth token there gets 401. device_id is accepted and ignored: monitoring always follows the project's own session.

Waveforms

get_clip_waveform (daw:read, viewers allowed) returns per-channel min/max/rms buckets of one clip's source audio over a frame range: raw signed PCM in [-1, 1], before clip gain and effects. It includes sample_rate, channel_count, frame_count, the clip's start_ms/audio_offset_frames/duration_frames/gain and a revision that changes when the source audio changes. Bucket b covers frames [start + floor(b·span/n), start + floor((b+1)·span/n)); a range shorter than buckets returns one frame per bucket (sample-level zoom). Frames index the whole source file, so an editor reads each source once and draws every zoom level and every clip cut from it out of that copy; the recipe is on Waveforms.

Time-range editing

  • edit_time_range (daw:write): split, delete (ripple: true closes the gap like Audacity Delete, false leaves silence like Split Delete) and trim_to_selection across lane_ids. The edit is applied as one atomic engine batch: if any clip changed since it was read, nothing is applied (409 conflict). It returns clips_after (with new clip ids) and undo.inverse_ops. idempotency_key derives the new clip ids so a retry is safe; dry_run returns the plan only.
  • Boundaries: either start_ms/end_ms (numbers; fractional milliseconds allowed) or start_frame/end_frame (integers on the project timeline at sample_rate; default is the live session's engine rate, and the call is rejected if that is unknown). Whole-millisecond input behaves exactly as before.
  • Cursor split: start == end is allowed only for split. It cuts once at that position on every listed lane; clips that do not contain the position are untouched. It is atomic, idempotent and returns inverse ops like any other edit. delete and trim_to_selection reject an empty range.
  • Seamless cuts: every cut inside a clip snaps to the 1 ms timeline grid (rounded half up, like the engine), because a clip's timeline start_ms is stored in whole milliseconds. Both pieces are derived from that one snapped cut: the left piece ends exactly where the right piece starts, and the right piece's audio_offset_sec is the clip's offset plus (cut − clip start), so its audio continues exactly where the left piece stops. There is no gap, no overlap and no content shift. Source windows are stored to 1 µs; a clip's own edges keep their exact stored values. The engine and the database receive the same values, so a reload matches the live session.
  • Cut report: for fractional-ms or frame input the result has cuts, one entry per boundary with requested_ms (and requested_frame), actual_ms, actual_frame at the session rate, and the difference (difference_ms, difference_frames, at most 0.5 ms). Two requested cuts inside the same millisecond become one cut. A cut that would leave a piece shorter than one frame is no cut for that clip, and a delete or trim_to_selection selection that collapses below 1 ms is rejected. Ripple delete moves every later clip by one whole-millisecond shift, so the spacing between clips never drifts.
  • Lanes: lanes that take no part are listed in skipped_lanes as {lane_id, reason} (unknown_lane, not_audio_lane for pattern or instrument lanes, clips_not_loaded, no_clips). If no listed lane is a real audio lane, the call fails with invalid_argument. ripple and dry_run must be JSON booleans.
  • apply_clip_batch (daw:write): up to 256 update/insert/remove/restore clip operations in one database transaction, each optionally guarded by expected timing. Pass undo.inverse_ops here for a one-step undo. A retry of an already committed batch returns replay: true.
  • split_pattern_placement (daw:write, Pro): the Studio's atomic pattern-placement split at an absolute cut_ms. It preserves phase inside repeated patterns and returns {left, right, before}; call it with undo: true, the same child_id and before to reverse it.

Region effects

Apply one of Freestyle's built-in effects to a selected region of a clip, like selecting audio in Audacity and choosing an effect. Preview it first; applying replaces only the selection, and one call undoes it. The processing is Freestyle's own deterministic DSP, not a copy of Audacity's.

  • list_region_effects (daw:read) returns the catalog. Each effect has a typed parameter schema (numbers with min, max, default and unit; booleans; enums): amplify, normalize, fade_in, fade_out, reverse, silence, invert, pitch_shift (keeps length), compressor, limiter, high_pass, low_pass, eq_band, echo and reverb. It also lists processors that cannot run on a region yet, with the reason: voice models, super-resolution and enhance only run on whole takes, and lane plugin chains only run live.
  • Selection: a durable clip_id plus either start_ms/end_ms or start_frame/end_frame. The precision rules are the same as edit_time_range: cuts snap to the 1 ms grid, region.cuts reports requested vs actual, and a range that runs past the clip is clamped to it. A region can be at most 120 s long (region_too_long); apply longer effects in parts.
  • preview_region_effect (daw:read, viewers allowed) renders the effect without changing the project. It returns a one-hour playbackUrl (MP3 at the real level, not normalized) and measured levels for the original and processed selection: peak, RMS, true peak, LUFS and would_clip. context_ms (up to 2 s) adds untouched clip audio before and after so you can hear the change in context. A preview covers at most the first 30 s of the selection.
  • apply_effect_to_region (daw:write) stores the processed audio as a new asset (48 kHz WAV, mono stays mono). The original file is never changed. One atomic clip batch then splits the clip at the boundaries and drops a new clip on the processed asset into the gap. The pieces outside the selection still play the original file at their original offsets, so audio outside the selection is bit-identical. If the clip changed since it was read, nothing is applied (409 conflict).
  • Seams: by default the edges are hard, as in Audacity. crossfade_ms (0–100) fades from the original into the processed audio at the start of the selection and back out at the end. The fades sit inside the selection, so nothing outside it changes. Compressor, limiter and EQ get up to 1 s of the clip's own audio before the selection as warm-up. Echo and reverb tails stop at the end of the selection.
  • Result: region (the actual cut), asset (the new clip_id, audio_file_id and sha256), clips_after, ops, measured, engine_reload_required, and undo.inverse_ops. Pass undo.inverse_ops to apply_clip_batch to undo in one step: the processed clip is removed and the original clip gets back its exact timing.
  • Jobs: an apply waits up to wait_sec (default 20, max 50). If it is still running, poll get_region_effect_job with the returned job_id. idempotency_key makes a retry safe: an apply that already committed comes back as replay: true and is never applied twice. A result that peaks at 0 dBFS or above is refused (would_clip) unless you pass allow_clipping: true. dry_run: true returns the plan without rendering. Keys are per user. After you undo an apply, apply again with a new idempotency_key: the old key answers idempotency_key_used. Clips with whole-take processing turned on (enhance, super-resolution or a voice model) are refused (clip_has_phase1_effects). The clip's stored audio must be WAV, or a compressed file that can be decoded from its start (otherwise source_format_unsupported; bounce the clip first). Only the selected part of a WAV is read; the source is never copied whole.
  • Budgets: preview and apply decode and render audio, so they use the Mozart AI budget. list_region_effects and get_region_effect_job use the interactive budget.

Sample editing (pencil)

  • edit_clip_samples (daw:write) is Audacity's Draw tool: it overwrites individual sample values of one clip's source. edits is up to 64 ranges of {channel, start_frame, values[]} in source frames, the same frames get_clip_waveform indexes (its sample_rate, channel_count and frame_count; a range shorter than buckets gives one sample per bucket). Values are raw PCM in [-1, 1], before clip gain and effects.
  • Bounds per call: at most 1 s of frames in total (sample_rate frames, capped at 192,000), ranges on one channel must not overlap, and NaN, infinite or out-of-range values are rejected (invalid_sample_value, too_many_frames, too_many_ranges, frame_out_of_range, channel_out_of_range, overlapping_ranges). Batch a whole pencil drag into one call; see limits for rates and source length.
  • Revision check: expected_revision is the revision from get_clip_waveform you drew on. If the clip's source changed since (another edit, a voice-model render, a tempo change), nothing is applied: 409 revision_conflict with current_revision. Other refusals: source_not_durable (a take or import is still being stored; retry shortly), edit_in_progress (another edit on this clip is being saved), engine_reload_required / sample_rate_mismatch (the live session is behind the saved clip or changed rate; reload it).
  • Encrypted audio is supported: when a clip's audio is envelope-encrypted (raw recordings and uploads on stage and production usually are), or its encryption state cannot be proven, the audio engine encrypts the edited version itself before storing it, so it stays encrypted at rest like the original (encrypted_at_rest: true in the result). Edited audio never passes through the Freestyle servers in plaintext or otherwise. If the encrypted version cannot be stored right now the edit is refused with 409 source_encrypted_unsupported and nothing is applied.
  • Copy-on-write, lossless: the original audio is never modified. The engine applies the edits to the audio it already has decoded and stores a new immutable source version as a 32-bit float WAV at the source's decoded rate and channel count, so every sample you did not draw is bit-identical and the edited values are stored as the nearest 32-bit float. The new version is written by the engine straight to storage. Only this clip switches to the new version; other clips that share the old audio keep it. A previous effects render of the clip is dropped so players use the edited audio. Turning on Enhance, a voice model (RVC) or a tempo change later re-renders the clip from the original recording and replaces the pencil edits; undo then answers source_changed.
  • Result: the new revision (from now on get_clip_waveform reports the same value, also after a session reload), previous_revision, changed_ranges ({channel, start_frame, end_frame}) and undo ({clip_id, expected_revision}). idempotency_key (16–128 characters) is required; a retry with the same key and body returns the same result with replay: true (key order in the body does not matter), also when the first call timed out after the edit was saved, and reusing a key for a different edit is rejected. engine_reload_required: true in a result means the edit is saved but the live engine still plays the previous audio until the session reloads.
  • undo_clip_sample_edit (daw:write) restores the clip's previous version in one step; call it again to step further back. expected_revision must be the clip's current revision. It answers 409 when the source changed since the last edit, nothing_to_undo when there is no edit left, and returns the restored revision and remaining_undo_steps.
  • Retention: the last 8 versions of each clip are kept for undo. A version that is undone or falls off that list is deleted unless anything still uses it, in this project or any other (a project copy plays the same audio, a saved project version, another clip); if that cannot be checked quickly the version is kept. Original recordings and imports are never deleted by sample editing.

Clip and engine actions (execute_pro_action)

  • trim_clip keeps the clip's current value for any field you omit; split_clip takes clip_id (or a lane and split_ms) and keeps both halves on the lane; move_clip_to_lane and copy_append_clip take durable clip ids; delete_clip also deletes the saved clip.
  • attach_clip_to_session loads a just-uploaded clip (db_track_id = the clipId from upload_audio) into the running session without a reload.
  • preview_pattern accepts repeat_count (1–64) to loop. Its receipt reports sample_errors (a reason per failing sample source) and complete, and returns ok: false only when nothing could play.
  • send_midi plays notes immediately, in order: one note or events[] of {note, action: note_on|note_off, velocity 0-1, channel 1-16}. Empty or malformed input and CC are rejected before anything is sent.
  • open_plugin_editor / close_plugin_editor / release_plugin_editor / get_plugin_editor_status manage a track plugin's mirrored native editor; frames and input use the project's WebRTC editor channels.
  • play_range (also transport_control with command: "play_range") plays [start, end) once and stops exactly at end. Give start_sec/end_sec, or start_frame/end_frame in project-timeline frames at the engine rate (sample_rate converts from another rate to the nearest engine frame). The engine seeks to start and plays. It splits the audio block that crosses end, so the last frame rendered is end − 1, and pauses the transport at end. Effect tails then fade out as they do after a normal pause; there is no extra fade. The range then clears. A later play, pause, seek, seek-and-play or explicit loop change cancels a pending end. While the range plays, its end takes priority over an enabled loop region. Recording must be stopped first (409 recording_in_progress), and arming record cancels a pending range (cancelled_by_record). Frames must be non-negative integers and seconds finite; invalid values are rejected, never clamped. transport_control status (/transport/status) and get_transport_clock report play_range {active, start_sec, end_sec, start_frame, end_frame, sample_rate, stop_reason, stopped_at_frame, stopped_at_sec, generation}. stop_reason is one of reached_end, cancelled_by_play, cancelled_by_pause, cancelled_by_seek, cancelled_by_seek_and_play, cancelled_by_loop, cancelled_by_record or replaced. A refused request leaves the current range untouched.
  • set_metronome turns the click on or off.
  • set_track_pan pans a lane: pan from -1 (hard left) through 0 (center) to 1 (hard right), applied after the lane's fader and before bus routing, with a 25 ms ramp so moves do not click. Lanes playing mono audio use an equal-power law with −3 dB at center, compensated so center is unity (hard pan puts the signal on one side at +3 dB). Stereo lanes, instruments and patterns use equal-power balance: only the opposite side is turned down (−3 dB at ±0.5, silent at ±1). The value is saved on the lane (the backing lane's pan is saved with the project, beside its fader); pattern-generated lanes keep it for the session only.
  • set_bus_gain with bus_id: "master" sets the master output fader: linear gain 0–4 (1 = unity) on the whole project output, after the master chain and before the output limiter. It is saved with the project. This engine fader is separate from the Studio's Master strip, which is the listener's local monitor volume: the strip does not move when you set the engine fader, and shows a non-unity engine value as its Out level. Engine playback and Mozart renders (including export_mix) apply master gain and pan; the older FFmpeg mix endpoint (/api/mix/export) applies neither.
  • Both take persist: false while you sweep a control; send a final call without it to save. get_pro_state returns the current values in mix (masterGain and each track's pan/gain), and get_project returns masterGain and each lane's pan.
  • Live microphone input: live_ingest_offer sends a WebRTC offer carrying the microphone track and returns Mozart's answer (TURN from get_turn_credentials); live_ingest_close and get_live_status manage it, and start_recording / finalize_recording capture the take. Audio goes client → Mozart directly.

Tempo and meter maps

Every project has one revisioned timing map: tempo segments, a meter (time-signature) map with an optional pickup, and optional per-pattern meters. Read and change it with execute_pro_action: get_timing_map, set_timing_map, undo_timing_map and convert_musical_time (full schemas from list_pro_capabilities). The same contract is served over REST at GET/PUT /api/projects/<id>/timing-map, POST …/timing-map/undo and POST …/timing-map/convert, and get_project carries a summary in timingMap.

  • Units. tick = whole PPQ ticks, 96 per quarter note (the pattern timebase), from the project start; tick 0 is second 0. beat = quarter-note beats (tick / 96). bpm is always quarter notes per minute, whatever the meter's denominator, from 10 to 522 at 0.001 precision. Bar:beat:tick: bar 1 is the first full bar, bar 0 is the pickup; beat is 1-based in the meter's denominator unit (an eighth in 7/8); tick is 0-based inside that beat (0 .. 384/denominator − 1). Seconds are project-timeline seconds; frames are round(seconds · sample_rate).
  • Tempo segments {tick | beat | bar, bpm, curve, end_bpm?}. The first segment starts at 0. constant (alias step) holds until the next segment. linear (alias ramp) ramps linearly in beats from bpm to end_bpm (default: the next segment's bpm) at the next segment's start; the next segment may then jump. With k = (end_bpm − bpm) / (b1 − b0) BPM per beat: seconds(b) = s0 + (60/k)·ln(T(b)/bpm), beat(s) = b0 + (bpm/k)·(ek(s−s0)/60 − 1); constant: seconds(b) = s0 + 60·(b−b0)/bpm. The last segment cannot ramp. Example: 60 BPM for 10 s then 120 BPM for 10 s is 30 quarter notes, not 40.
  • Meter {bar | tick, numerator 1–64, denominator 1|2|4|8|16|32, groups?}. Changes happen only on bar lines (a tick must be a bar line of the preceding meter; mid-bar changes are rejected). groups sets the accent grouping in denominator beats and must sum to the numerator (7/8 as [2,2,3]); by default compound meters group in threes (6/8 → 3+3) and others accent only the downbeat. pickup_ticks (0 to one bar of the first meter minus one tick) is an anacrusis: bar 1 starts at that tick, and the pickup is numbered as the last beats of a full bar.
  • Pattern meters patterns: {pattern_id: {meter: [...]}}. A pattern without one uses the project's first meter. Pattern bars count from the pattern start. A pattern meter is grid metadata: it never changes lengthTicks, note or step ticks, or placements.
  • Missing vs empty. A project that was never edited has no stored map: implicit: true, revision 0, one constant segment at the project BPM (else the backing's detected BPM, else 120), 4/4, no pickup. In set_timing_map an omitted key keeps that part; an empty list resets it (meter: [] → 4/4; tempo: [] → one constant segment at the current tick-0 BPM); patterns: {id: null} or {id: {meter: []}} removes a pattern meter.
  • Revisions and writes. Writes need expected_revision (the revision you read). A mismatch fails with timing_map_revision_conflict (HTTP 409) and returns the current map in current. Every accepted write adds exactly one revision; nothing is partially applied. idempotency_key makes a retry return the revision it already produced (replayed: true); the same key with a different request is idempotency_key_reused. Errors are {ok: false, error, code, stage, engineStatus}: stage is validation, revision or policy, and engineStatus is not_dispatched (Mozart is never contacted for a rejected write). A success returns the fresh canonical map, inverse (a set_timing_map call that restores the previous content) and engine.status: "resync_queued" with a confirm rule: if get_transport_clock reports timing_map_revision, wait until it equals the new revision; if the field is absent the engine predates tempo maps (it plays the tick-0 tempo), so do not wait. Idempotent replay and undo reach back over the last 64 revisions, capped at 256 KiB of history (oldest first); a retry whose key has left that window is a new write, still guarded by expected_revision.
  • Undo. undo_timing_map {expected_revision} writes a new revision whose content is the state before the current revision's edit; repeated undo walks further back (the last 64 revisions are kept). timing_map_nothing_to_undo when there is nothing earlier.
  • Scalar BPM. set_project_tempo changes a constant map's tempo (a new revision when a map is stored; meter, pickup and pattern meters are kept). It commits with the same revision check as set_timing_map, so a concurrent map edit makes it fail with timing_map_revision_conflict instead of overwriting it. On a map with ramps or several segments it refuses with tempo_map_not_constant (stage policy) instead of erasing it. Once a project has a stored map, the Studio's autosaved BPM is only a mirror: it is applied only when the save carries the map revision it was edited against (timingMapRevision), so an open tab can never write an old tempo back over an edit made through MCP or the AI. Every map write broadcasts a timing_map project edit and open Studios re-read the map. A map with ramps or several tempos shows as ~BPM on the BPM control, which is then read-only. user_projects.bpm always mirrors the tempo at tick 0, so older readers keep working. mode: "stretch_audio" (default keep_time) keeps clips on their bars instead of their times: every audio clip re-renders through the per-clip tempo stretch (pitch kept, always from its original audio), clip and pattern starts scale by old/new BPM, and the tempo and positions change together once every render succeeded (a failed render rolls everything back). It answers with a job: poll get_tempo_stretch_job (job_id) and undo it with undo_tempo_stretch, which restores the old tempo, positions and original audio exactly (tempo_stretch_undo_conflict if the project was edited since). Loop repeats tile their clip's measured rendered length, automation envelopes are rescaled (and restored by undo), and a stretched backing moves the bar-ruler anchor. A job that answers engine_reload_required: true is saved, but the open engine session still plays the old arrangement until it is reloaded.
  • Anchoring. Audio clips and pattern placements are absolute-time locked (start_ms; audio source offsets and frames are never changed by a map edit). Pattern content is beat-locked to its placement start: every note, step and CC tick is mapped through the tempo map, so a note that crosses a tempo change keeps its length in ticks and its on and off times are mapped separately. Map edits never time-stretch audio; that stays the separate apply_track_tempo job.
  • Transport. get_transport_clock and the session channel's transport_clock frames add ppq, position_ticks, position_beats, time_signature, tempo_segment {index, start_tick, curve, bpm, end_bpm, start_seconds}, meter {bar, start_tick, numerator, denominator, accent_level, pickup_ticks}, timing_map_revision, timing_map_fingerprint and timing_map_source (timing_map or scalar_bpm) to the sample anchor (position_samples, sample_rate), song seconds and session_epoch, all computed from one map snapshot. bpm is the instantaneous tempo. The seek action accepts tick instead of seconds, and play_range and set_transport_loop accept start_tick/end_tick; each takes an optional timing_map_revision and fails with timing_map_revision_mismatch (409) when the engine holds another revision. Ticks are converted to seconds once, when the command arrives; the engine plays seconds, so a later map edit does not move a running loop or range.
  • Metronome. The engine click sounds every denominator beat (eighths in 7/8) at the map's tempo, ramps included: a high loud click on each downbeat, a high click on accent-group starts, a low click otherwise. The recording count-in uses quarter-note beats at the current tempo.
  • Import. FLP project time signatures and time-signature markers become the meter map; an off-bar or unsupported marker is reported and skipped. FL tempo automation is not imported: the import report's tempoMap.limitation says the fixed project tempo was used. There is no MIDI file import or export in Freestyle yet; export your own from get_timing_map (MIDI set-tempo and time-signature meta events map one to one, except ramps, which need stepping).
  • Rollout. Mozart ships first (without the database columns it keeps playing the scalar tempo), then the migration and backend, then the Studio. Until a project's Mozart reports timing_map_revision, it plays the tick-0 tempo in 4/4.
  • Fixture. timing-map-fixture.json is a canonical project map (3/4 with a pickup, 6/8 with 3+3 accents, the meter restored to 3/4, a tempo ramp, a step at an exact bar line and an independent 5/4 pattern meter) with the expected conversions. Send its set_timing_map_arguments to a fresh project to reproduce it.

Automation envelopes

  • create_automation / update_automation take points of {timeSec, value, curve?, tension?, meta?}; list_automation returns them in the same shape. timeSec is seconds from the clip start, stored at full double precision (no rounding); value is 0–1 (clip gain = 4·value, so 0.25 is unity).
  • Two points with exactly the same timeSec are a jump (an Audacity discontinuity pair): the first is the value just before that time, the second the value from it on. Order is kept. At most two points are kept per time; if you send more, the first and the last are kept. The automatic end points at 0 and the clip duration are added only when no point sits exactly there.
  • curve is linear (default), bezier (with tension −1..1), hold (forced for discrete and boolean parameters) or db. db is valid only on clip gain. It fades in decibels like Audacity: from 1× to 0.25× the halfway gain is 0.5× (linear gives 0.625×). A point at 0 is silent exactly at its time; on the way there the gain stops at a −140 dB floor.
  • meta is an optional JSON object, up to 1 KB per point and 256 KB per envelope, returned unchanged. Send it back with update_automation to keep it.
  • Splitting a clip or placement keeps every point. A jump exactly at the cut is split between the two sides: the left side ends on the first value and the right side starts on the second.

Discovery and errors

  • list_pro_capabilities with action: "<name>" returns that action's full record: argumentSchema (JSON Schema with units in x-unit; x-inferred marks types inferred from the field name), method, mutates, risk/destructive/requiresConfirmation and the result shape.
  • A failed action returns {error, code, stage, engineStatus?}. stage is validation (rejected before dispatch), engine_dispatch (could not complete the call to Mozart) or engine (Mozart answered and refused). code is stable, for example invalid_argument, engine_timeout, engine_unreachable, engine_conflict, engine_route_not_found, target_not_loaded or the engine's own code.

get_project clips include audioOffsetSec; send it back unchanged (never a guessed 0) when trimming. list_my_library_assets is paged: pass nextCursor back as cursor until it is null.

Interactive session channel (WebSocket push)

MCP itself stays POST-only. An editor that needs server push opens an interactive session: a WebSocket on the Freestyle origin that carries commands, acknowledgements, a gap-free revision stream and the transport clock.

  1. Your backend calls open_interactive_session with its OAuth token (project_id, optional track_id, origin = the browser origin that will connect, mode auto|write|read). It returns session_id, websocket_url, session_ticket, ticket_expires_at, expires_at (session), revision, sample_rate, clock, monitor and limits. A write session needs the editor role and daw:write; viewers and daw:read-only grants get a read-only session. The OAuth token never leaves your backend.
  2. The browser opens websocket_url with no credential in the URL and sends {"type":"auth","ticket":"…"} as its first frame (within 120 s of issue, and within 10 s of connecting: a hard deadline, a partial frame does not extend it). The ticket is signed, single-use and bound to the user, project, session, scopes, mode and the browser Origin; it must arrive from exactly that origin. A ticket issued without origin refuses browser connections (server-side clients only). Allowed origins: your OAuth client's registered redirect-URI origins and allowed origins, plus origins Freestyle allowlists.
  3. The server answers welcome (epoch, revision, limits, session_expires_at, server clocks) and then a snapshot (the get_pro_state shape) unless the auth frame carried "snapshot": false or "resume": {"epoch", "revision"}.

Commands. {"type":"command","id","action","arguments","base_revision"?,"require_base"?,"confirmed_destructive"?,"gesture"?}. action is any execute_pro_action action except the generative compose family (not_interactive: use MCP). Commands run through the same allow-listed executor, role checks and studio announcement as execute_pro_action, in arrival order. A mutating command commits one revision: its state_patch arrives immediately before {"type":"ack","id","status":"applied","revision","result"}. Read actions ack with the current revision. Failures are {"type":"reject","id","code","error","revision"}; codes include unsupported_action, not_interactive, read_only_session, confirmation_required, invalid_command, invalid_revision, stale_revision (only with require_base: true; otherwise a command based on an older revision applies last-writer-wins and its ack carries rebased_from), scheduling_unsupported (at_sample_frame is not supported yet: commands apply on arrival), rate_limited (with retry_after_ms), editor_required and the engine codes listed above. id (1–64 of [A-Za-z0-9._:-]) deduplicates final outcomes: a repeated id gets the original ack, or the original reject when that reject was final (for example invalid_command, unsupported_action, read_only_session, an engine validation error), again with duplicate: true (the last 1024 ids per session, across reconnects to the same server process). Transient rejects are not remembered, so retrying the same id runs the command again: rate_limited, server_busy, engine_timeout, confirmation_required, stale_revision, invalid_revision, too_many_pending, gesture_in_progress, internal_error, any *_timeout / *_unavailable / *_busy code and any reject carrying retry_after_ms. After engine_timeout the engine may still have applied the edit: re-read before retrying a non-idempotent action. server_busy (retry_after_ms) means this server's bound on concurrent engine calls from sockets is full. An id still being coalesced answers status: "pending".

Faders and knobs. Updates to seek, set_track_gain, set_clip_gain, set_bus_gain, the native EQ bands, pattern gains and lane/bus plugin parameters are coalesced per control (identity = the *_id/*_index/band arguments): updates within 40 ms collapse into one engine call with the final value and one revision; superseded commands ack status: "coalesced", into: <id>. For a drag, send gesture: {"id", "phase": "begin"|"update"|"end"}: updates ack status: "accepted" and are applied live (audible) at most 20 times a second without a revision; end applies the final value as exactly one revision (one undo step for your editor). Edit access is re-checked when each gesture begins (a lost role rejects it with forbidden and ends the session). A gesture with no update for 5 s commits itself (gesture_committed, auto_ended: true). Socket edits are not added to the Studio's own undo history.

Events and ordering. Every state_patch (origin, changes[]: the action, its arguments and summary) and resync_required carries epoch, from_revision and revision = from_revision + 1. All sessions on a project share one stream, so other editors' socket commands arrive as patches. Edits made elsewhere (MCP tools/call, Mozart AI, the Studio's timeline) arrive as resync_required with the new revision and no invented diff: re-read with snapshot_request or your own reads. Mixer changes made anywhere else, including a Studio user's direct fader, pan, mute, solo or routing moves on the engine, raise Mozart's mix_revision; while the clock is subscribed, a change that this channel's own commands did not cause arrives as resync_required with source: "mix" and detail.mix_revision. That detection is best effort (it rides the clock read, and a change landing while one of your own mix commands is in flight is absorbed), so a writer that must not overwrite a human sends expected_mix_revision (see Mixing safely). Plug-in parameter changes made directly on the engine do not raise resync_required; guard parameter writes with expected_value_norm. If from_revision is not the last revision you saw, you missed events: send {"type":"resubscribe","epoch","since_revision"}. The server replays from its buffer (512 events) or, when it cannot (old revision, or a new epoch after a restart), sends a full snapshot (reason replay_unavailable / epoch_changed). A snapshot's revision is read before its state, so treat later patches as idempotent re-applications.

Transport clock. {"type":"transport_clock","seq","sample_frame","sample_rate","server_monotonic_ns","server_time_ms","fetch_rtt_ms","playing","bpm","loop":{enabled,start_sec,end_sec},"bar","beat","tick","recording","producer_latency_seconds"} plus, from a current engine, the musical fields described under Tempo and meter maps (position_ticks, time_signature, tempo_segment, meter, timing_map_revision, session_epoch); a change of timing_map_revision pushes a frame immediately up to 15 Hz while playing; while stopped the engine is read 4 times a second and a frame is pushed only on a change or a 2 s heartbeat. One engine poll per project feeds every socket, and it runs only while at least one live socket on the project is subscribed to the clock. The rate is a ceiling, not a guarantee: reads are scheduled start to start, so the achievable rate is the lower of 15 Hz and 1 / engine round trip, and every project on a server shares a budget of 120 engine clock reads per second (with many projects playing at once each gets a share). Interpolate between frames with sample_rate; do not assume a fixed spacing. Frames are lossy and coalesced (a slow socket gets the latest). sample_frame is the engine write head, sampled within fetch_rtt_ms of server_monotonic_ns; use {"type":"ping","client_time"} → pong (server_monotonic_ns) to map server time to yours, and subtract producer_latency_seconds plus your WebRTC jitter delay for the heard position. Turn it off with {"type":"subscribe","clock":false}.

Session lifecycle. One socket per session: a new connection with a fresh ticket replaces the old one (the old socket gets session_closed and is closed with 4409 within a moment; nothing it sends afterwards runs). The server pings every 20 s at the WebSocket level (browsers answer automatically); a socket that sends nothing at all, not even a pong, for 50 s is closed (4408 peer_timeout, or 1008 from the keepalive) and stops keeping its session alive. A frame over 64 KiB is refused while it is still arriving (1009). Before a ticket expires, {"type":"renew"} re-checks your grant and role, extends the session and returns renewed with a resume_ticket for your next reconnect; after a lost socket you can also call open_interactive_session with session_id. Sessions slide while a socket is connected, expire after 600 s without one, and live at most 43200 s. {"type":"close"} or close_interactive_session revokes a session; revoking the OAuth grant, losing project access or losing edit access (write sessions) ends it within 30 s; edits still being coalesced when a session is revoked are dropped, not applied. At most 4 open sessions per user; per project at most 8 write sessions and, separately, 64 read sessions, so viewers never lock an editor out (too_many_sessions; the per-user error lists active_session_ids). Resuming a read session in write mode needs a free write slot. The server says why before closing (session_closed with reason). Close codes: 4400 protocol, 4401 bad, used or expired ticket or origin mismatch, 4403 access lost, 4408 no auth frame in time or peer silent, 4409 replaced, 4410 session closed or expired, 4429 server busy, 1009 frame over 64 KiB.

Mixing safely. The live mix (lane gain, pan, mute, solo and output bus; the master output gain; bus gain, mute and solo; lanes and buses added or removed) has one revision, Mozart's mix_revision. Every change bumps it, whoever made it: a Studio user moving a fader, another agent, the WebRTC control channel, a session reload. Automation playback and meters never do. Read it as mix.mixRevision in get_pro_state (also session.mix_revision, transport.mix_revision and every transport_clock frame). Then pass it back as the top-level expected_mix_revision of execute_pro_action (next to action and arguments) on set_track_gain, set_track_pan, set_track_muted, set_track_soloed, route_track_to_bus, set_bus_gain, set_bus_muted, set_bus_soloed or apply_mix. Mozart compares and applies under its mix-write lock, so if anything changed in between, nothing is applied and the tool fails with mix_revision_conflict and currentMixRevision: re-read the mix, decide again, retry. apply_mix takes changes (up to 64 of {target: "lane", lane_id | track_id, gain?, pan?, muted?, soloed?, bus_id?}, {target: "master", gain} and {target: "bus", bus_id, gain?, muted?, soloed?}), validates all of them before applying any, applies them as one revision step and returns mix_revision plus undo_changes, the inverse batch that undoes the move. For plug-in parameters, set_plugin_parameter takes expected_value_norm (the valueNorm you read); a parameter that moved by more than 1e-4 since refuses the write with plugin_parameter_conflict and currentValueNorm, alongside the existing expected_plugin_instance_id / expected_plugin_type slot pins. A live engine older than mix revisions cannot check these preconditions and refuses the write with engine_update_required instead of applying it unguarded; writes without a precondition keep working there.

Audio and meters are not on this socket: monitor with start_audio_monitor + rick_webrtc_offer (Mozart → client WebRTC). Mixer meters are lossy telemetry on that peer's data channel, not part of the revision stream.

Freestyle developer documentation. Base URL https://freestyle.audio. Generated from the server's own registry and configuration.