mcp_opendaw_detect_key
Detect the key and mode of a WAV file using chroma analysis, enabling automatic harmonic arrangement generation for remix pipelines.
Instructions
Detect musical key and mode of a WAV file using chroma features + Krumhansl-Schmuckler key profiles.
Pure Python implementation (no external dependencies):
Parse WAV → mono mixdown
Short-time FFT (4096-point, Hann window, 75% overlap) — pure Python radix-2 Cooley-Tukey
Map spectral bins to 12 pitch classes → chroma vector
Correlate chroma with major/minor key profiles for all 24 keys (12 roots × 2 modes)
Best correlation → key + mode
Essential for Suno integration: detect key → build matching chord progression → create_harmonic_arrangement that fits the imported audio. Enables automatic remix pipeline: download → detect_bpm → detect_key → import → generate matching harmony → mix → render.
filename: Name of the WAV file in the exports directory (without path), or absolute path to any WAV file.
Returns: key (e.g. "A"), mode ("major"/"minor"), confidence (0-1), correlation, alternatives (top 3), chroma (12-element list).
Examples:
After importing a Suno track
result = detect_key("suno_track.wav")
→ {key: "A", mode: "minor", confidence: 0.72, ...}
Then build matching progression
create_chord_progression([["Am","G","F","E7"]])
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filename | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |