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: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BCxXmJVvDFJVHTUi4QgNzi
1 job from dev in 113 minutes and 54 seconds (queued for 8 seconds)
Status Job ID Name Coverage
  Test
failed #4221
test_api

01:53:54

 
Name Stage Failure
failed
test_api Test There has been a timeout failure or the job got stuck. Check your timeout limits or try again
2026-08-06T13:54:04.375175Z 01O tests/test_auth.py ..........                                            [ 18%]
2026-08-06T13:54:06.601975Z 01O tests/test_discovery.py ...... [ 30%]
2026-08-06T13:54:06.949244Z 01O tests/test_library.py ............ [ 52%]
2026-08-06T13:54:07.746221Z 01O tests/test_music.py .... [ 60%]
2026-08-06T13:54:08.028547Z 01O tests/test_remix.py .... [ 67%]
2026-08-06T14:06:18.126798Z 01E Terminated
2026-08-06T13:54:08.170144Z 01O tests/test_remix_engine.py ...
2026-08-06T14:06:19.458986Z 00O
2026-08-06T14:06:19.463131Z 00O+WARNING: step_script could not run to completion because the timeout was exceeded. For more control over job and script timeouts see: https://docs.gitlab.com/ci/runners/configure_runners/#set-script-and-after_script-timeouts
2026-08-06T14:06:28.663403Z 00O ERROR: Job failed: execution took longer than 1h0m0s seconds