› cavi-ai/
GitHub ↗

Keep a played MIDI idea

Use keep-played-midi when you want to retain recently played MIDI without having started a normal recording. For example: “Keep what I just played, leave its timing alone and show me the captured clip.” The workflow uses the all profile and an updated bridge.

get_midi_capture_context reads global Capture MIDI availability, current armed/monitored candidates, playing-clip risks, input routing, existing note counts/digests, timing, tempo and recording/musical controls. Input monitoring In can make an unarmed track a candidate. This preserves focus and does not reveal Live's hidden input buffer, exact future notes or a chosen destination slot. The moving playhead is observed through the separate transport reader and is not reserved by a capture plan.

Capture MIDI is global, not restricted to the selected track. Live can create Session clips or scenes, start playback, adjust tempo in an empty Set or overdub a playing Session clip. Resolve that scope before capturing. Do not change arms, monitoring or routing merely to imply isolation of an existing buffer. If no material is available, inspect the input for a future performance; do not invent notes or silently start normal recording instead.

Plan capture_midi_session with a fresh expectedStateVersion, review the complete context, then confirm with the token and plan hash. The default refuses known playing-clip changes. Use allowExistingClipChanges: true only for explicitly authorized changes to those existing clips. Native execution rechecks Set/track/slot/clip identities, current MIDI notes and timing, routing, monitoring, arms, launches, tempo and musical/recording controls. Resolve recording, pending launches and frozen candidate tracks first. Reads support at most 256 tracks, 16384 Session slots and 16384 existing MIDI notes. Instruments, hidden expression curves and the hidden MIDI buffer are outside the snapshot.

The operation captures the current native buffer at execution time; the plan is not an exact note preview. Read captureRequested, captureVerified, changedSlots, scene counts, tempoBefore/tempoAfter and actual playback. existingContentPreserved distinguishes creation from changes to existing clips. unexpectedExistingChanges and verificationError remain unresolved outcomes. Do not automatically undo the result, which could erase other work.

captureVerified means a changed nonempty MIDI clip was observed without a disallowed existing-content change. It does not establish completeness of the hidden buffer, exact human intent, expression capture or audible output. An authorized overdub can rebuild notes with new note IDs, repeat existing content and move loop markers; existing edits may fall outside the resulting loop. Read each affected clip's complete notes and timing separately before further development. Compare musical content rather than assuming note IDs survive capture. Keep unrequested timing, note lengths and dynamics unchanged during subsequent edits.

After a timeout or lost reply, inspect all Session clips and their actual notes before retrying. Capture has no durable operation handle or recoverable buffer snapshot. Missing pre-capture observations can leave provenance uncertain; do not claim recovery or repeat the command blindly. Preserve manual edits, and scope auditions, stopping, disarming, cleanup and saving to the user's request.