Commit b1eab28c authored by Aryan Noshirvani's avatar Aryan Noshirvani

Real creative transformation: key matching, sections, sidechain, style

The old engine picked stems and slapped a static reverb+compressor on
top for the full duration - "change pitch and speed and call it a
day," per the ask. This is a genuine rewrite of the DSP core:

- Real key detection (Krumhansl-Kessler chroma-profile correlation)
  replaces AI-guessed pitch shifts. Semitone shifts are now computed
  from actual detected keys, so combined stems from different songs
  are harmonically correct instead of an arbitrary number the model
  picked with no data behind it.
- Section-based arrangement: the plan now describes real structure
  (intro/build/drop/etc.) with different stems active per section
  instead of one static combination playing for the whole duration.
  Every stem is stretched/pitch-matched once and cached in memory;
  sections slice and sum from that shared pool with short crossfades
  at boundaries.
- Sidechain ducking: one song's drums can rhythmically duck everything
  else (the "pump" that makes a mix actually groove), via a vectorized
  lowpass-filtered envelope follower - not a per-sample Python loop,
  which would be far too slow on this CPU's unaccelerated math.
- Style presets (lofi/trap/house) apply genre-appropriate processing
  chains instead of one generic effects chain for every request.

Two-step AI pipeline, split by what each model actually can/can't do:
Gemini listens to a real audio preview of each song and writes a text
description (mood, energy, instrumentation) - Claude's API has no
audio input at all, so this is the only way it gets that context.
Claude then takes those descriptions plus real BPM/key data and the
user's prompt and directs the actual arrangement: sections, target
key, sidechain routing, style. Perception on Gemini, instruction-
following and structured reasoning on Claude - not asking one model
to do both.

Needs ANTHROPIC_API_KEY to actually run plan_remix - not yet set in
this environment, so the full pipeline is implemented and unit-tested
but not yet verified end-to-end. All DSP pieces (key detection,
semitone math, sidechain envelope, tiling) have deterministic unit
tests against a committed fixture (tests/fixtures/tone.wav, plain
numpy+soundfile, no ffmpeg dependency).
Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BCxXmJVvDFJVHTUi4QgNzi
parent 83b9fafc
Pipeline #995 failed with stage
in 113 minutes and 54 seconds