-- ============================================================
-- COPYCAT: NTO - La Clé des Champs (2016)
-- Algoraoke by ParVagues
-- ============================================================
--
-- TRACK INFO
-- ==========
-- Artist: NTO (Anthony Favier), Hungry Music (HM17)
-- Release: Sept 30, 2016 | Duration: 6:56
-- BPM: 120 (Spotify/Tunebat) — Beatport says 113, adjust to taste
-- Key: Bb minor (harmonic minor dominant) | Camelot 3A
-- Genre: Deep house / melodic house
--
-- HARMONIC ANALYSIS (chordu.com + demucs htdemucs_6s spectral)
-- =============================================================
-- Key: Bb natural minor (Bb C Db Eb F Gb Ab)
--      with harmonic minor dominant (F major → raised 7th = A natural)
--
-- Chords (Bb harmonic minor):
--   i   Bbm  = Bb Db F    — tonic, home base
--   V   F    = F  A  C    — dominant (harmonic minor), V→i cadence engine
--   III Db   = Db F  Ab   — relative major, extended sections
--   iv  Ebm  = Eb Gb Bb   — subdominant, tension before resolution
--   VI  Gb                 — brief appearances
--
-- Primary vamp: Bbm | F alternating (2 bars each)
-- Extended: Bbm | F | Bbm | F | Bbm | F | Db | Ebm (16-bar cycle)
--
-- DEMUCS SPECTRAL EVIDENCE (htdemucs_6s, 15s/5s overlap segments)
-- ================================================================
-- Source: ~/Downloads/N'to - La Clé Des Champs [qd_8mm906GA].mp4
--
-- BASS stem (pyin pitch tracking across all segments):
--   Bb1=58Hz (~45% of frames) + F2=88Hz (~30%) = sustained 2-bar alternation
--   Chromatic slide transitions: Bb1→Ab1→F2 (descending), F2→C#2→Bb1 (ascending)
--   Eb2=78Hz for iv (Ebm) sections, F1=44Hz sub-octave in later segments
--   A2 NEVER appears — bass is Bb1↔F2 vamp, NOT V chord arpeggio
--   Bass deepens over time: F2 → F1 in segments 250s+
--
-- PIANO stem: enters ~40-50s, peaks ~90-100s
--   237Hz (Bb3) dominant, 53% low + 47% mid
--   → Rhodes-style chord stabs in Bb3-F4 range (low-mid, not high)
--
-- GUITAR stem (= arp synth, demucs mislabel):
--   172Hz (F3) dominant, peaks at 100-120s and 250s
--   → Mid-range synth arp, NOT the bass register
--
-- OTHER stem (= pad/atmosphere):
--   226Hz (~Bb3) dominant early, shifts to 345-560Hz later
--   → Pad evolves: low-mid warmth → brighter harmonics over time
--
-- MIDI TRANSCRIPTION (Nto- la cle des champs .mid)
-- =================================================
-- Arp: Bb4↔F4 16th alternation (Bb on downbeats), same notes over both
--      Bbm and F chords (context changes beneath). Eb4↔Gb4 for Ebm.
--      Note order does NOT flip between chords — Bb stays on top.
-- Kick: Offbeat syncopated pattern (NOT straight 4otf throughout)
--
-- ARRANGEMENT (demucs segment timeline)
-- ======================================
-- 0-10s:   Pad only (other stem: Bb3, rms=0.07)
-- 10-30s:  Bass enters (86Hz/F2, rms=0.19-0.26), pad continues
-- 30-50s:  Arp synth fades in (guitar stem: 172-183Hz), piano first stabs
-- 40-50s:  KICK enters — 8th note pulse, kick only, no hats yet
-- 60s:     OH enters on upbeat 8ths (warm, centroid 4000Hz)
-- 70-80s:  Full groove: K↑OH alternating 8ths, OH brightening (→4900Hz)
-- 90s:     Pre-drop: kick gets ghost DOUBLES, OH→ride brightness (→7700Hz)
-- 90s bar4: KICK DROPS OUT — pure cymbal shimmer (centroid 8200Hz, QUIET)
-- 100-120s: Cymbal break — whisper-quiet shimmer on upbeat 8ths only
-- 150s:    Kick returns + OH-mid (centroid 6000Hz), groove restored
-- 200s+:   Full: kick + bright OH/ride + CLAP on beats 1&3 (contretemps)
--
-- DRUM VOICES (demucs onset + envelope analysis)
-- ================================================
-- KICK: dom=86Hz, sub=58-70%, att=48-56ms (SLOW round thud), dec=3ms
--   No click, no snap. Gets DEEPER over time (centroid 1100→200Hz).
--   Pattern: 8th notes on every downbeat eighth. Ghost doubles pre-drop.
--
-- OPEN HAT → CYMBAL (one evolving voice, not separate samples):
--   centroid evolves: 4000Hz(warm) → 4900(bright) → 8400Hz(shimmer)
--   Groove: peak=0.55-0.61, att=38-42ms, on every upbeat 8th
--   Breakdown: peak=0.05-0.07 (QUIET whisper!), att=7-10ms (tick)
--   Post-drop: peak=0.62, centroid 6000-7200Hz (bright ride character)
--
-- CLAP: enters at climax (~200s), contretemps (beats 1&3)
--   peak=0.13 (quiet accent!), att=10ms, dec=12ms, dom=1292Hz
--   Dry thin mid-snap. Not a fat backbeat — more rimshot/finger snap.
--
-- SOUND DESIGN
-- ============
-- KICK:     Round sub thud (att 50ms!), 8th pulse. Gets deeper over time.
-- BASS:     F2/A2/C2 (V chord tones only!). Rhythmic, not held notes.
-- ARPEGGIO: 2-note 16th Bb4↔F4, FM synth. Magic = timbre not notes.
-- PIANO:    Rapid A3/F3 repeated stabs (16th-ish), sparse, enters ~40s.
-- PAD:      ~Bb3 warm bed, evolves brighter. Generous reverb, slow filter.
-- OH/CY:    One voice that brightens: warm OH → bright ride → shimmer.
-- CLAP:     Late entry (~200s), contretemps, dry quiet mid-snap.
--
-- NTO'S KNOWN GEAR:
--   Moog Subsequent 37, Arturia MicroFreak, Akai APC40 MKII,
--   Novation Impulse 49, DJ Tech Tools MIDI Fighter Twister
--
-- PRODUCTION STYLE (from interviews):
--   "I love the 'human side' of electronic music."
--   "Deep basses and lysergic harmonies"
--   Often asks real musicians to replay software melodies for organic feel
--   Influences: Stephan Bodzin, James Holden, Paul Kalkbrenner
-- ============================================================

do
setcps (120/60/4)
-- resetCycles
let gMute = (midiOn "^73" (mask "f*16"))
let gM = gMask . gMute
-- Harmonic foundation: 16-bar cycle (each chord = 2 bars)
-- Main Bbm/F vamp with Db/Ebm variation
-- pyin evidence: bass = sustained Bb1(58Hz)↔F2(88Hz), Eb2 for iv, chromatic slides
let rt = slow 2 "<bf2 f2 bf2 f2 bf2 f2 df2 ef2>" -- root sequence (for d6 piano, pad, etc)
d1 $ gF1 $ gMute2 -- KICK: Sub thud, 4otf with flourish (NTO: deepens over time)
  $ midiOn  "^42" (<| "k k k <k k*2 k [~ k]>") -- ON: 4otf + flourish variations
  $ midiOff "^42" (<| "k ~ ~ <~!3 k>") -- OFF: sparse intro
  $ sometimesBy "^29" ( -- ^29: ghost doubles (pre-drop energy)
    superimpose (("0.07" <~) . (|* gain 0.7))
    )
  $ "[techno:0,808bd:2]"
  # lpf (slow 32 $ range 4000 1500 saw) -- 32-bar: kick click present, darkens over time
  # room (slow 32 $ range 0 0.15 saw) -- 32-bar: tiny room growth
  # gain 1.8
d2 $ gF1 $ gM -- CLAP: Dry quiet snap, contretemps (enters late)
  -- NTO: peak=0.13 (QUIET!), att=10ms, dom=1292Hz, 0% sub, beats 1&3
  $ midiOn "^43" (<| "cp ~ cp ~") -- ON: contretemps (NTO climax)
  $ midiOff "^43" (<| "~ cp ~ <~ cp*<1 2>>") -- OFF: backbeat (our touch)
  $ sometimesBy "^30" ( -- ^30: flam probability
    superimpose (("e" <~) . (|* gain 0.6))
    )
  $ "h2ogmcp"
  # hpf 800 # lpf 4000 -- pure mid-snap, no sub
  # room 0.1 # dry 1.5 -- very dry
  # gain (slow 32 $ range 0.8 1.2 saw) -- 32-bar: clap grows into the mix
  # pan 0.55
d3 $ gF1 $ gM -- OH/CY: Subtle offbeat hats, ^44 morphs to cymbal shimmer
  -- NTO: OH on upbeats, centroid brightens 4000→8400Hz. Breakdown = quiet cymbal.
  $ midiOn "^76" (stut 3 0.6 "s") -- push: rolls
  $ midiOn "^44" ( -- ON: cymbal shimmer (quiet, bright, breakdown character)
    (|* gain 0.94) . (# legato 0.2) . (# "h2ogmcy:1") . (# hpf 5000)
    )
  -- $ midiOff "^44" (mask "t(3,8)") -- OFF: sparse euclidean (subtle)
  $ sometimesBy "^32" (ply "<2!3 [2 4]>") -- ^32: roll probability
  $ "~ h ~ h ~ h ~ <h!3 h*2>" -- offbeat pattern with flourish
  # "h2ogmhh"
  # n "~ 3 ~ 2 ~ 4 ~ <3!3 [3 6]>" -- varying openness per hit
  # legato (range 0.2 0.9 "^52") -- ^52: tightness
  # cut "~ 3 ~ 3 ~ 3 ~ <3!3 [3 0]>" -- last hit: cut 0 = rings over bar boundary
  # room (slow 32 $ range 0.2 0.45 saw) -- 32-bar: space grows (NOT dry!)
  # sz (slow 32 $ range 0.1 0.3 saw) -- 32-bar: tail lengthens
  # dry 1
  # pan 0.42
  # gain (slow 32 $ range 1.3 1.6 saw * "0.7 0.8 0.65 [0.75|0.85] 0.69 0.8 ~ <0.9!3 [0.9 0.5]>")
  -- 32-bar swell * per-hit velocity (the original subtle dynamics)
d4 $ gF2 $ gM3 -- BASS: Sustained Bb1↔F2 alternation with chromatic slides
  -- pyin analysis: Bb1 (58Hz, ~45%) + F2 (88Hz, ~30%) = 2 main notes
  -- 2-bar holds, chromatic slide transitions (Ab1→F2, C#2→Bb1)
  -- Eb2 for iv chord, F1 sub-octave in later segments (bass deepens)
  -- A2 NEVER appears — prior "V chord arp" was wrong
  $ midiOn "^57" ( -- state: sub-octave layer (NTO later segments)
    superimpose ((|+ note (-12)) . (|* gain 0.6) . (# legato 2))
    )
  $ midiOn "^89" (struct "[t, [~ t t ~. <t(3,8) t*[2 <2 4>]>]]") -- push: wild mode
  $ note (
    slow 2 $ "<[bf1@7 af1] [f2@7 af1] [bf1@7 af1] [f2@7 af1] [bf1@7 af1] [f2@7 af1] [df2@7 c2] [ef2@7 df2]>"
    )
  # "bassWarsaw"
  # dec 0.3 # sus 0.8 # legato 2
  # octersubbus 41 (range 0 2.5 "^53") -- ^53: sub-octave depth
  # crushbus 42 (range 16 3 "^33") -- ^33: grit
  # room (slow 32 $ range 0.05 0.2 saw) -- 32-bar: bass space opens up
  # gain 1.3
d5 $ gF3 $ gM3 -- ARPEGGIO: 2-note 16th, evolves over sections (demucs guitar stem)
  -- demucs: F3/F4 base, Bb3/A3 mid-sections, Gb4 in Ebm, E4 at breakdown
  $ midiOn "^90" (stut 4 0.5 "e") -- push: stutter
  $ midiOn "^58" ( -- state ON: 2x speed layer (the real NTO arp tempo!)
     (fast 2 . (|* gain 0.8) . (|+ pan 0.15) . (# room 0.3))
    )
  $ sometimesBy (1 - "^18") (mask "<t(11,16) t(13,16) t(14,16) t(15,16)>") -- breathes
  $ note ( -- 16-bar: Bb/F anchor, A3/C4 variations, Eb/Gb for Ebm (demucs)
    slow 2 $ "<[bf4 f4]*8 [bf4 f4]*8 [a3 f4]*8 [bf4 f4]*8 [a3 c4]*8 [bf4 f4]*8 [ef4 gf4]*8 [ef4 gf4]*8>"
    )
  # "FMRhodes1"
  # modIndex (range 0.5 8 "^34") -- ^34: FM depth (timbre IS the magic)
  # crushbus 51 (range 15 4.2 "^54") -- ^54: bitcrush
  # lpfbus 52 (slow 8 $ range 800 6000 sine) -- 4-bar: filter breath
  # room (slow 32 $ range 0.2 0.5 saw) -- 32-bar: arp opens into space
  # sz (slow 32 $ range 0.3 0.7 saw) -- 32-bar: reverb tail grows
  # dry 1.2
  # legato 0.5
  # pan 0.6
  # gain 1.9
d9 $ gF2 $ gM3 -- PAD: Warm evolving harmonic bed
  $ note (
    slow 2 $ cat [
      "[bf4,df5,f5]", "[f4,a4,c5]",
      "[bf4,df5,f5]", "[f4,a4,c5]",
      "[bf4,df5,f5]", "[f4,a4,c5]",
      "[df4,f4,af4]", "[ef4,gf4,bf4]"
    ])
  # "90s_synatm:8" -- n8=pure warm low (99.7% low, 0% hi). Alt: n23(longer), n33(warm+long)
  # lpf (slow 32 $ range 1200 6000 saw) -- 32-bar: pad opens from warm to bright
  # room 0.6 # sz 0.8 # dry 0.9
  # legato 4
  # pan 0.4
  -- # cut 9
  # gain (slow 32 $ range 0.7 1.4 saw) -- 32-bar: pad swells gently
d6 $ gF2 $ gM3 -- PIANO: Sustained Rhodes chords (demucs: Bb3/A3/F3, enters ~40s)
  -- ^31: modIndex sweep (more harmonics = more presence)
  $ note (
    slow 2 $ "<[bf3,f4] [a3,f4] [bf3,f4] [a3,c4] [bf3,f4] [a3,f4] [af3,df4] [gf3,bf3]>"
    )
  # "FMRhodes1"
  # modIndex (range 0.8 4 "^31") -- ^31: knob sweeps harmonic richness
  # room 0.3 # sz 0.4 # dry 1
  # legato 4 -- long sustained chords, not stabs
  # pan 0.5
  # gain 1.6
d7 $ gF3 $ gMute3 -- CELLO: Rhythmic bowed answer, tighter complement to bass
  $ midiOn "^91" (ply 2) -- push: doubles for urgency
  $ midiOn "^59" ((|* gain 1.2) . (# "[cpluck:6,cpluck:7]")) -- state ON: pizzicato
  $ midiOff "^59" (struct "t@3 [t t t] ~ ~") -- OFF: rhythmic bow, answer on beat 3
  $ note ( -- mirrors bass Bb↔F vamp, one octave up, with answer phrase
    slow 2 $ "<[bf2@3 [af2 f2 bf2] ~ ~] [f3@3 [af2 bf2 f3] ~ ~] [bf2@3 [af2 f2 bf2] ~ ~] [f3@3 [af2 bf2 f3] ~ ~] [bf2@3 [af2 f2 bf2] ~ ~] [f3@3 [af2 bf2 f3] ~ ~] [df3@3 [c3 df3 ef3] ~ ~] [ef3@3 [df3 bf2 ef3] ~ ~]>"
    )
  # "cbow:2"
  # crushbus 71 (range 16 2.5 "^55") -- ^55: grit
  # room 0.25 # sz 0.3 -- tighter space (less ambient wash)
  # legato 1.2 -- shorter bow strokes
  # pan 0.8
  # gain (slow 32 $ range 0.9 1.2 saw) -- 32-bar: presence grows
d8 $ gF1 $ gM1 -- BREAKS: Full jungle break treatment
  $ midiOn "^92" (ply "1 <2!3 4>") -- push: fill/ply
  $ midiOff "^60" (mask "t(4,8,1)") -- state OFF: sparse techno mask
  $ midiOn "^36" (loopAt 1 . (# "jungle_breaks:74")) -- mid knob: alt break A
  $ midiOn "^56" (loopAt 1 . (# "jungle_breaks:19")) -- mid knob: alt break B
  $ chop 16
  $ loopAt 2
  $ "jungle_breaks:42"
  # cut 8
  # gain 1.5
  # room (slow 8 $ range 0 0.3 perlin)
  # sz 0.05
  # pan 0.74
d10 -- RISER: Transition sweeps
  $ struct "<~!14 t ~>"
  $ "risers:8" # speed 0.25
  # room 0.5 # sz 0.9
  # cut 10
  # gain 0.6
