The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Strudel: loop marked moments in recorded takes (#231)
Dee708da285f748
diff --git a/store/agents/strudel/AGENTS.md b/store/agents/strudel/AGENTS.mdindex e52dcfbb4..38619062b 100644--- a/store/agents/strudel/AGENTS.md+++ b/store/agents/strudel/AGENTS.md@@ -34,6 +34,11 @@ listen, name it and **Keep take**. The pane records actual stereo output, up tosaves `out/takes/<id>/performance.wav`, `take.json`, numbered source versions and `take.zip`.The live track file stays untouched. The saved take reopens in the pane after a restart.+To audition a favorite passage, select its marker and **Loop moment**. This repeats the captured+audio until the next distinct marker or the end of the take. It does not synthesize the source again+or trim the saved WAV. **Stop looping** restores full-take playback. The selected range is temporary;+the original audio, marker journal and downloadable source remain intact.+When asked to develop a kept take or a marked moment, read its `take.json` and the correspondingsource version before editing `track.strudel`. Use the journal's source, mix, tempo and markerevents to understand the direction; do not replace the performance with the default template.diff --git a/store/agents/strudel/README.md b/store/agents/strudel/README.mdindex 8276c8cc3..96b9ff615 100644--- a/store/agents/strudel/README.md+++ b/store/agents/strudel/README.md@@ -21,11 +21,15 @@ its preview video pairs the screen recording with the captured take's audio.keeps playing. `pane/voices.mjs` is the voice parser (`node --test pane/voices.test.mjs`).- **Perform and keep.** Click Play, then **Record take**. Mute, solo, run a code change, or mark amoment while the track plays. **Finish take** opens the actual stereo recording, with a waveform- and seekable moment buttons. Name it and **Keep take**: the WAV, every successfully played code+ and seekable moment buttons. Select a moment and **Loop moment** to audition its captured audio+ through the next marker or the end of the take. The waveform highlights the passage; **Stop+ looping** returns to the full recording. Name it and **Keep take**: the WAV, every successfully played codeversion, a timed performance journal and an **Audio + source** ZIP live in `out/takes/`.Open them again from **Takes**, including after restarting the pane. Listening to a take stopsthe live instrument; playing the instrument pauses the take. Failed saves retain the recordingfor retry or direct WAV download. Retrying a lost save response keeps one copy.+ A take whose samples exceed full scale shows its measured peak and a reminder to lower the mix+ for the next recording; the original audio stays unchanged.- Agent file changes wait during capture or when the editor has unsaved changes. **Load newversion** applies the latest file when the performer is ready. Saving a take leaves the live`.strudel` file untouched; the take's source files are available for the next agent revision.diff --git a/store/agents/strudel/pane/index.html b/store/agents/strudel/pane/index.htmlindex b2216187c..e21fe3f10 100644--- a/store/agents/strudel/pane/index.html+++ b/store/agents/strudel/pane/index.html@@ -34,9 +34,11 @@<div id="take-live" hidden><span id="take-live-note">Recording your mix and code changes.</span><input id="marker-note" maxlength="240" placeholder="Name a moment…" aria-label="Moment note"><button id="add-marker">Add marker</button></div><div id="take-draft" hidden><div class="draft-head"><strong>Your take</strong><span id="draft-details"></span><span class="grow"></span><button id="discard-take">Discard</button></div>+ <p id="take-level" role="status" hidden></p><canvas id="take-wave" aria-label="Recorded stereo waveform" title="Left and right channels · waveform fitted to view · click to seek"></canvas>- <audio id="take-audio" controls preload="metadata"></audio>+ <audio id="take-audio" controls preload="metadata" aria-label="Recorded performance"></audio><div id="take-markers"></div>+ <div id="take-loop" hidden><button id="loop-moment" aria-pressed="false" disabled>Loop moment</button><span id="loop-details"></span></div><div class="keep-row"><input id="take-name" maxlength="100" placeholder="Name this take" aria-label="Take name"><button id="keep-take">Keep take</button><a id="download-draft" download="performance.wav">WAV</a></div></div><div id="take-shelf" hidden><div id="take-list"></div><p id="take-empty">Your performances will live here, with their audio, code and moments.</p></div>diff --git a/store/agents/strudel/pane/pane.css b/store/agents/strudel/pane/pane.cssindex e5d0fdd96..951c36c65 100644--- a/store/agents/strudel/pane/pane.css+++ b/store/agents/strudel/pane/pane.css@@ -221,12 +221,16 @@ button { font: inherit; color: inherit; cursor: pointer; }.draft-head, .keep-row { display: flex; gap: 10px; align-items: center; }.draft-head { margin-bottom: 6px; }#draft-details { color: var(--h-ink2); font-size: 11px; }+#take-level { color: var(--h-err); font-size: 12px; margin: 6px 0; }.grow { flex: 1; }#take-wave { display: block; width: 100%; height: 52px; border-radius: 5px; background: var(--h-card); cursor: pointer; }#take-audio { display: block; width: 100%; height: 34px; margin: 6px 0; }#take-markers { display: flex; gap: 6px; overflow-x: auto; padding: 0 0 8px; }#take-markers:empty { display: none; }#take-markers button { white-space: nowrap; font-size: 11px; color: var(--h-accent); }+#performance [aria-pressed="true"] { border-color: var(--h-accent); background: color-mix(in srgb, var(--h-accent) 14%, var(--h-bg)); }+#take-loop { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }+#loop-details { color: var(--h-ink2); font-size: 11px; overflow-wrap: anywhere; }#take-name { flex: 1; max-width: 480px; }#performance #keep-take { background: var(--h-accent); color: white; border-color: var(--h-accent); white-space: nowrap; }#take-message { padding: 0 14px 10px; color: var(--h-ink2); font-size: 12px; }diff --git a/store/agents/strudel/pane/pane.mjs b/store/agents/strudel/pane/pane.mjsindex e86bdd866..aec4f6eb4 100644--- a/store/agents/strudel/pane/pane.mjs+++ b/store/agents/strudel/pane/pane.mjs@@ -116,6 +116,10 @@ function renderMixer() {s.classList.toggle('on', S.soloed.has(v.key))m.title = `Mute ${v.name}${i < 9 ? ` (${i + 1})` : ''}`s.title = `Solo ${v.name}${i < 9 ? ` (⇧${i + 1})` : ''}`+ m.setAttribute('aria-label', `Mute ${v.name}`)+ s.setAttribute('aria-label', `Solo ${v.name}`)+ m.setAttribute('aria-pressed', String(S.muted.has(v.key)))+ s.setAttribute('aria-pressed', String(S.soloed.has(v.key)))row.classList.toggle('silent', !audible(i) || !!v.muted)row.classList.toggle('codemuted', !!v.muted)return rowdiff --git a/store/agents/strudel/pane/performance.mjs b/store/agents/strudel/pane/performance.mjsindex 49e68ab1d..21846452a 100644--- a/store/agents/strudel/pane/performance.mjs+++ b/store/agents/strudel/pane/performance.mjs@@ -1,4 +1,5 @@import { capture, packTake } from './recording.mjs'+import { markedPassage, passageWave } from './take-loop.mjs'const $ = (id) => document.getElementById(id)const time = (seconds) => `${Math.floor(seconds / 60)}:${String(Math.floor(seconds % 60)).padStart(2, '0')}`@@ -19,6 +20,7 @@ export function installPerformance({ state: S, cycle, stop }) {duration = 0let takes = [],waveSamples = null+ let audioBytes = null, fullURL = null, loopURL = null, loopRange = null, selectedMarker = nullconst mix = () => ({ muted: [...S.muted], soloed: [...S.soloed] })const clock = () => ({ cycle: cycle(), cps: Math.max(0, Number(S.sched?.cps) || 0) })function message(value = '', error = false) {@@ -83,15 +85,48 @@ export function installPerformance({ state: S, cycle, stop }) {}function clearDraft() {$('take-audio').pause()+ $('take-audio').loop = false$('take-audio').removeAttribute('src')$('take-audio').load()if (blobURL) URL.revokeObjectURL(blobURL)+ if (loopURL) URL.revokeObjectURL(loopURL)blobURL = null+ audioBytes = fullURL = loopURL = loopRange = selectedMarker = nulldraft = nullwaveSamples = null$('take-draft').hidden = truesync()}+ const position = () => $('take-audio').currentTime + (loopRange?.start || 0)+ function syncLoop() {+ const range = selectedMarker && markedPassage(draft, selectedMarker)+ $('loop-moment').disabled = !loopRange && (!audioBytes || !range)+ $('loop-moment').setAttribute('aria-pressed', String(!!loopRange))+ $('loop-moment').textContent = loopRange ? 'Stop looping' : 'Loop moment'+ $('loop-details').textContent = range+ ? `${loopRange ? 'Looping' : 'Selected'} ${time(range.start)}–${time(range.end)} · ${selectedMarker.note}`+ : selectedMarker ? 'This marker is at the end of the take.' : 'Choose a marked moment to repeat it.'+ }+ function playback(loop, at = position(), play = !$('take-audio').paused) {+ const audio = $('take-audio')+ try {+ const range = loop && selectedMarker && markedPassage(draft, selectedMarker)+ if (loop && (!audioBytes || !range)) return+ const nextURL = range ? URL.createObjectURL(passageWave(audioBytes, draft.audio, range)) : null+ audio.pause()+ if (loopURL) URL.revokeObjectURL(loopURL)+ loopURL = nextURL+ loopRange = range || null+ audio.loop = !!range+ audio.src = nextURL || fullURL+ audio.currentTime = range ? 0 : Math.max(0, Math.min(duration, at))+ syncLoop()+ drawWave()+ if (play) audio.play().catch(() => message('Press Play on the recording to listen.'))+ } catch (error) {+ message(error.message, true)+ }+ }function drawWave() {if (!waveSamples) returnconst canvas = $('take-wave'),@@ -101,6 +136,12 @@ export function installPerformance({ state: S, cycle, stop }) {canvas.height = Math.round(52 * ratio)const ctx = canvas.getContext('2d')ctx.scale(ratio, ratio)+ if (loopRange) {+ ctx.fillStyle = getComputedStyle(document.documentElement).getPropertyValue('--h-accent')+ ctx.globalAlpha = 0.16+ ctx.fillRect(loopRange.start / duration * rect.width, 0, (loopRange.end - loopRange.start) / duration * rect.width, 52)+ ctx.globalAlpha = 1+ }ctx.fillStyle = getComputedStyle(document.documentElement).getPropertyValue('--h-accent')const maximum = Math.max(0.0001, ...waveSamples.left, ...waveSamples.right)for (let channel = 0; channel < 2; channel++) {@@ -114,7 +155,7 @@ export function installPerformance({ state: S, cycle, stop }) {}ctx.globalAlpha = 1ctx.fillStyle = getComputedStyle(document.documentElement).getPropertyValue('--h-ink')- const x = ($('take-audio').currentTime / duration) * rect.width+ const x = (position() / duration) * rect.widthctx.fillRect(x, 0, 1, 52)}async function showDraft(value, wav) {@@ -123,10 +164,13 @@ export function installPerformance({ state: S, cycle, stop }) {duration = value.audio.durationif (wav) blobURL = URL.createObjectURL(wav)const url = blobURL || urlFor(value.id, 'performance.wav')+ fullURL = url$('take-audio').src = url$('download-draft').href = url$('take-name').value = value.title$('take-name').readOnly = !!value.id+ $('take-level').hidden = true+ $('take-level').textContent = ''$('keep-take').hidden = !!value.id$('discard-take').textContent = value.id ? 'Close' : 'Discard'$('take-draft').hidden = false@@ -137,17 +181,29 @@ export function installPerformance({ state: S, cycle, stop }) {.filter((e) => e.type === 'marker').map((event) => {const button = node('button', `${time(event.at)} · ${event.note}`)+ button.setAttribute('aria-pressed', 'false')button.onclick = () => {- $('take-audio').currentTime = event.at+ selectedMarker = event+ for (const marker of $('take-markers').children) marker.setAttribute('aria-pressed', String(marker === button))+ if (loopRange) {+ const canLoop = !!markedPassage(draft, event)+ playback(canLoop, event.at, !$('take-audio').paused && event.at < duration)+ }+ else $('take-audio').currentTime = event.at+ syncLoop()drawWave()}return button}))+ $('take-loop').hidden = !value.events.some((event) => event.type === 'marker')+ syncLoop()sync()try {const bytes = await (wav || (await (await fetch(url)).blob())).arrayBuffer()if (draft !== value) return+ audioBytes = bytes+ syncLoop()const floats = new Float32Array(bytes, 56),bins = 1600waveSamples = { left: new Float32Array(bins), right: new Float32Array(bins) }@@ -156,6 +212,11 @@ export function installPerformance({ state: S, cycle, stop }) {waveSamples.left[b] = Math.max(waveSamples.left[b], Math.abs(floats[i]))waveSamples.right[b] = Math.max(waveSamples.right[b], Math.abs(floats[i + 1]))}+ const peak = Math.max(...waveSamples.left, ...waveSamples.right)+ if (peak > 1) {+ $('take-level').textContent = `Peak +${(20 * Math.log10(peak)).toFixed(1)} dBFS: this recording exceeds full scale and may distort during playback. Lower the mix for your next take.`+ $('take-level').hidden = false+ }drawWave()} catch {message('Audio is available; the waveform could not be drawn.')@@ -372,9 +433,12 @@ export function installPerformance({ state: S, cycle, stop }) {else stop()}$('take-audio').ontimeupdate = drawWave+ $('loop-moment').onclick = () => playback(!loopRange, position(), !loopRange || !$('take-audio').paused)$('take-wave').onclick = (event) => {if (duration) {- $('take-audio').currentTime = (duration * event.offsetX) / $('take-wave').clientWidth+ const at = (duration * event.offsetX) / $('take-wave').clientWidth+ if (loopRange) playback(false, at)+ else $('take-audio').currentTime = atdrawWave()}}diff --git a/store/agents/strudel/pane/take-loop.mjs b/store/agents/strudel/pane/take-loop.mjsnew file mode 100644index 000000000..9a9507e38--- /dev/null+++ b/store/agents/strudel/pane/take-loop.mjs@@ -0,0 +1,27 @@+import { wave } from './recording.mjs'++// A moment runs to the next distinct marker, or the end of the captured performance.+// Work in frames so playback uses the original samples, independent of UI timers.+export function markedPassage(take, marker) {+ const { sampleRate, frames } = take.audio+ const markers = take.events.filter((event) => event.type === 'marker')+ if (!markers.includes(marker) || !Number.isFinite(marker.at) || !sampleRate || !frames) return null+ const startFrame = Math.max(0, Math.min(frames, Math.round(marker.at * sampleRate)))+ const next = markers.filter((event) => event.at > marker.at).reduce((end, event) => Math.min(end, event.at), frames / sampleRate)+ const endFrame = Math.max(startFrame, Math.min(frames, Math.round(next * sampleRate)))+ if (endFrame === startFrame) return null+ return { startFrame, endFrame, start: startFrame / sampleRate, end: endFrame / sampleRate }+}++export function passageWave(bytes, audio, range) {+ const view = new DataView(bytes)+ if (bytes.byteLength !== 56 + audio.frames * 8 || view.getUint16(20, true) !== 3 ||+ view.getUint16(22, true) !== 2 || view.getUint32(24, true) !== audio.sampleRate ||+ view.getUint16(34, true) !== 32 || view.getUint32(52, true) !== audio.frames * 8)+ throw new Error('This recording cannot be looped: its audio does not match the saved take.')+ const { startFrame, endFrame } = range+ if (!Number.isInteger(startFrame) || !Number.isInteger(endFrame) || startFrame < 0 ||+ endFrame > audio.frames || endFrame <= startFrame)+ throw new Error('Choose a moment with recorded audio after it.')+ return wave([bytes.slice(56 + startFrame * 8, 56 + endFrame * 8)], endFrame - startFrame, audio.sampleRate)+}diff --git a/store/agents/strudel/test/PLAYTEST-2026-09-22.md b/store/agents/strudel/test/PLAYTEST-2026-09-22.mdnew file mode 100644index 000000000..12ef5bbfd--- /dev/null+++ b/store/agents/strudel/test/PLAYTEST-2026-09-22.md@@ -0,0 +1,42 @@+# Strudel user playtest — 2026-09-22++Draft PR: [#231](https://github.com/autonomous-ai/openharness/pull/231). No merge.+Branch: `codex/strudel-take-loops`.++## Completed++- A real prompt in a fresh native Harness project produced **Harbor Lights**, a 96 bpm five-voice+ synth track. The old installed package lacked the recorder because the Store did not offer+ an update after the official repository rename; the separate Store fix is PR223.+- Used that actual track in the patched viewer in Chrome: Play, record, mute/solo, mark two+ passages, finish with Space, name, keep, reload and reopen. The actual stereo take is 32.832 s,+ 1,575,936 frames at 48 kHz, with its source and timed mix events.+- Verified marked passage loops of 10.496 s and 10.954667 s, waveform highlighting, return to the+ matching full-take time while paused, live/recorded playback exclusion and keyboard mixer state.+ An end-marker regression was fixed and retested using an explicitly labeled copy of the take.+- Original full WAV and source hashes stayed unchanged. The WAV peak is 1.480566 (+3.4 dBFS),+ including 9,736 samples above full scale. The added take-level warning reports measured overload+ without normalizing or modifying audio. Reopened the real saved take in Chrome and verified+ the visible +3.4 dBFS warning and its layout.+- All 27 Node and 51 Python tests, package conformance, doctor and syntax checks passed.+- Installed this branch and submitted a new original prompt through Harness. The native project+ `strudel-2026-09-22-13-22` has a new 40-line offline five-voice track, call/answer melody,+ conservative gains and a clean parsing verdict.++## Resume here++The fresh native project's performance interaction and revision are unfinished. Play and record,+use Mute/Solo, mark a passage, loop it before saving, name and keep it, reload and reopen.+Then ask the embedded agent to develop the marked phrase from the kept journal/source while+preserving the saved take. The test operator owns preview controls; the agent should edit files+and inspect artifacts without controlling the desktop or browser. Measure the new WAV's actual+headroom; low gains in source alone do not prove it stays below full scale.++The completed Chrome take is `1a325927-0b8c-4d63-baad-a853c6c093fd` in the local+`strudel-app-review-9oe1fv6l` workspace. Its WAV SHA256 is+`c75ccab37e61302584fe9e5b2b560b3fc156b55dbd03d25aac125a595e970b1c`.+Scratch native baselines live in this branch's `.scratch/native-rerun-baseline/`; these are+local resume aids, not committed fixtures. The PR includes an approved screenshot of the real take.++Parsing and signal measurements do not establish musical quality. No subjective listening+approval or full native acceptance pass is claimed.diff --git a/store/agents/strudel/test/recording.test.mjs b/store/agents/strudel/test/recording.test.mjsindex 204b70da8..da70edd10 100644--- a/store/agents/strudel/test/recording.test.mjs+++ b/store/agents/strudel/test/recording.test.mjs@@ -3,6 +3,41 @@ import assert from 'node:assert/strict'import { CaptureFrames } from '../pane/capture-worklet.mjs'import { wave, packTake } from '../pane/recording.mjs'import { unpackTake, readWave } from '../takes.mjs'+import { markedPassage, passageWave } from '../pane/take-loop.mjs'++test('a marked passage ends at the next distinct marker, including duplicate and end markers', () => {+ const events = [0.2, 0.2, 0.65, 1].map((at) => ({ type: 'marker', at }))+ const take = { audio: { frames: 8000, sampleRate: 8000 }, events }+ assert.deepEqual(markedPassage(take, events[0]), { startFrame: 1600, endFrame: 5200, start: 0.2, end: 0.65 })+ assert.equal(markedPassage(take, events[1]).end, 0.65)+ assert.equal(markedPassage(take, events[2]).endFrame, 8000)+ assert.equal(markedPassage(take, events[3]), null)+ assert.equal(markedPassage(take, { type: 'marker', at: 0.1 }), null)+})++test('loop audio contains the exact stereo frames of the selected passage without changing the full take', async () => {+ const samples = Float32Array.from({ length: 16000 }, (_, i) => (i % 101 - 50) / 40)+ const bytes = await wave([samples], 8000, 8000).arrayBuffer()+ const before = Buffer.from(bytes).toString('base64')+ const marker = { type: 'marker', at: 0.20006 }+ const take = { audio: { frames: 8000, sampleRate: 8000 }, events: [marker, { type: 'marker', at: 0.65006 }] }+ const range = markedPassage(take, marker)+ const loop = Buffer.from(await passageWave(bytes, take.audio, range).arrayBuffer())+ assert.equal(readWave(loop).frames, 3600)+ assert.equal(readWave(loop).duration, 0.45)+ assert.deepEqual(loop.subarray(56), Buffer.from(bytes).subarray(56 + 1600 * 8, 56 + 5200 * 8))+ assert.equal(Buffer.from(bytes).toString('base64'), before)+})++test('looping rejects mismatched audio and empty or out-of-bounds passages', async () => {+ const bytes = await wave([new Float32Array(16000)], 8000, 8000).arrayBuffer()+ const audio = { frames: 8000, sampleRate: 8000 }+ const range = { startFrame: 0, endFrame: 4000 }+ assert.throws(() => passageWave(bytes.slice(0, 20), audio, range), /does not match/)+ assert.throws(() => passageWave(bytes, { ...audio, sampleRate: 48000 }, range), /does not match/)+ for (const bad of [{ startFrame: -1, endFrame: 20 }, { startFrame: 0, endFrame: 8001 }, { startFrame: 2, endFrame: 2 }])+ assert.throws(() => passageWave(bytes, audio, bad), /Choose a moment/)+})test('worklet buffer preserves exact stereo frames across chunks, stop is idempotent', () => {const messages = [],