-- url: "/home/pln/Downloads/PerfectSunriseLoop.gif"

-- Les Moulins de Mon Cœur — Hiba ∞ ParVagues
-- Montagnes → Ville, nostalgique, le train qui tourne
-- <3

-- ANALYSE ——————————————————————————————————————————
-- Source: Michel Legrand 1968, Hiba voix sur karaoke piano
-- Tonalité : C# mineur (conf. librosa 0.76)
-- Tempo original : ~60 BPM ballade 4/4
-- Ici on joue à 120 BPM → 2 cycles Tidal = 1 mesure vocale d'Hiba
-- → half-time feel sur la voix, broken-beat density côté batterie

-- PROGRESSION ——————————————————————————————————————
-- Couplet A : C#m(1m) ⇄ G#(1m)             (i ⇄ V modal)
-- Couplet B : C#m C# F#m B E A F#m G#      (descente, l'entrée vers le refrain)
-- Refrain  : F#m → B → E → A  spirale       (iv VII III VI, le moulin qui tourne)
-- Sortie   : Cm/C#m/C/C# modulation demi-ton (chanson classique)

-- STRUCTURE (RMS envelope des pistes Hiba) —————————
--  0-60s  Section A  : intro/couplet 1       (adlib3 actif)
--  60-124s Section B : couplet 2, voix seule (adlib2 continue)
--  124-202s Section C: CLIMAX (peak 150s)    (les 3 voix convergent)
--  202-fin Section D : outro (-34s de fleurs adlib)

-- SAMPLES EXPLORÉS ————————————————————————————————
-- Accords C (+1 semitone pour C#m via |+ note 1 ou speed 1.059):
--   nujazz_keys120 : 120_NuPad_Chords_C_1..8   (pads chord)
--                    120_Rhodes_Chords_C_1     (Rhodes plein)
--                    120_Eli_rhodes_chords_C_1..3
--                    120_Wed_synth_licks_C_1..11 (licks mélodiques)
--                    120_Softlead_lick_C_1
--                    120_NuPad_riff_C1/2
-- Directement en tonalité (zéro transpose):
--   QStab_Db       = C# stab (nujazz_stabs)     ← tonique directe
--   QStab_B         = B (VII)
--   QStab_Gb/A/E    = F#/A/E (iv/VI/III)
--   120_Rhodes_Bass_Gb = F# bass (iv)
--   120_Rhodes_Bass_E  = E bass (III)
--   120_Th_Rhodes_E_1..3 / 120_Th_Pad_A_1..4 / EPianoB_120A_1..4
--   120_Hera_riff_4bars1_Eminor  (riff 4-mesures Emin = rel. majeur C#m)
-- Nostalgie :
--   blues_guitar_bluesky_60 / hoochie_60 / misc_60 (à 60 BPM, pulse vocal)
--   rhadamanthe_melo (toujours là, signature maison)

do
-- resetCycles
setcps (120/60/4)
let modIndex = pF "modIndex"

d1 $ gF1 $ gM2 -- Kick, le pas du train qui démarre
  $ midiOn "^42"  (struct "t ~ ~ ~ ~ ~ t ~")   -- half-time feel (60bpm sur 120 Tidal)
  $ midiOff "^42" (struct "t ~ <~ t> ~ ~ ~ t <~ t>") -- broken-beat plus dense
  $ stack [
  "kick" # lpf 10000 # cut 1,
  "jazz" # lpf 200 # cut 11 |* gain 0.9,
  ""
  ]
  # "[kick:3,jazz]"
  # gain 1.35
  # cps ((range 60 180 "^29")/60/4)

d2 $ gF1 $ gM1 -- Clap/snare, contretemps liquide
  $ midiOn "^43" (<| "~ ~ ~ ~ s ~ ~ <~ s*<1 2>>")
  $ midiOff "^43" (<| "~ ~ ~ ~ s ~ ~ ~")
  $ "[snare:24,cp]"
  # gain 1.3

d3 $ gF1 $ gM1 -- Cymbales légères, la brume du matin
  $ midiOn "^44" (<| "~ cy ~ cy ~ cy ~ <cy [~ cy]>")
  $ midiOff "^44" (<| "~!6 <~ <cy ~> cy>")
  $ "cy" # "<cy:1!6 cy:2!2>" # "h2ogmcy"
  |* gain (range 1.0 0.7 perlin)
  |* legato (range 0.5 2 (fast 2 perlin))

d4 $ gF2 $ gM3 -- Basse bassWarsaw, le cœur qui tourne (C#m ⇄ G# puis F#m-B-E-A)
  $ midiOn "^89" (struct "t*16")
  $ midiOn "^57" (struct "t(<3 5 5 7>,8)")
  -- couplet (i⇄V) puis spirale du refrain
  $ note ("<[cs2@7 gs2] [gs1@7 cs2] [cs2@7 gs2] [gs1@7 cs2] [fs1@7 b1] [b1@7 e2] [e2@7 a1] [a1@7 gs1]>")
  # stack [
  "bassWarsaw" # lpf 500,
  "bassWarsaw" # cut 41 # crushbus 41 (range 16 3.5 "^53") # bandf 500 # gain 1.2,
  ""]
  # "cpluck" |+ note 12
  # octerbus 42 (range 0 0.8 "^33")
  -- # octersubbus 43 (range 0 2.5 "^33")
  # cut 41
  # lpf 20000
  # gain 1.35

d5 $ gF3 $ gM3 -- Rhodes/Keys, les moulins qui tournent doucement
  -- sample 120_Rhodes_Chords_C ou _Eli_rhodes_chords_C shiftés +1 pour C#
  $ midiOn "^90" (superimpose ((# cut 51) . (# delay 0.95) . (# delayt 0.125) . (# delayfb 0.7) . (# room 0) . (|* gain 0.8)))
  $ stack [
  midiOn "^58" (# silence) $ slow 2 "<begin ~ begin ~ begin ~ ~ ~>/2" # cut 51 # begin 0 # end 0.4 # pan 0.4,
  midiOn "^58" (# silence) $ slow 2 "<~ mid ~ mid ~ ~ ~ ~>/2" # cut 52 # begin 0.4 # end 0.8 # pan 0.55,
  "<~!24 end!8>" # begin 0.8 # end 1 # cut 53 # gain 0.8 # pan 0.7,
  ""
  ]
  -- Rhodes en C : shift +1 semitone pour atterrir en C#
  # "120_Rhodes_Chords_C:0" |+ note 1
  -- alternatives : "120_NuPad_Chords_C:<0 1 2 3>" |+ note 1  ← pad 8-variations
  --                "120_Eli_rhodes_chords_C:<0 1 2>" |+ note 1
  # crushbus 51 (range 16 2.7 "^54")
  # room 0.45
  # gain 1.3

d7 $ gF3 $ gM3 -- Violoncelle / Guitare blues, la mémoire du voyage
  -- blues_guitar_*_60 = 60 BPM donc loopAt 0.5 pour revenir à 120
  $ midiOn "^59" (# silence)
  $ loopAt 0.5
  $ chop 8
  $ "<blues_guitar_misc_60:0 blues_guitar_bluesky_60:0 blues_guitar_hoochie_60:0 blues_guitar_misc_60:1>"
  # cut 7
  # hpf 200
  # room 0.5 # sz 0.6
  # gain 1.0

d8 $ gF1 $ gM1 -- Break, le train qui cogne les rails
  $ midiOn "^60" (mask "t(4,8,<1!3 0>)" . chop 8)
  $ midiOn "^36" (id . (loopAt 0.5 . (# "jungle_breaks:130")))
  $ midiOn "^92" (mask "t(16,32)" . ply "2 2 <4 8 16 16> 2")
  $ midiOn "^56" (loopAt 2 . (# n 12))
  $ chop 16
  $ loopAt 2
  $ "jungle_breaks:1" # cut 8
  # gain 1.35

d9 $ gF3 $ gM3 -- Pad rhadamanthe, la brume de la vallée
  -- notes suivent la progression couplet/refrain en C#m
  $ note ("<cs4 gs3 cs4 gs3 fs3 b3 e4 a3>/2" - 12)
  # "rhadamanthe_melo:4"
  # legato 4
  # rel 2
  # sus 2
  # room 0.6 # sz 0.7 # lpf 2000
  # gain 1.1

d10 -- Risers, les moments de bascule (section B→C, C→D)
  $ mask "<f!24 t!8>"
  $ loopAt 8
  $ "risers"
  # cut 10
  # room 0.4
  # dry 1.4
  # octersubsub 0.5
  # gain 0.8

d11 $ gF3 $ gM3 -- Intro texture, le calme avant le départ
  -- stab QStab_Db = C# direct, pas de transpose
  -- alternative : "120_Th_Stabs_C1" # speed 1.059 pour C#
  $ gF3
  $ whenmod 8 6 (slice 2 "0*2")
  $ chop 8
  $ "QStab_Db"
  # cut 11
  # room 0.7 # sz 0.7 # dry 1
  # delaybus 111 "^30"
  # delayt ("<2!3 3>"/3)
  # delayfb 0.5
  # gain 1.2

d12 $ gF1 $ gM1 $ "hh(3,8) hh(3,8)" # "h2ogmhh"

-- BOUTONS (convention LaunchControl XL) ——————————————
-- ^41 = gMask (gate syncopé, fill fantôme)
-- ^42/43/44 = variations kick/snare/hat
-- ^57 = basse euclidienne
-- ^58 = mute Rhodes (silence piano)
-- ^59 = mute blues guitar
-- ^60 = break mask+chop
-- ^36/56/92 = variantes de breaks (jungle_breaks superposés)
-- ^73/74/75 = mute 1/2/3
-- ^89/90 = intensifs basse/piano (struct 16 / delay wall)
-- ^29 = kick speed CC
-- ^30 = delay intro
-- ^33 = octerbus basse
-- ^53/54 = crushbus basse/piano
