Skip to content

feat: implement 'audio hold', 1 frame of audio is played continously in a loop - #42

Merged
ronak-create merged 3 commits into
ronak-create:mainfrom
PlkMarudny:audio-hold
Jul 25, 2026
Merged

ronak-create merged 3 commits into
ronak-create:mainfrom
PlkMarudny:audio-hold

Conversation

@PlkMarudny

@PlkMarudny PlkMarudny commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Audio editing helper; when in pause mode, one frame of audio is being played in a loop. This way it is easy to find a cut point. Pressing play/pause cancels the effect.

Type of change

  • Bug fix
  • New feature (transition / preset / text anim / effect / API)
  • Docs
  • Refactor / internal

How was it verified?

  • node --check server.js && node --check app.js && node --check mcp-server.js passes
  • Opened the editor and confirmed the change in preview
  • Confirmed the change in an export (fast or realtime), if it affects rendering
  • Updated CLAUDE.md / README.md if the schema, props, or API changed

Checklist

  • No new runtime dependencies added
  • Preview and export render identically (single compositor)
  • Commits are focused and messages are descriptive

Summary by CodeRabbit

  • New Features
    • Added an Audio Hold toolbar toggle that loops a single timeline frame of audio while playback is paused.
    • Scrubbing or frame-stepping retargets the held audio slice while keeping audio meters live.
    • Audio Hold automatically clears when playback starts, and is disabled via the toggle or when playback controls are used.
    • Project reload/reset now stops any active Audio Hold state to ensure playback elements rebuild cleanly.

@coderabbitai

coderabbitai Bot commented Jul 25, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 710816b0-12d9-4a79-b828-6824e2643e11

📥 Commits

Reviewing files that changed from the base of the PR and between 4c9045d and 63fd03a.

📒 Files selected for processing (3)
  • README.md
  • app.js
  • index.html
🚧 Files skipped from review as they are similar to previous changes (3)
  • index.html
  • README.md
  • app.js

📝 Walkthrough

Walkthrough

Adds an Audio Hold toolbar mode that loops one audio frame at the paused playhead, retargets during timeline navigation, keeps meters active, and disables during playback, project replacement, or manual deactivation.

Changes

Audio Hold playback

Layer / File(s) Summary
Audio Hold control and state
index.html, app.js, README.md
Adds the toolbar toggle, state flag, click handling, and documentation for paused one-frame audio looping.
Audio Hold audio graph
app.js
Slices and loops one frame of decoded audio, manages refresh scheduling and node disposal, and supports stereo channel selection.
Playback, timeline, and meter integration
app.js
Refreshes held audio after setTime(), disables Audio Hold when playback starts or projects reload, and includes hold activity in meter updates.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant btnAudioHold
  participant setAudioHold
  participant refreshAudioHold
  participant AudioBuffer
  participant updateMeterUI
  User->>btnAudioHold: Enable Audio Hold
  btnAudioHold->>setAudioHold: Toggle hold mode
  setAudioHold->>refreshAudioHold: Start paused refresh
  refreshAudioHold->>AudioBuffer: Slice one timeline frame
  AudioBuffer-->>refreshAudioHold: Return frame buffer
  refreshAudioHold-->>User: Loop held audio
  updateMeterUI-->>User: Animate meters during hold
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding an Audio Hold feature that loops one frame of audio.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
app.js (1)

2864-2882: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the duplicated pause-UI reset into a shared helper.

The if (state.playing) { ... } block here duplicates the state.playing=false / btnPlay text+class / clipEls-pause logic already in pause() (lines 2756-2759). A shared helper (e.g. pausePlaybackUI()) would keep the two paths from drifting.

♻️ Proposed refactor
+function pausePlaybackUI() {
+  state.playing = false;
+  els.btnPlay.textContent = "▶";
+  els.btnPlay.classList.remove("on");
+  for (const el of runtime.clipEls.values()) { if (!el.paused) el.pause(); }
+}
+
 function pause() {
   if (state.audioHold) setAudioHold(false);
-  state.playing = false;
-  els.btnPlay.textContent = "▶";
-  els.btnPlay.classList.remove("on");
-  for (const el of runtime.clipEls.values()) { if (!el.paused) el.pause(); }
+  pausePlaybackUI();
   if (state.exporting) finishExport(false);
 }
 ...
 function setAudioHold(on) {
   on = !!on;
   if (on) {
-    if (state.playing) {
-      // Pause without going through pause() (that would clear hold).
-      state.playing = false;
-      els.btnPlay.textContent = "▶";
-      els.btnPlay.classList.remove("on");
-      for (const el of runtime.clipEls.values()) { if (!el.paused) el.pause(); }
-    }
+    // Pause without going through pause() (that would clear hold).
+    if (state.playing) pausePlaybackUI();
     state.audioHold = true;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app.js` around lines 2864 - 2882, Extract the duplicated playback pause reset
from setAudioHold into a shared helper such as pausePlaybackUI(), including
state.playing, btnPlay text/class, and runtime.clipEls pause logic. Update both
setAudioHold and pause() to call this helper while preserving their existing
hold-specific behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app.js`:
- Around line 2864-2882: Update setAudioHold so the true branch exits without
changing state.audioHold or adding the "on" class when state.exporting or
state.rendering is active. Preserve the existing hold activation behavior when
neither operation is in progress, and keep the false branch’s clearing behavior
unchanged.

---

Nitpick comments:
In `@app.js`:
- Around line 2864-2882: Extract the duplicated playback pause reset from
setAudioHold into a shared helper such as pausePlaybackUI(), including
state.playing, btnPlay text/class, and runtime.clipEls pause logic. Update both
setAudioHold and pause() to call this helper while preserving their existing
hold-specific behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2355df72-61b0-42d0-b862-bb47a530931d

📥 Commits

Reviewing files that changed from the base of the PR and between d584430 and 4c9045d.

📒 Files selected for processing (3)
  • README.md
  • app.js
  • index.html

Comment thread app.js Resolved
@ronak-create
ronak-create merged commit 3b860a3 into ronak-create:main Jul 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants