adaptive-stem-alignment
What it does
This skill is a workflow for making a master audio track with separate stems, checking each piece as it goes. It is for music producers and people building audio with AI tools.
When to use it
- ✓When I am making a full track with several stems that must line up in length.
- ✓When stems come out with different lengths and need to be extended or aligned.
- ✓When I want to check every audio file before exporting the final mix.
Skill link
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/audio-track-production-enhanced-enhanced-b8f537/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“I want to build a full song with drums, bass and vocal stems that all match the reference length. Can you guide me?”
5 new skills a week. 1 minute to read.
How it works
The AI calculates timing from the tempo and length, checks the reference file, makes each stem one at a time, fixes length differences, and only then mixes and exports.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Adaptive Stem Alignment Workflow
This skill provides a resilient pattern for audio production that emphasizes incremental verification, fail-fast principles, and adaptive duration handling. Each major step produces verified outputs before proceeding, with explicit strategies for handling stems of different durations.
Overview
Follow these steps in strict order. Each step must complete successfully and pass verification before proceeding to the next:
- Early timing calculation - Derive section transitions from BPM and duration first
- Verify reference audio - Validate input file properties and establish target duration
- Generate and verify each stem individually - One stem at a time with immediate verification
- Generate drum stem separately - Dedicated drum extension with rhythm patterns
- Align stem durations - Handle duration mismatches with adaptive extension strategies
- Apply effects with verification - Process each stem and verify output
- Export master track - Mix all verified stems
- Archive and final verification - Package deliverables with comprehensive checks
Key Differences from Standard Workflow
- Incremental verification: Verify each stem immediately after generation, not just at the end
- Fail-fast approach: Stop and report errors at each step rather than accumulating failures
- Early timing: Calculate section transitions before any audio generation
- Separated drums: Drum stem generation is a distinct step with rhythm-specific processing
- Memory-efficient: Process stems individually to avoid large array operations that cause sandbox failures
- Adaptive duration handling: Explicit strategies for mismatched stem durations (zero-padding, looping, crossfade extension)
- Pre-mix alignment: Verify all stems match target duration before mixing
Step 1: Calculate Timing Parameters (Early)
Calculate all timing parameters before generating any audio. This ensures consistent timing across all stems:
def calculate_section_transitions(bpm, total_duration_sec, sections):
"""Calculate beat-aligned transition points for song sections."""
beats_per_second = bpm / 60.0
section_durations = {}
cumulative_time = 0
for section_name, beat_count in sections.items():
duration = beat_count / beats_per_second
section_durations[section_name] = {
'start': cumulative_time,
'end': cumulative_time + duration,
'beats': beat_count,
'start_beat': cumulative_time * beats_per_second
}
cumulative_time += duration
return section_durations
# Configuration
BPM = 120
DURATION = 137
SECTIONS = {'intro': 16, 'verse': 32, 'chorus': 32, 'bridge': 16, 'outro': 16}
timing = calculate_section_transitions(BPM, DURATION, SECTIONS)
print("Timing calculated:")
for section, data in timing.items():
print(f" {section}: {data['start']:.2f}s - {data['end']:.2f}s ({data['beats']} beats)")
Step 2: Verify Reference Audio
Validate the reference file exists and has expected properties:
import soundfile as sf
import os
def verify_reference_file(filepath, expected_sample_rate=None, min_duration=None):
"""Verify reference audio file and return info dict."""
if not os.path.exists(filepath):
raise FileNotFoundError(f"Reference file not found: {filepath}")
info = sf.info(filepath)
errors = []
if expected_sample_rate and info.samplerate != expected_sample_rate:
errors.append(f"Sample rate mismatch: expected {expected_sample_rate}, got {info.samplerate}")
if min_duration and info.duration < min_duration:
errors.append(f"Duration too short: expected >= {min_duration}s, got {info.duration}s")
if errors:
raise ValueError(f"Reference file validation failed: {'; '.join(errors)}")
print(f"Reference verified: {info.duration:.2f}s @ {info.samplerate}Hz, {info.channels}ch, {info.subtype}")
return {
'sample_rate': info.samplerate,
'duration': info.duration,
'channels': info.channels,
'subtype': info.subtype
}
# Verify reference
ref_info = verify_reference_file('reference.wav', expected_sample_rate=48000, min_duration=130)
TARGET_DURATION = ref_info['duration'] # Use reference duration as target
Step 3: Generate and Verify Each Stem Individually
Generate one stem at a time, verify it imm
FAQ
What is a stem?
A stem is a separate audio part of a song, such as the drums or the vocals.
Why check each stem separately?
Checking early catches errors before they are mixed together, which saves rework.
What tools does it use?
The examples use Python audio libraries, so those need to be available on your computer.
Details
Original description by the author
Incremental audio production with duration mismatch handling, adaptive stem extension, and pre-mix alignment verification
repo: HKUDS/AgentPilot
Popularity
- GitHub stars
- 7.8k
- Ranking position
- #12838
- License
- MIT
- Updated
- 11/1/2026
Comments
- …
More skills from this repository
agentpilot
7.8kHelps your agent improve a project step by step by preparing a task and running the AgentPilot loop that proposes, tests and scores changes.
openspace
7.8kHelps your agent set up OpenSpace, a tool that stores and fetches agent skills, and connect it to your AI app through MCP.
rsi-arena
7.8kHelps your agent set up and run standard AI benchmark tests, such as AIME and Terminal-Bench, to compare different improvement methods.
experiment-guide
7.8kHelps your agent plan small experiments, read their results and record findings while it investigates how to improve a program.
Similar skills
openai-whisper-api
394kLets your agent turn an audio recording into text using OpenAI's transcription service, with options for speaker labels and output files.
openai-whisper
394kHelps your agent transcribe audio on your own computer with the Whisper command, with no API key and no cloud upload needed.
sag
394kHelps your agent read text aloud with ElevenLabs voices and play the result on your computer, with tips for pronunciation and expression.