Skip to content

Fix/from silence lego audio duration#677

Closed
ChuxiJ wants to merge 4 commits intomainfrom
fix/from-silence-lego-audio-duration
Closed

Fix/from silence lego audio duration#677
ChuxiJ wants to merge 4 commits intomainfrom
fix/from-silence-lego-audio-duration

Conversation

@ChuxiJ
Copy link

@ChuxiJ ChuxiJ commented Mar 21, 2026

This pull request refactors and clarifies how timing parameters are determined and sent for ACE-Step "lego" (stem) generation tasks, especially distinguishing between "from silence" and "context/cumulative" scenarios. The changes ensure the server receives accurate timing data, prevent regressions with mismatched durations, and improve code maintainability and test coverage.

Timing parameter computation and usage:

  • Added a new module, legoApiTiming.ts, with the computeLegoTimingParams function to centralize the logic for calculating repainting_start, repainting_end, audio_duration, and chunk/full mode for lego tasks. This ensures correct values are sent based on whether generation is "from silence" or uses context.
  • Updated generateClipInternal in generationPipeline.ts to use computeLegoTimingParams, ensuring all API calls use the correct timing fields and improving logging for debugging. [1] [2] [3]

Documentation and developer guidance:

  • Added a detailed markdown document (release_task_lego_mapping.md) explaining the mapping between DAW state and ACE-Step API timing fields, chunk/full instruction logic, and the correct handling of placeholder silence WAVs. This helps prevent subtle bugs and clarifies expected behaviors.
  • Improved inline documentation in silenceGenerator.ts to clarify the role of the placeholder silence WAV and direct developers to the new timing logic.

Testing and regression prevention:

  • Added a comprehensive unit test suite (legoApiTiming.test.ts) to verify computeLegoTimingParams handles all expected scenarios and edge cases, protecting against regressions.

chuxij added 2 commits March 21, 2026 15:48
From-silence: repainting 0/-1 and audio_duration = clip length.
Context paths unchanged. Adds legoApiTiming, tests, and docs.

See docs/github-issues/from-silence-lego-audio-duration.md
Track bugs on GitHub; keep behavior notes in docs/release_task_lego_mapping.md.
Copilot AI review requested due to automatic review settings March 21, 2026 15:52
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR centralizes and corrects how ACE-Step lego task timing fields are computed/sent, especially differentiating “from silence” vs “with context” generation to avoid duration mismatches when uploading a placeholder silence WAV.

Changes:

  • Added computeLegoTimingParams to compute repainting_*, audio_duration, and chunk/full instruction mode consistently.
  • Updated generateClipInternal to use the centralized timing computation and improved debug logging of timing values.
  • Added unit tests and documentation describing the DAW → /release_task timing field mapping and placeholder silence behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/services/legoApiTiming.ts New centralized timing computation for lego tasks (from-silence vs context).
src/services/generationPipeline.ts Uses computeLegoTimingParams when building lego task params and instruction text; improves timing logging.
src/services/silenceGenerator.ts Clarifies that silence WAV is a small placeholder and real duration comes from audio_duration.
tests/unit/legoApiTiming.test.ts Unit coverage for the new timing computation behavior and overrides.
docs/release_task_lego_mapping.md Developer-facing explanation of timing field mapping and regression to avoid.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

? null
: (options.forceSilence ? null : previousCumulativeBlob);
const srcAudioBlob = srcBlob ?? generateSilenceWav(audioDuration);
const srcAudioBlob = srcBlob ?? generateSilenceWav(timing.audio_duration);
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

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

generateSilenceWav intentionally uploads a fixed 0.1s placeholder and ignores its argument (see its _durationSeconds param). Passing timing.audio_duration here reads like it affects the generated blob length and can mislead future changes; consider either removing the parameter from generateSilenceWav (or renaming the function to indicate it's a placeholder), or pass a constant (e.g. 0) and rely exclusively on audio_duration in the task params.

Suggested change
const srcAudioBlob = srcBlob ?? generateSilenceWav(timing.audio_duration);
const srcAudioBlob = srcBlob ?? generateSilenceWav(0);

Copilot uses AI. Check for mistakes.
Comment on lines 11 to 13
* seconds). This file only uploads a tiny placeholder (0.1s at 16kHz mono ≈ 3.2KB).
*/
export function generateSilenceWav(_durationSeconds: number): Blob {
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

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

generateSilenceWav takes a _durationSeconds argument but the implementation ignores it and always generates a fixed 0.1s placeholder WAV. To avoid confusion (especially now that call sites pass meaningful durations), consider removing this parameter from the public API or renaming it to make it explicit that it's unused/placeholder-only.

Suggested change
* seconds). This file only uploads a tiny placeholder (0.1s at 16kHz mono 3.2KB).
*/
export function generateSilenceWav(_durationSeconds: number): Blob {
* seconds). This file only uploads a tiny placeholder (0.1s at 16kHz mono 3.2KB),
* regardless of the provided duration argument.
*
* NOTE: `_placeholderDurationSeconds` is accepted only for API symmetry with other
* audio generators; it is intentionally ignored when constructing the WAV and should
* not be relied upon to control the output duration.
*/
export function generateSilenceWav(_placeholderDurationSeconds: number): Blob {

Copilot uses AI. Check for mistakes.
chuxij added 2 commits March 21, 2026 15:57
Normalized bug reports; see docs/release_task_lego_mapping.md for field semantics.
Address Copilot review: generateSilenceWav always produces a fixed 0.1s
placeholder regardless of arguments. Remove the misleading _durationSeconds
parameter and update all call sites. The actual generation duration is
controlled by audio_duration in the task params (via computeLegoTimingParams).

Made-with: Cursor
@ChuxiJ ChuxiJ closed this Mar 21, 2026
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