faustwave 0.93.1 → 0.94.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -44
- package/dist/npm/faustwave.mjs +73 -18
- package/dist/npm/pagekit/pagekit.js +2347 -0
- package/dist/npm/pagekit/parts/device-button.glb +0 -0
- package/dist/npm/pagekit/parts/device-fader.glb +0 -0
- package/dist/npm/pagekit/parts/device-knob.glb +0 -0
- package/dist/npm/pagekit/parts/device-meter.glb +0 -0
- package/dist/npm/pagekit/parts/device-panel.glb +0 -0
- package/dist/npm/pagekit/parts/models-provenance.json +46 -0
- package/dist/npm/pagekit/player/THIRD-PARTY-NOTICES.md +12358 -0
- package/dist/npm/pagekit/player/assets/AppView-BV9Obknn.js +1 -0
- package/dist/npm/pagekit/player/assets/AppView-CdET0bgZ.css +1 -0
- package/dist/npm/pagekit/player/assets/FontLoader-C8xh6Irz.js +64 -0
- package/dist/npm/pagekit/player/assets/StageView-CSu--ASd.css +1 -0
- package/dist/npm/pagekit/player/assets/StageView-_SwGWnwx.js +1 -0
- package/dist/npm/pagekit/player/assets/actionRegistry-DrQhww6a.js +1 -0
- package/dist/npm/pagekit/player/assets/actionRegistry-hOkUYNvI.js +1 -0
- package/dist/npm/pagekit/player/assets/ahead-BNQHG1e8.js +1 -0
- package/dist/npm/pagekit/player/assets/api-BrGhAVvb.js +1 -0
- package/dist/npm/pagekit/player/assets/autoLayout-C5ue2K3x.js +1 -0
- package/dist/npm/pagekit/player/assets/bundledSources-2GoXdU5z.js +1 -0
- package/dist/npm/pagekit/player/assets/clapModule-CB6_36hc.js +1 -0
- package/dist/npm/pagekit/player/assets/client-DksDHYQL.js +1 -0
- package/dist/npm/pagekit/player/assets/codeEditorBridge-Bl202hrO.js +1 -0
- package/dist/npm/pagekit/player/assets/disclose-version-BvIhFN19.js +1 -0
- package/dist/npm/pagekit/player/assets/dist-BvRk9kiK.js +0 -0
- package/dist/npm/pagekit/player/assets/dist-DfaMbR-1.js +1 -0
- package/dist/npm/pagekit/player/assets/engine.worklet-BTB8yjdk.js +1865 -0
- package/dist/npm/pagekit/player/assets/engineCost.worker-Cv0PY3S-.js +2167 -0
- package/dist/npm/pagekit/player/assets/errors-BdUU2zPt.js +1 -0
- package/dist/npm/pagekit/player/assets/faust-analysis.nodepack-Bg1ixSAB.js +1 -0
- package/dist/npm/pagekit/player/assets/faust-physical-models.nodepack-DxbqTZII.js +1 -0
- package/dist/npm/pagekit/player/assets/faust-reverbs.nodepack-c-ZIKLrJ.js +1 -0
- package/dist/npm/pagekit/player/assets/faust-spatial.nodepack-C6GwVzOM.js +1 -0
- package/dist/npm/pagekit/player/assets/faust-vintage.nodepack-D8g5LX-U.js +1 -0
- package/dist/npm/pagekit/player/assets/faust.nodepack-Do7P1z0H.js +1 -0
- package/dist/npm/pagekit/player/assets/faustSource-Blr9zzKL.js +1 -0
- package/dist/npm/pagekit/player/assets/faustwasm-webclap-double-BX3OrOpF.js +1 -0
- package/dist/npm/pagekit/player/assets/faustwasm-webclap-double-Drn3DiHA.wasm +0 -0
- package/dist/npm/pagekit/player/assets/faustwasm.js +1 -0
- package/dist/npm/pagekit/player/assets/faustwave-conventions.nodepack-D2jA38Q6.js +1 -0
- package/dist/npm/pagekit/player/assets/fileMirror-CkgB9zNS.js +1 -0
- package/dist/npm/pagekit/player/assets/fileRef-BmnWhXuY.js +1 -0
- package/dist/npm/pagekit/player/assets/host-DPIuYxlL.js +1 -0
- package/dist/npm/pagekit/player/assets/instantiate-Dh0T46aH.js +1 -0
- package/dist/npm/pagekit/player/assets/inter-500.typeface-B6jxeZL_.js +21 -0
- package/dist/npm/pagekit/player/assets/inter-700.typeface-COCE0d_R.js +21 -0
- package/dist/npm/pagekit/player/assets/kernel-BErAMnKr.js +1 -0
- package/dist/npm/pagekit/player/assets/kernel-D6spGIFh.js +1 -0
- package/dist/npm/pagekit/player/assets/kernel-DKiI3Wqx.js +2 -0
- package/dist/npm/pagekit/player/assets/kit--nsV_OZy.js +1 -0
- package/dist/npm/pagekit/player/assets/kit-vVQ5cDnW.css +1 -0
- package/dist/npm/pagekit/player/assets/lazy-BkjipY-3.css +1 -0
- package/dist/npm/pagekit/player/assets/lazy-ClEpU-Ev.js +1 -0
- package/dist/npm/pagekit/player/assets/libraryFacts-B_z-Kv6i.js +1 -0
- package/dist/npm/pagekit/player/assets/mono-500.typeface-CuX9Pbhu.js +21 -0
- package/dist/npm/pagekit/player/assets/mono-700.typeface-BpIQdJao.js +21 -0
- package/dist/npm/pagekit/player/assets/newId-DuoSrkVn.js +1 -0
- package/dist/npm/pagekit/player/assets/notes-D-zF5qJ1.js +1 -0
- package/dist/npm/pagekit/player/assets/opfsStore-CXd1Yz_2.js +1 -0
- package/dist/npm/pagekit/player/assets/panic-ckha9YOX.js +1 -0
- package/dist/npm/pagekit/player/assets/patchSnippets-Dsccmpj6.js +1 -0
- package/dist/npm/pagekit/player/assets/paths-DFjX1bFA.js +1 -0
- package/dist/npm/pagekit/player/assets/player-CgcvekqS.js +2 -0
- package/dist/npm/pagekit/player/assets/playerApp-BmyTSXxw.js +2 -0
- package/dist/npm/pagekit/player/assets/playerApp-DO80EIpx.css +1 -0
- package/dist/npm/pagekit/player/assets/preArm-ifXM2Buj.js +1 -0
- package/dist/npm/pagekit/player/assets/preload-helper-9MKZsTCd.js +1 -0
- package/dist/npm/pagekit/player/assets/projectFiles-BEdLy3nE.js +1 -0
- package/dist/npm/pagekit/player/assets/projectPicker-mteZ2tiI.js +1 -0
- package/dist/npm/pagekit/player/assets/rocket-CgRnlVoE.js +1 -0
- package/dist/npm/pagekit/player/assets/runtime-36oA_YiG.js +1 -0
- package/dist/npm/pagekit/player/assets/runtime-7lvdeERt.js +1 -0
- package/dist/npm/pagekit/player/assets/runtime-BNLxaYPi.js +2 -0
- package/dist/npm/pagekit/player/assets/runtime-CL1M0Epi.js +1 -0
- package/dist/npm/pagekit/player/assets/runtime-bQsuRbRM.js +2 -0
- package/dist/npm/pagekit/player/assets/runtime-vj8wKnnG.js +1 -0
- package/dist/npm/pagekit/player/assets/runtime-wuc1seO8.js +1 -0
- package/dist/npm/pagekit/player/assets/scale-D2nqiPek.js +1 -0
- package/dist/npm/pagekit/player/assets/sha256-B9lHpAF4.js +1 -0
- package/dist/npm/pagekit/player/assets/soundfiles-DMZ8HKDZ.js +1 -0
- package/dist/npm/pagekit/player/assets/src-BvHr5YSH.js +2 -0
- package/dist/npm/pagekit/player/assets/src-Co7ihhBK.js +1 -0
- package/dist/npm/pagekit/player/assets/src-DyDfRe65.js +1 -0
- package/dist/npm/pagekit/player/assets/src-LMfGAjlj.js +1 -0
- package/dist/npm/pagekit/player/assets/stageWorker-ggqqFf5m.js +20869 -0
- package/dist/npm/pagekit/player/assets/store-CJdayqZa.js +1 -0
- package/dist/npm/pagekit/player/assets/sun-Bi-OgPry.js +1 -0
- package/dist/npm/pagekit/player/assets/time-aboh42pX.js +1 -0
- package/dist/npm/pagekit/player/assets/toasts-BCcM1yGS.js +1 -0
- package/dist/npm/pagekit/player/assets/toasts-ChPacqdd.js +1 -0
- package/dist/npm/pagekit/player/assets/transportFollow-Ox91SKLF.js +1 -0
- package/dist/npm/pagekit/player/favicon.svg +77 -0
- package/dist/npm/pagekit/player/files.json +1 -0
- package/dist/npm/pagekit/player/player.html +35 -0
- package/package.json +58 -43
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./errors-BdUU2zPt.js";import{i as t}from"./fileRef-BmnWhXuY.js";import{_ as n,b as s,d as r,g as o,n as i,v as a,x as c,y as l}from"./store-CJdayqZa.js";import{n as d}from"./transportFollow-Ox91SKLF.js";import{s as h,t as u}from"./notes-D-zF5qJ1.js";import{a as m,s as p}from"./src-DyDfRe65.js";import{i as f}from"./scale-D2nqiPek.js";import"./dist-DfaMbR-1.js";import{n as g,t as b}from"./ahead-BNQHG1e8.js";var k=p({heldNotes:new Set,channel:0,holdMode:!1,octaveBase:60});function v(e){const t=function(e){if(!Number.isFinite(e))return 60;const t=Math.round(e);return t<0?0:t>103?103:t}(e);return k.update(e=>({...e,octaveBase:t})),t}var y="keyboard-default";function w(){const e=l(),t=e.routing.registerSource({id:y,kind:"midi",label:"Keyboard",outputs:[{id:"out",label:"out"}],meta:{kind:"keyboard"},permanent:!0}),n=e.events.on("midi.panic",()=>{!function(){const e=l(),{heldNotes:t,channel:n}=m(k),s=128|i(n);let r=0;for(const o of t)e.midi.dispatchFromSource(y,[s,o,0]),r++;(function(){k.update(e=>0===e.heldNotes.size?e:{...e,heldNotes:new Set})})()}()});return()=>{t(),n()}}var M={key:"keyboard",save:()=>{const e=m(k);return{channel:e.channel,holdMode:e.holdMode,octaveBase:e.octaveBase}},restore:e=>{if(!e||"object"!=typeof e)return;const t=e;var n;"number"==typeof t.channel&&function(e){const t=r(e);k.update(e=>({...e,channel:t}))}(t.channel),"boolean"==typeof t.holdMode&&(n=t.holdMode,k.update(e=>({...e,holdMode:!!n}))),"number"==typeof t.octaveBase&&v(t.octaveBase)},subscribe:e=>k.subscribe(()=>e())},$={structure:{chooseAhead:2,entries:{max:2,airFirst:!0,seeded:!1}},arc:{shapes:{waves:[[0,.3],[.08,.55],[.17,.75],[.24,.45],[.34,.8],[.42,.5],[.55,.75],[.66,1],[.76,.95],[.82,.4],[.9,.7],[1,.3]],plateau:[[0,.3],[.12,.7],[.2,.8],[.8,.85],[.9,.5],[1,.3]],"slow-burn":[[0,.2],[.3,.45],[.6,.7],[.85,1],[.93,.6],[1,.3]]},character:{driving:.12,balanced:0,deep:-.15},pull:.18,conductor:.5},density:{thin:.3},hand:{everyMs:25,step:[1,2],turnMs:[500,3e3],pause:.15,glideBars:4,glideInset:.15,count:1},ornaments:{calmPhrases:1,onSectionStart:!1},mutation:{kit:{add:.4,remove:.3,shift:.3,addVelocity:[50,90],keepHits:2},melodic:{step:.35,octave:.2,gate:.25,copy:.2,stepSemis:2,gateRange:[.5,16],copyVelocity:-10},melodicEvery:3},tempo:{bpm:1,everyBars:2,follow:"chapters"},wishes:{fade:.79,goneBelow:.1,rest:.35,high:.75,shift:{more:.3,build:.25},tilt:4},transitions:{namedFirst:!0,noRepeat:!0},checks:{melodic:{max:2},density:{intro:[2,4],core:[4,9],breakdown:[2,4],drift:[2,5]},densityShare:.1}};function I(e){const t=e.style??{},n=$;return{structure:{chooseAhead:t.structure?.chooseAhead??n.structure.chooseAhead,entries:{...n.structure.entries,...t.structure?.entries}},arc:{shapes:{...n.arc.shapes,...t.arc?.shapes},character:{...n.arc.character,...t.arc?.character},pull:t.arc?.pull??n.arc.pull,conductor:t.arc?.conductor??n.arc.conductor},density:{...n.density,...t.density},hand:{...n.hand,...t.hand},ornaments:{...n.ornaments,...t.ornaments},mutation:{kit:{...n.mutation.kit,...t.mutation?.kit},melodic:{...n.mutation.melodic,...t.mutation?.melodic},melodicEvery:t.mutation?.melodicEvery??n.mutation.melodicEvery},tempo:{...n.tempo,...t.tempo},wishes:{...n.wishes,...t.wishes,shift:{...n.wishes.shift,...t.wishes?.shift}},transitions:{...n.transitions,...t.transitions},checks:{melodic:{...n.checks.melodic,...t.checks?.melodic},density:t.checks?.density??n.checks.density,densityShare:t.checks?.densityShare??n.checks.densityShare}}}var S=["waves","plateau","slow-burn"],x=["driving","balanced","deep"],j={arc:"waves",character:"balanced",minutes:60};function B(e,t,n=$.arc){const s=6e4*Math.max(1,e.minutes),r=t%s/s,o=n.shapes[e.arc];let i=o[o.length-1][1];for(let a=1;a<o.length;a++){const[e,t]=o[a];if(r>e)continue;const[n,s]=o[a-1];i=s+(t-s)*(r-n)/Math.max(1e-9,e-n);break}return Math.max(0,Math.min(1,i+n.character[e.character]))}var P="performer",N=p({ruleBook:null,seed:null,follows:!0,playing:!1,run:null,error:null,choice:{minutes:j.minutes,arc:j.arc,character:j.character},labels:!0});function A(e){return{ruleBook:e.ruleBook,seed:e.seed,follows:e.follows,choice:e.choice}}var T={key:"performer",save:()=>A(m(N)),restore:e=>{e&&"object"==typeof e&&function(e){const n="string"==typeof e.ruleBook&&t(e.ruleBook)?e.ruleBook:null,s="number"==typeof e.seed&&Number.isInteger(e.seed)&&e.seed>=0?e.seed:null,r=!1!==e.follows,o=e.choice??{},i={minutes:null===o.minutes||"number"==typeof o.minutes&&o.minutes>0?o.minutes:j.minutes,arc:S.includes(o.arc)?o.arc:j.arc,character:x.includes(o.character)?o.character:j.character};N.update(e=>({...e,ruleBook:n,seed:s,follows:r,choice:i}))}(e)},subscribe:e=>{let t="";return N.subscribe(n=>{const s=JSON.stringify(A(n));s!==t&&(t=s,e())})}},D={id:"performer",label:"Performer",icon:"Theater",description:"A performer document: sections, transitions, ornaments — the project played live by itself, shown as its planned run.",fileExtensions:[".performer"],sounds:!0,minHeight:560};var O=[0,4,7],R=[0,3,7],E=[0,4,7,10],C=[{progressionId:"axis-major",name:"I–V–vi–IV (Pop Axis Progression)",degreePattern:"I–V–vi–IV",exampleKey:"C-Dur",steps:[{chordName:"C",rootMidi:60,intervals:O},{chordName:"G",rootMidi:55,intervals:O},{chordName:"Am",rootMidi:57,intervals:R},{chordName:"F",rootMidi:53,intervals:O}],suggestedStepMs:1200,character:"aufstrebend, anthemisch, aufgelöst — die wahrscheinlich häufigste Akkord-Folge im modernen Pop",genres:["pop","rock","singer-songwriter","anthem"],aliases:["Axis of Awesome","4 chords song","Pop Axis","I V vi IV","Don't Stop Believin'","Let It Be"]},{progressionId:"axis-minor",name:"vi–IV–I–V (Sad Axis Rotation)",degreePattern:"vi–IV–I–V",exampleKey:"C-Dur (vi-Start)",steps:[{chordName:"Am",rootMidi:57,intervals:R},{chordName:"F",rootMidi:53,intervals:O},{chordName:"C",rootMidi:60,intervals:O},{chordName:"G",rootMidi:55,intervals:O}],suggestedStepMs:1200,character:"melancholisch-anhebend — dieselben vier Akkorde wie der Pop-Axis, aber Start auf der Moll-Stufe",genres:["pop","ballade","singer-songwriter"],aliases:["vi IV I V","Sad Axis","Someone Like You-Loop","Apologize"]},{progressionId:"i-iv-v-major",name:"I–IV–V (klassische Dur-Kadenz)",degreePattern:"I–IV–V",exampleKey:"C-Dur",steps:[{chordName:"C",rootMidi:60,intervals:O},{chordName:"F",rootMidi:53,intervals:O},{chordName:"G",rootMidi:55,intervals:O}],suggestedStepMs:1200,character:"kanonisch, kraftvoll, abgeschlossen — die Drei-Akkord-Basis von Rock & Roll, Folk und unzähligen Volksliedern",genres:["rock","folk","country","gospel"],aliases:["three-chord","I IV V","classical cadence","Twist and Shout","Wild Thing","La Bamba"]},{progressionId:"ii-v-i",name:"ii–V–I (Jazz-Kadenz)",degreePattern:"ii–V–I",exampleKey:"C-Dur",steps:[{chordName:"Dm7",rootMidi:62,intervals:[0,3,7,10]},{chordName:"G7",rootMidi:55,intervals:E},{chordName:"Cmaj7",rootMidi:60,intervals:[0,4,7,11]}],suggestedStepMs:1400,character:"jazzig, elegant, vorwärtsdrängend — DIE Standard-Kadenz der westlichen Jazz-Harmonik",genres:["jazz","bossa nova","standards"],aliases:["two five one","ii V I","jazz cadence","Autumn Leaves","Misty"]},{progressionId:"i-vi-iv-v",name:"I–vi–IV–V (50s Doo-Wop)",degreePattern:"I–vi–IV–V",exampleKey:"C-Dur",steps:[{chordName:"C",rootMidi:60,intervals:O},{chordName:"Am",rootMidi:57,intervals:R},{chordName:"F",rootMidi:53,intervals:O},{chordName:"G",rootMidi:55,intervals:O}],suggestedStepMs:1200,character:"nostalgisch, romantisch, einfach — die klassische Doo-Wop / 50s-Pop-Schleife",genres:["doo-wop","50s pop","oldies","crooner ballad"],aliases:["50s progression","doo-wop changes","I vi IV V","Stand By Me","Earth Angel","Heart and Soul"]},{progressionId:"minor-pop-loop",name:"i–♭VI–♭III–♭VII (Minor Pop Loop)",degreePattern:"i–♭VI–♭III–♭VII",exampleKey:"A-Moll",steps:[{chordName:"Am",rootMidi:57,intervals:R},{chordName:"F",rootMidi:53,intervals:O},{chordName:"C",rootMidi:60,intervals:O},{chordName:"G",rootMidi:55,intervals:O}],suggestedStepMs:1200,character:"melancholisch-treibend — die Standard-Moll-Pop-Schleife, dieselben Akkorde wie Axis-Major aber gegen Moll-Tonika gehört",genres:["pop","rock","EDM","indie"],aliases:["minor pop","i VI III VII","Am F C G","Zombie","Numb","All Along the Watchtower"]},{progressionId:"folk-minor",name:"i–iv–v (Folk Minor)",degreePattern:"i–iv–v",exampleKey:"A-Moll",steps:[{chordName:"Am",rootMidi:57,intervals:R},{chordName:"Dm",rootMidi:62,intervals:R},{chordName:"Em",rootMidi:64,intervals:R}],suggestedStepMs:1400,character:"archaisch, schlicht — die Drei-Akkord-Form der Folk-Tradition mit Moll-v (statt Dur-V wie in harmonisch Moll)",genres:["folk","traditional","sea shanty","modal"],aliases:["three-chord minor","i iv v","Folk minor cadence"]},{progressionId:"twelve-bar-blues",name:"12-Bar Blues (I7–IV7–V7)",degreePattern:"I7 / IV7 / V7 (12-Bar-Form)",exampleKey:"A-Dur (Blues)",steps:[{chordName:"A7",rootMidi:57,intervals:E},{chordName:"A7",rootMidi:57,intervals:E},{chordName:"A7",rootMidi:57,intervals:E},{chordName:"A7",rootMidi:57,intervals:E},{chordName:"D7",rootMidi:62,intervals:E},{chordName:"D7",rootMidi:62,intervals:E},{chordName:"A7",rootMidi:57,intervals:E},{chordName:"A7",rootMidi:57,intervals:E},{chordName:"E7",rootMidi:64,intervals:E},{chordName:"D7",rootMidi:62,intervals:E},{chordName:"A7",rootMidi:57,intervals:E},{chordName:"E7",rootMidi:64,intervals:E}],suggestedStepMs:1600,character:"klassischer Blues — die wichtigste Akkord-Form des 20. Jahrhunderts; alle drei Akkorde sind Dominantseptakkorde",genres:["blues","rock & roll","jazz","rhythm & blues"],aliases:["12-bar blues","twelve bar","blues form","I7 IV7 V7","Sweet Home Chicago","Crossroads"]},{progressionId:"minor-pedal",name:"i (Moll-Orgelpunkt, ein Akkord)",degreePattern:"i",exampleKey:"A-Moll",steps:[{chordName:"Am",rootMidi:57,intervals:R}],suggestedStepMs:1200,character:"hypnotisch-stehend — ein Akkord trägt den Track, Bewegung kommt aus Klang und Schichten",genres:["dub-techno","techno","dark-techno"],aliases:["one chord","Orgelpunkt","pedal","vamp","ein Akkord","Phylyps Trak","M-4"]},{progressionId:"minor-i-v",name:"i–v (Moll-Pendel)",degreePattern:"i–v",exampleKey:"A-Moll",steps:[{chordName:"Am",rootMidi:57,intervals:R},{chordName:"Em",rootMidi:52,intervals:R}],suggestedStepMs:2400,character:"schwebend-melancholisch — Tonika und Moll-Dominante pendeln, ohne aufzulösen",genres:["dub-techno"],aliases:["i v","Moll-Pendel","minor dominant","Am Em","Listing Sinking"]},{progressionId:"minor-i-bvi-bvii",name:"i–♭VI–♭VII (äolische Schleife)",degreePattern:"i–♭VI–♭VII",exampleKey:"A-Moll",steps:[{chordName:"Am",rootMidi:57,intervals:R},{chordName:"F",rootMidi:53,intervals:O},{chordName:"G",rootMidi:55,intervals:O}],suggestedStepMs:1900,character:"melancholisch-hymnisch — die Moll-Tonika, dann zwei Dur-Stufen, die stufenweise zurück zur Tonika steigen",genres:["club"],aliases:["i bVI bVII","aeolian loop","äolische Schleife","Am F G"]},{progressionId:"minor-i-v-iv",name:"i7–v7–iv7 (absteigender Moll-Loop)",degreePattern:"i7–v7–iv7",exampleKey:"A-Moll",steps:[{chordName:"Am7",rootMidi:57,intervals:[0,3,7,10]},{chordName:"Em7",rootMidi:52,intervals:[0,3,7,10]},{chordName:"Dm7",rootMidi:50,intervals:[0,3,7,10]}],suggestedStepMs:1967,character:"warm-sehnsüchtig — drei Moll-Septakkorde gleicher Farbe, parallel verschoben, die Oberstimme sinkt",genres:["deep-house"],aliases:["i v iv","Am7 Em7 Dm7","Kerri Chandler","Come Home","parallel minor sevenths"]},{progressionId:"minor-vi-v",name:"♭VImaj7–v7 (Deep-House-Pendel)",degreePattern:"♭VImaj7–v7",exampleKey:"A-Moll",steps:[{chordName:"Fmaj7",rootMidi:53,intervals:[0,4,7,11]},{chordName:"Em7",rootMidi:52,intervals:[0,3,7,10]}],suggestedStepMs:3934,character:"schwebend-weich — ein Halbton abwärts von maj7 nach m7, die Tonika wird nie gespielt",genres:["deep-house"],aliases:["VI v","Fmaj7 Em7","deep house two-chord loop"]},{progressionId:"minor-i-iii-v",name:"i7–♭IIImaj7–v7 (Moll-Septakkord-Aufgang)",degreePattern:"i7–♭IIImaj7–v7",exampleKey:"A-Moll",steps:[{chordName:"Am7",rootMidi:57,intervals:[0,3,7,10]},{chordName:"Cmaj7",rootMidi:60,intervals:[0,4,7,11]},{chordName:"Em7",rootMidi:64,intervals:[0,3,7,10]}],suggestedStepMs:1967,character:"soulig-aufsteigend — Moll-Tonika, Dur-Parallele mit großer Septime, Moll-Dominante",genres:["deep-house"],aliases:["i III v","Am7 Cmaj7 Em7","Fm7 Abmaj7 Cm7","Masters At Work","To Be In Love"]},{progressionId:"minor-parallel",name:"i–ii (parallele Moll-Stabs, Chord Memory)",degreePattern:"i–i–ii–i (parallel, alle Moll)",exampleKey:"A-Moll",steps:[{chordName:"Am",rootMidi:57,intervals:R},{chordName:"Am",rootMidi:57,intervals:R},{chordName:"Bm",rootMidi:59,intervals:R},{chordName:"Am",rootMidi:57,intervals:R}],suggestedStepMs:1800,character:"maschinell-kreisend — eine feste Moll-Form wandert um einen Ganzton und kehrt zurück, die Tonart ist egal",genres:["techno"],aliases:["parallel chords","parallel stabs","chord memory","parallele Akkorde","Cm Dm","Am Bm"]},{progressionId:"phrygian-i-bii",name:"i–♭II (phrygisches Pendel)",degreePattern:"i–♭II",exampleKey:"A-Moll",steps:[{chordName:"Am",rootMidi:57,intervals:R},{chordName:"B♭",rootMidi:58,intervals:O}],suggestedStepMs:2400,character:"bedrohlich-eng — der Halbton über der Tonika zieht zurück, Spannung ohne Auflösung",genres:["dark-techno","club"],aliases:["i bII","phrygian pendulum","phrygisches Pendel","Halbton-Pendel","Am B♭","flat two"]},{progressionId:"minor-i-bvii",name:"i–♭VII (Moll mit Unterton)",degreePattern:"i–♭VII",exampleKey:"A-Moll",steps:[{chordName:"Am",rootMidi:57,intervals:R},{chordName:"G",rootMidi:55,intervals:O}],suggestedStepMs:2400,character:"düster-schwankend — zwei Akkorde, der Ganzton darunter, kein Leitton, keine Kadenz",genres:["dark-techno","club","techno","deep-house"],aliases:["i bVII","two chords","zwei Akkorde","Am G","aeolian vamp"]}],z=Object.fromEntries(C.map(e=>[e.progressionId,e])),F=u;function q(e,t){let n=(t-e)%12;return n>6&&(n-=12),n<-6&&(n+=12),n}var V=Object.fromEntries([{genreId:"dub-techno",name:"Dub Techno",aliases:["dub","dub techno","Basic Channel","Chain Reaction","Echospace","Deepchord","Rhythm & Sound","Maurizio"],neighbours:["techno","club","deep-house","dark-techno"],tempo:{min:118,max:128,default:122,occurs:[110,145]},swing:{min:50,max:50,default:50},grids:[{voice:"kick",name:"Four to the floor, muted",steps:[0,4,8,12],confidence:"sourced"},{voice:"kick",name:"Fourth kick a 16th early",steps:[0,4,8,11],confidence:"derived"},{voice:"clap",name:"Clap on two and four",steps:[4,12],confidence:"sourced"},{voice:"rim",name:"Rim on three only",steps:[8],confidence:"sourced"},{voice:"hat-open",name:"Open hat on the offbeats",steps:[2,6,10,14],confidence:"sourced"},{voice:"shaker",name:"Quiet 16th shaker",steps:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],confidence:"derived"},{voice:"perc",name:"Off-16th dabs into the echo",steps:[3,11,14],confidence:"derived"},{voice:"stab",name:"Stab on the offbeats",steps:[2,6,10,14],confidence:"sourced"},{voice:"stab",name:"One stab a bar, the echo fills",steps:[3],confidence:"derived"},{voice:"stab",name:"3-3-2 stab cell",steps:[0,3,6,8,11,14],confidence:"sourced"}],basslines:[{id:"offbeat-sub",name:"Sub pulse on the offbeat",role:"pulse",bars:1,notes:[[2,0,2],[6,0,2],[10,0,2],[14,0,2]],use:"The groove part: a round sub between every kick, the stab offbeats above it.",confidence:"sourced"},{id:"heartbeat",name:"Heartbeat",role:"sub",bars:1,notes:[[0,0,2],[3,0,1],[8,0,2],[11,0,1]],use:"Intro and drift: very sparse, a double beat each half note.",confidence:"derived"},{id:"root-fourth",name:"Root and fourth",role:"sub",bars:2,notes:[[0,0,3],[6,0,3],[16,5,3],[22,5,3],[28,0,3]],use:"Two notes, short release, under a single stab.",confidence:"derived"},{id:"triplet-roll",name:"Triplet roll",role:"rolling",bars:1,notes:[[0,0,2],[3,0,2],[6,0,2],[8,0,2],[11,0,2],[14,0,2]],use:"The heavy, rolling core of the early, faster records.",confidence:"derived"},{id:"minor-four-beat",name:"Four-beat line with minor third and fifth",role:"melodic",bars:1,notes:[[0,0,4],[6,3,3],[9,3,3],[12,7,3]],use:"A change or a transition, interlocked with the stab over four beats — not a groove to dance on.",confidence:"derived"}],harmony:{scales:["aeolian","dorian"],progressions:["minor-pedal","minor-i-v"],changesPer16Bars:[0,1],stab:[0,3,7,10]},form:{phraseBars:8,layerChangeBars:8,introBars:[16,64],outroBars:[16,32],breakdownBars:[1,2],trackMinutes:[7,13]},gestures:[{target:"echo-feedback",shape:"a throw: up fast, back down smooth",bars:[8,8],occasion:"an accent or a transition",confidence:"sourced"},{target:"echo-feedback",shape:"small ups and downs on the stab, more often towards the end",bars:[4,16],occasion:"life in the core",confidence:"sourced"},{target:"lowpass",shape:"opens slowly on everything but kick and bass",bars:[16,64],occasion:"the build from intro to peak",confidence:"derived"},{target:"lowpass",shape:"closes slowly",bars:[16,32],occasion:"the fade before the end",confidence:"sourced"},{target:"filter-lfo",shape:"a slow sine on the stab, 0.1–0.25 Hz, not tempo-synced",bars:null,occasion:"breathing, throughout",confidence:"sourced"},{target:"reverb",shape:"decay or send longer, then shorter",bars:[8,16],occasion:"the room widens or shrinks a section",confidence:"derived"},{target:"echo-time",shape:"turned live, unsynced — a pitch smear",bars:[1,2],occasion:"a dub moment",confidence:"derived"},{target:"mute",shape:"whole layers in and out (hats, ride, a stab layer)",bars:[8,8],occasion:"the form itself",confidence:"sourced"}],rules:[{id:"tempo",rule:"Tempo core",value:"118–128 BPM; 110–145 occurs",confidence:"sourced"},{id:"straight",rule:"No swing — the groove comes from echo and syncopation",value:"50 % (straight 16ths)",confidence:"sourced"},{id:"kick-quarters",rule:"Kick on every quarter",value:"almost always; beatless intros aside",confidence:"sourced"},{id:"kick-quiet",rule:"The kick sits under the stab and the air",value:"mostly",confidence:"sourced"},{id:"stab-off-kick",rule:"The stab is on the offbeat or syncopated, never with the kick",value:"mostly",confidence:"sourced"},{id:"stab-cell",rule:"The stab figure is 1–2 bars and stays the same through the track",value:"1–2 bars",confidence:"sourced"},{id:"few-changes",rule:"Chord changes",value:"0–1 per 16 bars; a loop is at most 32 bars; many tracks hold one chord",confidence:"sourced"},{id:"minor",rule:"Chord quality",value:"minor: triad, m7, m9",confidence:"sourced"},{id:"stab-rootless",rule:"The stab leaves the root to the bass",value:"often",confidence:"sourced"},{id:"echo-on-stab",rule:"Every stab has an echo; the echo is part of the groove",value:"dotted 1/8 standard, also 1/16, 5/16; feedback 20–50 %, throws to ~85 %",confidence:"sourced"},{id:"echo-band",rule:"The echo return is band-limited",value:"high-pass 200–280 Hz, low-pass 2–5 kHz",confidence:"sourced"},{id:"sound-moves",rule:"Movement comes from sound, not notes",value:"notes fixed; filter, echo and reverb move",confidence:"sourced"},{id:"no-risers",rule:"Form is layers in and out plus filter rides",value:"no risers, no snare rolls, no silent drops",confidence:"sourced"},{id:"short-break",rule:"The only break before a peak is a short kick mute",value:"short, by muting the kick",confidence:"sourced"},{id:"hats-late",rule:"Hats come late and leave first",value:"hats just before the peak; first out in the fade",confidence:"sourced"},{id:"bass-before-kick",rule:"In the fade the bass leaves before the kick",value:"always in the analysed tracks",confidence:"sourced"},{id:"atmo-first",rule:"A track begins with the atmosphere, never with kick or bass",value:"up to minutes without a beat",confidence:"sourced"},{id:"few-elements",rule:"Few elements",value:"4–6: drums, bass, 1–3 stab layers, pad",confidence:"sourced"},{id:"end",rule:"The end",value:"the stab echo alone, or a fade of about 32 s",confidence:"sourced"}]},{genreId:"club",name:"Club",aliases:["club","tech house","club house","high-tech minimal","peak time house","Boris Brejcha","Fisher","Chris Lake","Jamie Jones","Patrick Topping","The End","Wiggle"],neighbours:["deep-house","techno","dub-techno","dark-techno"],tempo:{min:124,max:128,default:126,occurs:[120,130]},swing:{min:54,max:62,default:58},grids:[{voice:"kick",name:"Four to the floor",steps:[0,4,8,12],confidence:"sourced"},{voice:"clap",name:"Clap on two and four",steps:[4,12],confidence:"sourced"},{voice:"clap",name:"Clap with a ghost after the last one (two bars)",steps:[4,12,20,28,29],quiet:[29],bars:2,confidence:"sourced"},{voice:"hat-open",name:"Open hat on the offbeats",steps:[2,6,10,14],confidence:"sourced"},{voice:"hat-closed",name:"Closed hat on 16ths one, two and four",steps:[0,1,3,4,5,7,8,9,11,12,13,15],confidence:"sourced"},{voice:"shaker",name:"Quiet 16th shaker, ghosts on the beat 16ths",steps:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],quiet:[0,2,4,6,8,10,12,14],confidence:"sourced"},{voice:"ride",name:"Quiet ride on the beat",steps:[0,4,8,12],confidence:"sourced"},{voice:"snare",name:"Ghost snare before the next downbeat",steps:[15],quiet:[15],confidence:"sourced"},{voice:"snare",name:"Ghost snare before kick three (two bars)",steps:[7,23],quiet:[7,23],bars:2,confidence:"derived"},{voice:"perc",name:"Offbeat perc around the claps",steps:[2,6,10,14],confidence:"sourced"},{voice:"stab",name:"One stab on beat one of two bars",steps:[0],bars:2,confidence:"derived"}],basslines:[{id:"offbeat-pump",name:"Offbeat bass",role:"pump",bars:1,notes:[[2,0,2],[6,0,2],[10,0,2],[14,0,2]],use:"The classic: an eighth between every kick; end of the intro and the groove parts.",confidence:"sourced"},{id:"offbeat-octave",name:"Offbeat with octave and passing note",role:"pump",bars:1,notes:[[2,12,1],[6,0,1],[9,0,1],[10,0,1],[14,0,1]],use:"Second half of a drop, or the variation after 8/16 bars — not as a loop on its own; the extra note a little louder.",confidence:"derived"},{id:"chug",name:"Chugging root figure",role:"pulse",bars:1,notes:[[0,0,1],[4,0,1],[8,0,1],[11,0,1],[14,0,1]],use:"Drop and core: partly on the kick (ducked by the sidechain), the two syncopes push into the next bar.",confidence:"sourced"},{id:"gallop",name:"Rolling 16ths around the kick (gallop)",role:"gallop",bars:1,notes:[[1,0,1],[2,0,1],[3,0,1],[5,0,1],[6,0,1],[7,0,1],[9,0,1],[10,0,1],[11,0,1],[13,0,1],[14,0,1],[15,0,1]],use:"Peak: every 16th but the kick, quiet to loud within each beat; only with a strong sidechain.",confidence:"sourced"},{id:"rolling-pair",name:"Rolling pair, the offbeat held",role:"rolling",bars:1,notes:[[1,0,1],[2,0,2],[5,0,1],[6,0,2],[9,0,1],[10,0,2],[13,0,1],[14,0,2]],use:"Modern tech house core: a short note, then the offbeat held into the next 16th; busy, so in doses; bass and hats swung, kick straight.",confidence:"derived"},{id:"driving-16ths",name:"Driving 16ths",role:"rolling",bars:1,notes:[[0,0,1],[1,0,1],[2,0,1],[3,0,1],[4,0,1],[5,0,1],[6,0,1],[7,0,1],[8,0,1],[9,0,1],[10,0,1],[11,0,1],[12,0,1],[13,0,1],[14,0,1],[15,0,1]],use:"Peak, when little else runs: every 16th, overall quieter, the sidechain ducks each beat.",confidence:"sourced"},{id:"octave-glide",name:"Legato octave glide (303-style)",role:"acid",bars:1,notes:[[0,0,3],[4,12,2],[6,0,2],[10,0,2],[12,12,2],[15,0,1]],use:"Drop variation: mono legato with portamento on the octave jumps.",confidence:"derived"},{id:"call-response",name:"Held call, rhythmic answer",role:"melodic",bars:2,notes:[[0,0,16],[18,0,1],[22,0,1],[25,0,1],[27,0,1],[30,0,1]],use:"When a lead or vocal hook is in front: a whole note with a filter ride, then short offbeats and syncopes.",confidence:"derived"}],harmony:{scales:["aeolian","phrygian"],progressions:["minor-pedal","phrygian-i-bii","minor-i-bvi-bvii","minor-i-bvii"],changesPer16Bars:[0,4],stab:[0,3,7]},form:{phraseBars:8,layerChangeBars:8,introBars:[8,32],outroBars:[8,32],breakdownBars:[8,16],trackMinutes:[5,6]},gestures:[{target:"lowpass",shape:"the lead or stab filter opens step by step over the whole track",bars:null,occasion:"tension over the running time",confidence:"sourced"},{target:"lowpass",shape:"the bass filter rises through the build",bars:[8,8],occasion:"the build into the drop",confidence:"sourced"},{target:"echo-feedback",shape:"the bass's own delay feedback rises with its filter",bars:[8,8],occasion:"the build into the drop",confidence:"sourced"},{target:"lowpass",shape:"a sweep open from about 200 Hz to 20 kHz, accelerating",bars:[8,16],occasion:"a build (instead of the high-pass approach, never both)",confidence:"sourced"},{target:"reverb",shape:"rises with amp and cutoff of a noise sweep, accelerating",bars:[8,8],occasion:"a build with a snare roll",confidence:"sourced"},{target:"reverb",shape:'"outside the club": reverb and EQ on in the breakdown, back to 0 on the drop downbeat',bars:[8,16],occasion:"contrast to the drop",confidence:"sourced"},{target:"mute",shape:"one element filtered or muted for a block",bars:[8,8],occasion:"variation, block 3 of the 4 in a drop",confidence:"sourced"},{target:"mute",shape:"kick out in the last bar of the build (or kick and bass the last two)",bars:[1,2],occasion:"just before the drop",confidence:"sourced"},{target:"highpass",shape:"on the bass, or a drum copy at about 250 Hz, through the build; off on the drop — at most one high-pass move per transition",bars:[8,8],occasion:"the build into the drop",confidence:"derived"}],rules:[{id:"tempo",rule:"Tempo core",value:"124–128 BPM, default 126; Brejcha style 125; 120–130 occurs",confidence:"sourced"},{id:"swing",rule:"Swing (Linn, 50 = straight)",value:"54–62 %, default 58; above ~66 is shuffle/jackin",confidence:"derived"},{id:"swing-odd-steps",rule:"Swing delays only the odd steps (1, 3, 5 …)",value:"always",confidence:"sourced"},{id:"kick-straight",rule:"The kick stays straight; bass and hats are swung",value:"mostly",confidence:"sourced"},{id:"kick-quarters",rule:"Kick on every quarter",value:"always, except breakdown and fills",confidence:"sourced"},{id:"clap-two-four",rule:"Clap or snare on two and four",value:"always in the groove",confidence:"sourced"},{id:"hat-offbeat",rule:"Hat on the offbeats",value:"always in the groove",confidence:"sourced"},{id:"shaker-quiet",rule:"The 16th shaker or perc is quiet, velocity varies",value:"always",confidence:"sourced"},{id:"ghosts",rule:"Ghost hits",value:"about −6 dB",confidence:"sourced"},{id:"bass-off-kick",rule:"The bass avoids the kick steps",value:"mostly; otherwise the sidechain makes room",confidence:"sourced"},{id:"sidechain",rule:"Bass ducked by the kick",value:"always",confidence:"sourced"},{id:"bass-notes",rule:"Bass note material",value:"root, octave, fifth, minor third (0, +12, +7, +3), rarely more",confidence:"derived"},{id:"bass-values",rule:"Bass note values",value:"eighths or 16ths",confidence:"sourced"},{id:"minor",rule:"Key",value:"minor (aeolian, phrygian for a darker line); F, F♯, G minor common",confidence:"sourced"},{id:"few-changes",rule:"Chord changes",value:"0–2 per 8-bar phrase; often a single degree for the whole track",confidence:"derived"},{id:"parallel-stab",rule:"The stab is a minor triad on one key, moved by transposing it whole",value:"intervals 0, +3, +7 (+ sub −12)",confidence:"sourced"},{id:"blocks",rule:"Built in blocks; something changes every block",value:"8 bars",confidence:"sourced"},{id:"intro-outro",rule:"Intro and outro",value:"32 bars each for the DJ; radio 8–16",confidence:"sourced"},{id:"intro-minimal",rule:"The first 16 intro bars are minimal",value:"drums and a hint of bass",confidence:"sourced"},{id:"breakdown",rule:"Breakdown length, always without kick",value:"8–16 bars (up to 32); short before a heavy drop",confidence:"sourced"},{id:"build",rule:"Build length",value:"8 bars",confidence:"sourced"},{id:"drop",rule:"Drop length; one block filters or mutes an element",value:"32 bars = 4 × 8, block 3 varies",confidence:"sourced"},{id:"drop-two-differs",rule:"Drop 2 is not Drop 1",value:"a new bass variant, extra perc or another vocal chop",confidence:"sourced"},{id:"perc-fill",rule:"A perc fill or roll",value:"every 8 or 16 bars",confidence:"sourced"},{id:"crash",rule:"Crash or impact",value:"on beat one of the drop",confidence:"sourced"},{id:"layer-order",rule:"Layers come in, and leave in reverse",value:"kick → hats/perc → hint of bass → full bass → hook/vocal → shaker; outro = drums only",confidence:"sourced"},{id:"length",rule:"Club mix length",value:"about 168 bars (5–6 min)",confidence:"sourced"},{id:"dry",rule:"Reverb and delay",value:"sparse; the genre is dry",confidence:"sourced"},{id:"mono-low",rule:"Kick and bass mono in the middle, width only on top",value:"always",confidence:"sourced"},{id:"highpass-sparse",rule:"High-pass sparingly",value:"at most one high-pass gesture per transition",confidence:"derived"}]},{genreId:"deep-house",name:"Deep House",aliases:["deep","deep house","Chicago deep house","New Jersey sound","Garage House","Larry Heard","Mr. Fingers","Kerri Chandler","Moodymann","Theo Parrish"],neighbours:["club","dub-techno","techno","dark-techno"],tempo:{min:120,max:124,default:122,occurs:[110,128]},swing:{min:56,max:62,default:59},grids:[{voice:"kick",name:"Four to the floor",steps:[0,4,8,12],confidence:"sourced"},{voice:"kick",name:"Fill: kick on the eighths, last bar before a section",steps:[0,2,4,6,8,10,12,14],confidence:"derived"},{voice:"clap",name:"Clap on two and four",steps:[4,12],confidence:"sourced"},{voice:"hat-open",name:"Open hat on the offbeats, short decay",steps:[2,6,10,14],confidence:"sourced"},{voice:"hat-closed",name:"Closed hat on every 16th the open hat leaves",steps:[0,1,3,4,5,7,8,9,11,12,13,15],confidence:"sourced"},{voice:"hat-closed",name:"One ghost hat for the shuffle",steps:[9],quiet:[9],confidence:"sourced"},{voice:"shaker",name:"16th shaker, off-16ths quiet",steps:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],quiet:[1,3,5,7,9,11,13,15],confidence:"derived"},{voice:"tom",name:"Rolling 909 tom",steps:[2,8,10],confidence:"sourced"},{voice:"perc",name:"Afro perc, tuned to the tom",steps:[1,9],confidence:"sourced"},{voice:"stab",name:"Stab on the first offbeat",steps:[2],confidence:"sourced"}],basslines:[{id:"offbeat-sub",name:"Offbeat sub",role:"pump",bars:1,notes:[[2,0,2],[6,0,2],[10,0,2],[14,0,2]],use:"The standard under pads, intro and groove: a sine sub between the kicks, sidechained deep.",confidence:"derived"},{id:"sparse-syncopation",name:"Sparse syncopation (Heard style)",role:"sub",bars:1,notes:[[3,0,3],[10,0,3],[15,7,1]],use:"Hollow and airy: two or three notes a bar; the fifth on the last 16th is optional.",confidence:"derived"},{id:"delayed-root",name:"Delayed root (Chandler)",role:"melodic",bars:2,notes:[[2,-2,2],[4,0,4],[10,0,3],[14,0,2],[18,-2,2],[20,0,4],[26,3,3],[30,0,2]],use:"The bar opens on the whole tone below and resolves to the root; the minor third colours the second bar.",confidence:"derived"},{id:"rolling-sixteenths",name:"Rolling 16th groove",role:"rolling",bars:2,notes:[[2,0,1],[3,0,1],[6,0,1],[9,0,1],[10,0,1],[14,12,1],[18,0,1],[19,0,1],[22,0,1],[25,0,1],[26,3,1],[29,5,1],[31,7,1]],use:"A transition or a build — fresh air after the steady figures; swung like the drums; the octave ends bar one, a climb leads into the next pass.",confidence:"derived"},{id:"chord-follower",name:"Chord follower",role:"pulse",bars:1,notes:[[2,0,2],[6,0,2],[10,0,2],[13,0,2]],use:"Under 2–4-chord loops: degree 0 is the root of the current chord, it changes with the chord and never sits on the kick.",confidence:"derived"},{id:"organ-bass",name:"Organ bass (90s NY/NJ)",role:"pulse",bars:1,notes:[[2,0,2],[5,0,2],[8,12,1],[10,0,2],[14,0,1],[15,12,1]],use:"Percussive, short decay, mids present, jumping octaves — the M1 organ bass.",confidence:"derived"},{id:"breakdown-sub",name:"Long sub under the breakdown",role:"sub",bars:1,notes:[[0,0,16]],use:"The breakdown without kick: one whole note per chord, filtered.",confidence:"derived"}],harmony:{scales:["aeolian","dorian"],progressions:["minor-i-v","minor-i-v-iv","minor-vi-v","minor-i-iii-v","minor-i-bvii"],changesPer16Bars:[8,16],stab:[0,3,7,10,14]},form:{phraseBars:8,layerChangeBars:16,introBars:[16,32],outroBars:[16,32],breakdownBars:[8,32],trackMinutes:[6,8]},gestures:[{target:"lowpass",shape:"slowly open and closed on chords and pad; the pad sits low (around 400 Hz)",bars:null,occasion:"breathing, throughout",confidence:"sourced"},{target:"lowpass",shape:"opens through the breakdown, closes again after the drop",bars:[8,32],occasion:"the breakdown",confidence:"derived"},{target:"lowpass",shape:"the arp filter opens",bars:[8,8],occasion:"a transition",confidence:"sourced"},{target:"lowpass",shape:"the band narrows: high-cut down on drums, less on kick and bass (a low-cut rises with it)",bars:[4,4],occasion:"leading into a breakdown",confidence:"sourced"},{target:"send",shape:"delay throw on chords or strings: 1/8 synced, high feedback, wet rises; the tail carries into the break",bars:[4,4],occasion:"entering a breakdown",confidence:"sourced"},{target:"reverb",shape:"reverb and delay mix on the arp rise — space instead of rhythm",bars:[8,32],occasion:"the breakdown",confidence:"sourced"},{target:"mute",shape:"percussion loops in and out on the fader",bars:[8,16],occasion:"steering density",confidence:"derived"}],rules:[{id:"tempo",rule:"Tempo core",value:"120–124 BPM, default 122; 110–128 occurs (slow classic to modern)",confidence:"sourced"},{id:"kick-quarters",rule:"Kick on every quarter",value:"always, except breakdown and fills",confidence:"sourced"},{id:"clap-two-four",rule:"Clap or snare on two and four",value:"always in the groove",confidence:"sourced"},{id:"hat-offbeat",rule:"Open hat on the offbeats",value:"standard",confidence:"sourced"},{id:"hat-ghosts",rule:"Closed hat or shaker on the remaining 16ths, with ghost velocity",value:"mostly; ghost level ~40–60 %, offbeat hat ~80–90 % (no source gives numbers)",confidence:"derived"},{id:"swing",rule:"Swing on the 16ths",value:"56–62 % Linn, range 50–66",confidence:"sourced"},{id:"swing-shared",rule:"Drums and bass share the same swing",value:"yes",confidence:"sourced"},{id:"bass-off-kick",rule:"The bass sits between the kicks, not on them",value:"mostly",confidence:"sourced"},{id:"bass-density",rule:"Bass note density",value:"2–5 notes a bar; a 2-bar pattern, hardly varied",confidence:"sourced"},{id:"bass-mono",rule:"Bass is monophonic and legato",value:"always",confidence:"sourced"},{id:"sidechain",rule:"Bass and everything melodic ducked by the kick",value:"always",confidence:"sourced"},{id:"minor",rule:"Key",value:"minor, ~73 % of the catalogue",confidence:"sourced"},{id:"chord-rate",rule:"Chord changes",value:"one per bar or a 2-bar vamp",confidence:"sourced"},{id:"chord-loop",rule:"Chord loop",value:"2–4 chords of the same colour, shifted in parallel",confidence:"sourced"},{id:"chord-type",rule:"Chord type",value:"m7 / maj7 plus 9 (11, 13); the fifth may go, the root may go (the bass has it)",confidence:"sourced"},{id:"voicing",rule:"Voicing",value:"close, within one octave; the seventh often in the bass (third inversion)",confidence:"sourced"},{id:"stab-position",rule:"Stab position",value:"offbeat, e.g. step 2; the last stab of a bar may anticipate the next chord",confidence:"sourced"},{id:"pad",rule:"Pad",value:"held, low-passed, quiet in the mix",confidence:"sourced"},{id:"sections",rule:"Sections",value:"multiples of 8 bars; layers change preferably at 16",confidence:"sourced"},{id:"dj-intro-outro",rule:"DJ intro and outro",value:"16–32 bars, reduced (kick, hats or perc, little bass)",confidence:"sourced"},{id:"breakdown",rule:"Breakdown",value:"8–32 bars; the kick leaves, the rest may stay",confidence:"sourced"},{id:"peak",rule:"Peak or groove block",value:"at least 32 bars",confidence:"sourced"},{id:"fill-repeat",rule:"Fills repeat",value:"the same fill type 8 bars later, slightly varied",confidence:"sourced"},{id:"riser",rule:"Noise riser",value:"2–4 bars before the end of the break, stops on the first kick",confidence:"sourced"},{id:"kick-eighths-rare",rule:"Double-eighth kick in the last bar",value:"allowed, but a cliché — rarely",confidence:"sourced"},{id:"flat-energy",rule:"Energy curve",value:"flat and hypnotic, a weak build",confidence:"sourced"},{id:"no-acid",rule:"No acid, distortion or resonance gestures",value:"rule",confidence:"derived"}]},{genreId:"techno",name:"Techno",aliases:["techno","Berlin techno","peak time","driving techno","rolling techno","hypnotic techno","Detroit techno","minimal techno","warehouse techno","Berghain","Tresor","Ostgut Ton","Belleville Three","Jeff Mills","Robert Hood","Ben Klock"],neighbours:["dub-techno","dark-techno","club","deep-house"],tempo:{min:128,max:135,default:130,occurs:[120,140]},swing:{min:50,max:55,default:53},grids:[{voice:"kick",name:"Four to the floor",steps:[0,4,8,12],confidence:"sourced"},{voice:"kick",name:"Ghost kick just before two and four",steps:[0,3,4,8,11,12],quiet:[3,11],confidence:"derived"},{voice:"kick",name:"Ghost kick at the end of the bar",steps:[0,4,8,12,15],quiet:[15],confidence:"derived"},{voice:"clap",name:"Clap on two and four",steps:[4,12],confidence:"sourced"},{voice:"clap",name:"Clap on two only",steps:[4],confidence:"sourced"},{voice:"clap",name:"Clap on two and four with ghosts",steps:[3,4,11,12,14],quiet:[3,11,14],confidence:"derived"},{voice:"hat-open",name:"Open hat on every offbeat",steps:[2,6,10,14],confidence:"sourced"},{voice:"hat-closed",name:"16th carpet, offbeat louder",steps:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],quiet:[0,1,3,4,5,7,8,9,11,12,13,15],confidence:"derived"},{voice:"hat-open",name:"Second open hat on the off-16ths",steps:[1,3,5,7,9,13,15],quiet:[1,5,9,13],confidence:"derived"},{voice:"ride",name:"Ride in eighths, every second hit quieter",steps:[0,2,4,6,8,10,12,14],quiet:[2,6,10,14],confidence:"sourced"},{voice:"shaker",name:"Shaker on the offbeats, every second quieter",steps:[2,6,10,14],quiet:[6,14],confidence:"sourced"},{voice:"tom",name:"Tom run on the off-16ths",steps:[1,3,5,7,9,11,13,15],confidence:"derived"},{voice:"tom",name:"Low tom as a second kick, end of bar two",steps:[30],bars:2,confidence:"derived"},{voice:"perc",name:"Noise stab on kick three, every second bar also before kick four",steps:[8,24,27],bars:2,confidence:"derived"},{voice:"stab",name:"Short stab on the offbeats",steps:[2,6,10,14],confidence:"derived"}],basslines:[{id:"rolling-16ths",name:"Rolling 16ths (warehouse)",role:"rolling",bars:1,notes:[[1,0,1],[2,0,1],[3,0,1],[5,0,1],[6,0,1],[7,0,1],[9,0,1],[10,0,1],[11,3,1],[13,0,1],[14,0,1],[15,0,1]],use:"Peak time: short 16ths, the first 16th of every beat left to the kick, sidechained to it; the first note of each group a little quieter.",confidence:"derived"},{id:"offbeat-pump",name:"Offbeat bass",role:"pump",bars:1,notes:[[2,0,2],[6,0,2],[10,0,2],[14,0,2]],use:"Groove, intro and the deeper, Detroit- and house-near style; parts from the kick by itself.",confidence:"sourced"},{id:"two-tone",name:"Two-tone monotone",role:"pulse",bars:2,notes:[[2,0,2],[6,0,2],[10,0,2],[14,7,2],[18,0,2],[22,0,2],[26,0,2],[30,-2,2]],use:"The opening bass that runs unchanged for a long time.",confidence:"derived"},{id:"gallop",name:"Gallop, two 16ths a beat",role:"gallop",bars:1,notes:[[2,0,1],[3,0,1],[6,0,1],[7,0,1],[10,0,1],[11,7,1],[14,0,1],[15,0,1]],use:"A bridge between offbeat and rolling bass when the energy rises: density first.",confidence:"starting"},{id:"acid-303",name:"Acid line (303)",role:"acid",bars:1,notes:[[0,0,1],[1,0,1],[2,12,1],[3,0,1],[5,0,1],[6,3,1],[7,0,1],[8,0,1],[10,12,1],[11,0,1],[12,7,1],[13,0,1],[15,10,1]],use:"Acid techno: accents on 0, 2, 6, 8, 10, 15, slides into 2, 7, 10, 15; gate about a 32nd; the cutoff starts low and opens over the track.",confidence:"starting"},{id:"sequencer-16ths",name:"Sequencer 16ths (The Bells type)",role:"rolling",bars:1,notes:[[0,0,1],[1,0,1],[2,12,1],[3,0,1],[4,0,1],[5,0,1],[6,12,1],[7,0,1],[8,0,1],[9,0,1],[10,12,1],[11,0,1],[12,0,1],[13,0,1],[14,12,1],[15,0,1]],use:"Peak and second half of a track: unbroken 16ths with a chuffy attack that doubles as a hat line.",confidence:"starting"}],harmony:{scales:["aeolian","phrygian","dorian"],progressions:["minor-pedal","minor-parallel","minor-i-bvii"],changesPer16Bars:[0,4],stab:[0,3,7]},form:{phraseBars:8,layerChangeBars:8,introBars:[16,32],outroBars:[16,32],breakdownBars:[16,32],trackMinutes:[6,8]},gestures:[{target:"lowpass",shape:"opens slowly on bass, 303 or synth — variation without new notes",bars:[8,32],occasion:"a build; on acid across the whole track",confidence:"sourced"},{target:"resonance",shape:"up until it howls",bars:[4,16],occasion:"tension, the peak",confidence:"sourced"},{target:"echo-feedback",shape:"feedback up until the signal breaks away",bars:[1,4],occasion:"a riser or a transition",confidence:"sourced"},{target:"reverb",shape:"wet up on pads and motif, a wash",bars:[8,8],occasion:"the last 8 bars of a breakdown, blurred before the drop",confidence:"sourced"},{target:"drive",shape:"kick distortion held high",bars:null,occasion:"the peak, for hardness",confidence:"sourced"},{target:"lowpass",shape:"closes on the rumble — darker; its reverb stays low",bars:[16,32],occasion:"darkness and depth",confidence:"sourced"},{target:"send",shape:"dub send with filter and delay in a feedback loop, pushed up",bars:[1,4],occasion:"the dub or deep variant",confidence:"sourced"},{target:"mute",shape:"whole layers in and out, on 8-bar boundaries",bars:[8,8],occasion:"the main arranging tool",confidence:"sourced"},{target:"mute",shape:"kick and clap out for the last 2 bars of an 8-bar phrase",bars:[2,2],occasion:"the fill, instead of a programmed drum fill",confidence:"sourced"},{target:"highpass",shape:"a low-cut sweep on the master or the lows rises; off on the drop",bars:[2,8],occasion:"preparing the drop",confidence:"sourced"}],rules:[{id:"tempo",rule:"Tempo core, Berlin / peak time",value:"128–135 BPM, core 130; 120–140 occurs",confidence:"sourced"},{id:"tempo-deep",rule:"Tempo deep / hypnotic / minimal",value:"124–130 BPM",confidence:"sourced"},{id:"tempo-detroit",rule:"Tempo Detroit peak (90s)",value:"130–138 BPM",confidence:"sourced"},{id:"above-140",rule:"Above 140 BPM it is hard techno, another genre",value:"140–160 BPM, median ~155",confidence:"sourced"},{id:"near-straight",rule:"Almost straight; micro-movement instead of swing",value:"50–55 % (Linn = MPC scale); Rolling Techno 20 % Ableton amount ≈ 53 %",confidence:"sourced"},{id:"kick-quarters",rule:"Kick on every quarter",value:"always, except a breakdown or a stop",confidence:"sourced"},{id:"open-hat-offbeat",rule:"Open hat on every offbeat",value:"standard (909 picture)",confidence:"sourced"},{id:"clap",rule:"Clap or snare",value:"two and four standard; variant on two only, with an extra clap in the last bar as a turnaround",confidence:"sourced"},{id:"closed-hat-quiet",rule:"Closed hat around the offbeat, quiet",value:"velocity ≤ 70 %",confidence:"sourced"},{id:"ride",rule:"Ride",value:"eighths, every second hit shorter and quieter",confidence:"sourced"},{id:"hat-microtiming",rule:"Hats move a few ms back and forth",value:"LFO on a 100 % wet delay time",confidence:"sourced"},{id:"bass-off-kick-slot",rule:"A rolling bass never sits on the first 16th of a beat",value:"always",confidence:"sourced"},{id:"bass-sidechain",rule:"A rolling 16th bass is sidechained to the kick",value:"always; an offbeat bass needs less",confidence:"sourced"},{id:"bass-few-notes",rule:"Bass note set",value:"1–3 notes, mostly the root, mono",confidence:"sourced"},{id:"bass-range",rule:"Bass range and band",value:"G1–G2 (~49–98 Hz); high-pass ~65 Hz, low-pass ~350 Hz",confidence:"sourced"},{id:"rumble-is-bass",rule:"In dark / hypnotic techno the rumble is the bass; no second bass at full level",value:"long-decay kick, reverb, low-pass, drive < 4 dB, ducked under the kick; reverb share low",confidence:"sourced"},{id:"harmony",rule:"Harmony",value:"0–1 chord or root change per 4–8 bars; often none, a drone is the harmony",confidence:"sourced"},{id:"parallel-stab",rule:"The stab keeps its shape; only the root moves (parallel), even out of key",value:"minor [0,3,7] or m7 [0,3,7,10]",confidence:"sourced"},{id:"stab-short",rule:"Stab length and place",value:"1/16, syncopated on the offbeats",confidence:"sourced"},{id:"scales",rule:"Scales",value:"aeolian standard; phrygian for darkness, dorian for Detroit warmth (forum consensus only)",confidence:"derived"},{id:"hook",rule:"The hook is a short loop; it varies in sound, not in notes",value:"1–2 bars, 2–4 notes; filter, decay, pitch of single hits",confidence:"sourced"},{id:"layers-8",rule:"Layers enter and leave on 8-bar boundaries",value:"one layer per 8 bars",confidence:"sourced"},{id:"mute-fill",rule:"Fills are mutes, not programmed drum fills",value:"kick and clap out for the last 2 bars of an 8-bar phrase; or the ride cut for 2 bars",confidence:"sourced"},{id:"breakdown",rule:"Breakdown",value:"16–32 bars in 8-bar phases; kick out, or the lows out",confidence:"sourced"},{id:"no-breakdown",rule:"The Berlin / Berghain variant does without a breakdown",value:"kick throughout, gradual builds; relief by subtraction, not by a break",confidence:"sourced"},{id:"build",rule:"Build before a drop",value:"snare roll over 8 bars, getting louder, 32nds at the end; repeats speed up from quarters to eighths in the last 4",confidence:"sourced"},{id:"lows-out",rule:"The lows leave before a drop and return on the downbeat",value:"high-pass or EQ sweep over 2–8 bars",confidence:"sourced"},{id:"stop",rule:"A stop: everything but one element out two beats early, then back",value:"silence before the drop ≤ 1 bar",confidence:"sourced"},{id:"dj-intro-outro",rule:"DJ intro and outro",value:"16–32 bars, multiples of 16; few competing elements; kick and hats stay to the end",confidence:"sourced"},{id:"blend",rule:"Mix strip",value:"blends 16–32 bars; bass swap over 8–16 bars at a phrase change",confidence:"sourced"},{id:"track-length",rule:"Track length",value:"DJ tracks about 6–8 min (practice value); The Bells ~4:40",confidence:"starting"}]},{genreId:"dark-techno",name:"Dark Techno",aliases:["dark","dark techno","industrial techno","industrial","dark minimal","raw hypnotic","rumble techno","Jeff Mills","Surgeon","Regis","Downwards","Perc Trax","Ancient Methods","Paula Temple"],neighbours:["techno","dub-techno","club","deep-house"],tempo:{min:128,max:138,default:132,occurs:[120,145]},swing:{min:50,max:56,default:52},grids:[{voice:"kick",name:"Four to the floor, short and compressed",steps:[0,4,8,12],confidence:"sourced"},{voice:"kick",name:"Ghost kicks before two and four",steps:[0,3,4,8,11,12],quiet:[3,11],confidence:"derived"},{voice:"clap",name:"Clap on two only",steps:[4],confidence:"sourced"},{voice:"snare",name:"Distorted noise snare on two and four",steps:[4,12],confidence:"sourced"},{voice:"hat-closed",name:"Closed hat on the offbeats, low velocity",steps:[2,6,10,14],confidence:"derived"},{voice:"hat-open",name:"Long filtered open hat, twice a bar",steps:[2,10],gate:4,confidence:"derived"},{voice:"shaker",name:"Offbeat shaker, every second hit quiet",steps:[2,6,10,14],quiet:[6,14],confidence:"derived"},{voice:"shaker",name:"Every second offbeat (industrial)",steps:[6,14],confidence:"derived"},{voice:"ride",name:"Eighth ride, every second one shorter and quiet",steps:[0,2,4,6,8,10,12,14],quiet:[2,6,10,14],confidence:"derived"},{voice:"tom",name:"Rolling toms in 16ths",steps:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],confidence:"derived"},{voice:"perc",name:"Noise breath on two and four",steps:[4,12],confidence:"derived"},{voice:"stab",name:"Distorted noise stab on three, every second bar also before four",steps:[8,24,27],bars:2,confidence:"derived"}],basslines:[{id:"rolling-one-note",name:"Rolling 16ths, one note",role:"rolling",bars:1,notes:[[1,0,1],[2,0,1],[3,0,1],[5,0,1],[6,0,1],[7,0,1],[9,0,1],[10,0,1],[11,0,1],[13,0,1],[14,0,1],[15,0,1]],use:"Warehouse rolling: the root on every 16th but the first of each beat, sidechained to the kick.",confidence:"sourced"},{id:"gallop-thinned",name:"Gallop (two of three)",role:"gallop",bars:1,notes:[[1,0,1],[2,0,1],[5,0,1],[6,0,1],[9,0,1],[10,0,1],[13,0,1],[14,0,1]],use:"The rolling line thinned out by leaving 16ths away, as a variation.",confidence:"starting"},{id:"offbeat-pulse",name:"Offbeat pulse",role:"pulse",bars:1,notes:[[2,0,1],[6,0,1],[10,0,1],[14,0,1]],use:"Short root on every offbeat to stay out of the kick's way; darker with +12 or a distorted layer.",confidence:"sourced"},{id:"chug-flat-two",name:"Chug with a flat second",role:"rolling",bars:1,notes:[[1,0,1],[2,0,1],[3,0,1],[5,0,1],[6,0,1],[7,0,1],[9,0,1],[10,0,1],[11,0,1],[13,0,1],[14,1,1],[15,0,1]],use:"The one-note chug, with the phrygian flat second as a tension note in the last beat.",confidence:"starting"},{id:"ebm-octave",name:"EBM sequence with one octave jump",role:"rolling",bars:1,notes:[[0,0,1],[1,0,1],[2,0,1],[3,0,1],[4,0,1],[5,0,1],[6,0,1],[7,0,1],[8,0,1],[9,0,1],[10,0,1],[11,0,1],[12,0,1],[13,12,1],[14,0,1],[15,0,1]],use:"Industrial and EBM-leaning tracks: straight staccato 16ths that stick to the kick; one octave a bar — more jumps sound busy.",confidence:"starting"}],harmony:{scales:["aeolian","phrygian"],progressions:["minor-pedal","phrygian-i-bii","minor-i-bvii"],changesPer16Bars:[0,2],stab:[0,3,7]},form:{phraseBars:8,layerChangeBars:8,introBars:[16,64],outroBars:[32,32],breakdownBars:null,trackMinutes:[5,8]},gestures:[{target:"send",shape:"rumble level and reverb send move slightly, about ±1–2 dB",bars:[8,8],occasion:"life in the core",confidence:"sourced"},{target:"lowpass",shape:"the low-pass on the rumble closes: darker",bars:[8,16],occasion:"darkness and tension over a phrase",confidence:"derived"},{target:"resonance",shape:"resonance on the rumble filter up: pressure in the mids",bars:[8,16],occasion:"tension over a phrase",confidence:"derived"},{target:"filter-lfo",shape:"a tempo-synced LFO on the rumble filter",bars:null,occasion:"movement inside the reverb, throughout",confidence:"sourced"},{target:"drive",shape:"parallel distortion and drive on the drum bus rise",bars:[4,8],occasion:"a section change, or the build before a return",confidence:"derived"},{target:"lowpass",shape:"the stab or pad filter opens in a break, closes after the return",bars:[4,16],occasion:"a break and its build",confidence:"derived"},{target:"reverb",shape:"reverb and delay wash up in the break, back to dry on the return",bars:[4,16],occasion:"contrast that makes the return hit harder",confidence:"derived"},{target:"lowpass",shape:"the bass filter moves slowly while the bass runs alone",bars:[16,16],occasion:"the bass-alone stretch",confidence:"sourced"},{target:"mute",shape:"hats, rides and clap out for one bar after seven; kick and clap out for the last two bars of a phrase",bars:[1,2],occasion:"the fill — subtraction instead of a roll",confidence:"sourced"},{target:"mute",shape:"a second kick or the rides in and out, almost at random",bars:[1,4],occasion:"a live feel",confidence:"sourced"},{target:"highpass",shape:"a low-cut sweep on the master or the bass rises; off on the return",bars:[2,8],occasion:"announcing the return",confidence:"sourced"}],rules:[{id:"tempo",rule:"Tempo core",value:"128–138 BPM, default 132; industrial 132–145 around 138; slow Dark Berlin from 120",confidence:"sourced"},{id:"hard-techno-border",rule:"From about 145 BPM with a distorted kick it is hard techno, not dark",value:"border, the sound decides as much as the tempo",confidence:"sourced"},{id:"swing-hats-only",rule:"Swing only on hats and perc; kick and bass stay straight",value:"hats/perc 50–56 %, default 52 %; kick/bass 50 %",confidence:"sourced"},{id:"kick-quarters",rule:"Kick on every quarter",value:"always; variation from ghost kicks on 3 and 11 or a second low kick",confidence:"sourced"},{id:"clap-sparse",rule:"Clap or snare is optional and sparse, and comes late",value:"on 2 and 4, on 2 only, or none; not before bar 17",confidence:"sourced"},{id:"offbeat-hat",rule:"Hat on the offbeats",value:"standard (2, 6, 10, 14)",confidence:"sourced"},{id:"velocity-alternate",rule:"Every second hat or shaker hit is quieter",value:"yes",confidence:"sourced"},{id:"perc-collisions",rule:"Perc velocity goes down where it falls on a kick or hat",value:"yes",confidence:"sourced"},{id:"bass-off-kick",rule:"The bass stays off the kick steps",value:"mostly; EBM sequences are the exception",confidence:"sourced"},{id:"rumble-ducked",rule:"Rumble and sub are ducked against the kick; the sidechain stays fixed and tight",value:"always",confidence:"sourced"},{id:"rumble-mono",rule:"Rumble and sub are mono and low-passed",value:"low-pass 150–250 Hz, high-pass 20–25 Hz",confidence:"sourced"},{id:"same-root",rule:"Kick and bass are tuned to the same root",value:"always",confidence:"sourced"},{id:"one-low-voice",rule:"Only one low voice leads at full level",value:"rumble OR bass line OR tom 16ths",confidence:"sourced"},{id:"bass-late-guest",rule:"The bass may be a late guest, not the foundation from bar 1",value:"entry after 1–2 min (around bar 65) is possible",confidence:"sourced"},{id:"little-harmony",rule:"Harmony",value:"0–2 chords per track; a drone on the root for minutes is normal",confidence:"sourced"},{id:"mode",rule:"Mode",value:"aeolian by default, phrygian (flat 2) for the dark colour; locrian only in passing",confidence:"sourced"},{id:"no-rest-on-tension",rule:"Flat 2, flat 5 and flat 6 are never resting notes",value:"passing tones and pendulums over a stable root",confidence:"sourced"},{id:"progressions-unsourced",rule:"No source gives dark-techno chord progressions",value:"i–♭II, i–♭VII are starting values, 2–8 bars per chord; or the whole loop shifted ±1 semitone",confidence:"starting"},{id:"parallel-chords",rule:"A chord change is the same shape shifted in parallel",value:"preferred; leaving the key is intended",confidence:"sourced"},{id:"stab-short",rule:"Stab length",value:"one 16th, accented beside the downbeat",confidence:"sourced"},{id:"motif",rule:"The motif is one bar, repeated endlessly; layers switch in 2- and 4-bar phrases",value:"1 bar",confidence:"sourced"},{id:"few-elements",rule:"Few elements at once",value:"never more than a few; minimal arrangement, maximal energy",confidence:"sourced"},{id:"phrase-entries",rule:"Entries on phrase boundaries",value:"8-bar grid (bars 1, 9, 17, 33, 65 …); about one audible change per 8 bars",confidence:"sourced"},{id:"fill-subtraction",rule:"A fill is a subtraction",value:"hats/rides/clap out 1 bar after 7; kick out at most 2 bars; 4 bars of kick and motif alone before everything returns",confidence:"sourced"},{id:"dj-intro-outro",rule:"DJ intro and outro",value:"32 bars each; intro kick and perc only, outro may drop the kick",confidence:"sourced"},{id:"no-drop",rule:"No obligatory drop or climax; hold the pressure",value:"a long groove plane with 1–2 breaks",confidence:"sourced"},{id:"breakdown-optional",rule:"If there is a breakdown",value:"16–32 bars; a halftime break in industrial 8–16 bars (one editorial source)",confidence:"derived"},{id:"layer-order",rule:"Layers up: hats, ride, clap, motif or stab, bass; down in reverse",value:"the low voice is the first out before a break and the last back",confidence:"sourced"},{id:"tension-levers",rule:"The tension levers",value:"filter resonance, drive, reverb send",confidence:"sourced"},{id:"wash-contrast",rule:"Wash contrast",value:"reverb/delay up in the break, dry on the return",confidence:"sourced"},{id:"distortion",rule:"Distortion everywhere is a feature",value:"kick, perc, noise stabs; conventional reverb rarely, except as the rumble source",confidence:"sourced"}]}].map(e=>[e.genreId,e])),_=(e,t,n)=>({from:e,to:t,confidence:n}),K=[{kind:"arc",id:"freytag",name:"Freytag-Pyramide",aliases:["Pyramide","Fünf-Akt-Struktur","Freytag's pyramid"],phases:[{name:"Einleitung",role:"exposition",at:[0,.15],does:"Den Grundton setzen, den Zustand vor der bewegenden Kraft zeigen.",confidence:"derived"},{name:"Steigerung",role:"rise",at:[.15,.45],does:"In Stufen wachsen, jede größer als die vorige.",confidence:"derived"},{name:"Höhenpunkt",role:"climax",at:[.45,.55],does:"Eine groß ausgeführte Szene, in der das Ergebnis des Aufstiegs heraustritt.",confidence:"derived"},{name:"Fall und Umkehr",role:"rise",at:[.55,.85],does:"Nach einer Pause die Spannung neu erregen; die Bühnenwirkung steigt weiter.",confidence:"derived"},{name:"Katastrophe",role:"climax",at:[.85,.95],does:"Eine kräftige Tat löst die Verstrickung.",confidence:"derived"},{name:"Ausklang",role:"resolution",at:[.95,1],does:"Ein beruhigendes Allgemeines.",confidence:"derived"}],curve:[[0,.15,.05],[.12,.25,.3],[.3,.45,.5],[.45,.75,.75],[.52,.85,.6],[.6,.55,.4],[.75,.7,.7],[.84,.55,.9],[.93,.95,.6],[1,.3,.05]],curveConfidence:"derived"},{kind:"arc",id:"three-act",name:"Dreiakter",aliases:["Drei-Akt-Struktur","three-act structure","Paradigma"],phases:[{name:"Akt I",role:"exposition",at:[0,.25],does:"Welt und Ausgangslage, ein früher Auslöser.",confidence:"sourced"},{name:"Akt II, erste Hälfte",role:"rise",at:[.25,.5],does:"Hindernisse wachsen bis zur Mitte.",confidence:"sourced"},{name:"Akt II, zweite Hälfte",role:"turn",at:[.5,.75],does:"Der Druck steigt bis zum Tiefpunkt: wenig Energie, große Spannung.",confidence:"derived"},{name:"Akt III",role:"climax",at:[.75,.95],does:"Die Entscheidung.",confidence:"derived"},{name:"Auflösung",role:"resolution",at:[.95,1],does:"Ein neues Gleichgewicht.",confidence:"derived"}],curve:[[0,.15,.05],[.12,.25,.25],[.25,.45,.5],[.5,.65,.6],[.7,.3,.8],[.75,.5,.85],[.9,1,.95],[.95,.6,.2],[1,.2,0]],curveConfidence:"derived"},{kind:"arc",id:"kishotenketsu",name:"Kishōtenketsu",aliases:["起承転結","Ki-Shō-Ten-Ketsu","Vier-Teile-Form"],phases:[{name:"Ki",role:"exposition",at:[0,.25],does:"Lage, Ort, Stimmung.",confidence:"derived"},{name:"Shō",role:"rise",at:[.25,.5],does:"Dasselbe vertiefen, ohne neue Richtung.",confidence:"derived"},{name:"Ten",role:"turn",at:[.5,.75],does:"Etwas scheinbar Fremdes tritt hinzu; die Spannung springt, die Energie nicht.",confidence:"derived"},{name:"Ketsu",role:"resolution",at:[.75,1],does:"Beides zeigt sich als zusammengehörig: Einsicht statt Sieg.",confidence:"derived"}],curve:[[0,.2,.05],[.25,.3,.1],[.5,.35,.15],[.55,.45,.6],[.75,.4,.7],[.9,.35,.2],[1,.25,0]],curveConfidence:"derived"},{kind:"arc",id:"short-film",name:"Kurzfilm-Bogen",aliases:["Kurzfilm","short film","spät hinein, früh hinaus"],phases:[{name:"Einstieg mitten drin",role:"exposition",at:[0,.1],does:"Lage und Frage im selben ersten Bild.",confidence:"derived"},{name:"Entfaltung",role:"rise",at:[.1,.75],does:"Variationen der einen Idee, schrittweise zugespitzt.",confidence:"derived"},{name:"Wendung",role:"turn",at:[.75,.82],does:"Die Idee kippt und zeigt ihre andere Seite.",confidence:"starting"},{name:"Gipfel",role:"climax",at:[.82,.9],does:"Der eine große Moment.",confidence:"starting"},{name:"Nachbild",role:"resolution",at:[.9,1],does:"Ein kurzes Bild, das die Wendung stehen lässt.",confidence:"derived"}],curve:[[0,.35,.3],[.3,.45,.45],[.6,.6,.65],[.78,.7,.9],[.82,.9,.5],[.92,.4,.2],[1,.2,.1]],curveConfidence:"starting"},{kind:"arc",id:"club-set",name:"Club-Set",aliases:["DJ-Set","Set-Bogen","peak time","Wellen"],phases:[{name:"Ankommen",role:"exposition",at:[0,.15],does:"Den Raum füllen, nicht gipfeln.",confidence:"sourced"},{name:"Aufbau",role:"rise",at:[.15,.55],does:"In Wellen und Stufen heben, mit Atempausen dazwischen.",confidence:"derived"},{name:"Peak Time",role:"climax",at:[.55,.75],does:"Über mehrere Tracks auf den großen Moment hinführen.",confidence:"derived"},{name:"Nachwelle",role:"release",at:[.75,.9],does:"Eine kleinere Welle nach dem Gipfel.",confidence:"derived"},{name:"Abklang",role:"resolution",at:[.9,1],does:"Die Leute leicht entlassen.",confidence:"sourced"}],curve:[[0,.1,.05],[.12,.25,.15],[.25,.45,.35],[.32,.35,.5],[.42,.6,.55],[.5,.45,.6],[.58,.75,.75],[.66,1,.8],[.75,.7,.4],[.85,.8,.5],[.93,.5,.2],[1,.2,0]],curveConfidence:"derived"},{kind:"arc",id:"break-routine",name:"Breakdown–Build–Drop",aliases:["Break-Routine","Drop","Breakdown","Build-up"],phases:[{name:"Breakdown",role:"release",at:[0,.35],does:"Dünne Textur, keine Drums, gewollte Desorientierung.",confidence:"sourced"},{name:"Build",role:"rise",at:[.35,.78],does:"Energie und Spannung steigen: Filter, Wirbel, Riser.",confidence:"sourced"},{name:"Break und Cue",role:"turn",at:[.78,.82],does:"Plötzlicher Entzug, ein kurzes Auftaktsignal.",confidence:"sourced"},{name:"Drop",role:"climax",at:[.82,1],does:"Alle Schichten kehren auf einen Schlag zurück.",confidence:"sourced"}],curve:[[0,.3,.4],[.35,.35,.55],[.5,.55,.75],[.78,.8,.9],[.8,.1,1],[.82,1,.2],[1,.95,.15]],curveConfidence:"derived"},{kind:"moment",id:"inciting",name:"Erregendes Moment",aliases:["Auslöser","inciting incident"],role:"rise",at:[.1,.15],bars:[1,4],before:"Ruhe, der Zustand.",after:"Die erste Stufe der Steigerung.",image:{motion:.3},confidence:"derived"},{kind:"moment",id:"reversal",name:"Umkehr",aliases:["tragisches Moment","Peripetie","reversal"],role:"turn",at:[.5,.6],bars:[2,8],before:"Der Gipfel.",after:"Eine Pause, dann die fallende Handlung.",image:{warmth:-.6,light:-.6},confidence:"derived"},{kind:"moment",id:"last-suspense",name:"Letzte Spannung",aliases:["Moment der letzten Spannung","Aufschub"],role:"turn",at:[.8,.88],bars:[2,4],before:"Die Umkehr.",after:"Das Finale.",image:{light:-.3},confidence:"derived"},{kind:"moment",id:"silence-before-the-hit",name:"Stille vor dem Schlag",aliases:["Break vor dem Drop","Cue","Blackout vor dem Drop"],role:"turn",at:null,bars:[.25,1],before:"Der Aufbau.",after:"Der Drop, der Höhepunkt.",image:{light:-1,motion:-1},confidence:"sourced"},{kind:"moment",id:"return",name:"Wiederkehr",aliases:["Rekapitulation","Reprise"],role:"climax",at:[.75,.95],bars:[4,16],before:"Ferne, Entwicklung.",after:"Der Abschluss.",image:{density:.6},confidence:"derived"},{kind:"moment",id:"false-ending",name:"Falsches Ende",aliases:["Scheinschluss","false ending"],role:"turn",at:[.85,.95],bars:[1,2],before:"Ein Gipfel.",after:"Ein letzter Gipfel.",image:{light:-1,motion:-1},confidence:"starting"},{kind:"moment",id:"reveal",name:"Enthüllung",aliases:["Erkennung","Anagnorisis","reveal"],role:"turn",at:null,bars:[2,8],before:"Rätsel, Verhüllung.",after:"Eine neue Lage.",image:{light:.5,nearness:-.4},confidence:"starting"},{kind:"moment",id:"pursuit",name:"Verfolgung",aliases:["Polti V","Flucht","Jagd"],role:"rise",at:null,bars:[8,32],before:"Ein Auslöser.",after:"Rettung oder Unheil.",image:{nearness:.8,motion:.6},confidence:"derived"},{kind:"moment",id:"rescue",name:"Rettung",aliases:["Polti II","Retter"],role:"release",at:null,bars:[2,8],before:"Bedrohung, Verfolgung.",after:"Erleichterung.",image:{light:.6},confidence:"starting"},{kind:"moment",id:"daring",name:"Wagnis",aliases:["Polti IX","Aufbruch","Expedition"],role:"rise",at:null,bars:[8,32],before:"Die Vorbereitung.",after:"Ein Gipfel, oder ein offener Schluss.",image:{motion:.5},confidence:"starting"},{kind:"moment",id:"disaster",name:"Unheil",aliases:["Polti VI","Sturz","Einbruch"],role:"turn",at:null,bars:[1,4],before:"Höhe und Glanz.",after:"Trümmer, Stille.",image:{nearness:.8,light:-.5},confidence:"derived"},{kind:"moment",id:"loss",name:"Verlust",aliases:["Polti XXXVI","Trauer"],role:"release",at:null,bars:[8,32],before:"Ein Unheil.",after:"Ruhe, Auflösung.",image:{density:-.8,motion:-.5},confidence:"starting"},{kind:"image",id:"exposition",name:"Exposition im Bild",aliases:["Einleitung","Setup","Ankommen"],role:"exposition",axes:{light:_(.3,.3,"sourced"),contrast:_(-.3,-.3,"derived"),warmth:_(0,0,"starting"),density:_(-.5,-.5,"derived"),nearness:_(-.6,-.6,"sourced"),motion:_(-.7,-.7,"sourced")},music:"Wenige Schichten, der Grundton steht; im Club ohne Gipfel, im langen Set auch ohne Kick."},{kind:"image",id:"rise",name:"Steigerung im Bild",aliases:["Aufbau","Build","rising action"],role:"rise",axes:{light:_(0,-.4,"sourced"),contrast:_(.1,.4,"derived"),warmth:_(.1,.4,"starting"),density:_(.2,.5,"starting"),nearness:_(.1,.4,"derived"),motion:_(.1,.5,"starting")},music:"Schichten kommen hinzu, Filter öffnen sich; zuerst wird es schneller und dichter, noch nicht höher."},{kind:"image",id:"climax",name:"Höhepunkt im Bild",aliases:["Gipfel","Peak","Drop","climax"],role:"climax",axes:{light:_(-.2,.8,"sourced"),contrast:_(.9,.9,"derived"),warmth:_(.5,.5,"starting"),density:_(.9,.9,"derived"),nearness:_(.8,.8,"derived"),motion:_(1,.6,"sourced")},music:"Alle Schichten, der Drop auf einen Schlag; danach trägt die volle Textur."},{kind:"image",id:"turn",name:"Umkehr im Bild",aliases:["Bruch","Wendung","Breakdown vor dem Drop","Tiefpunkt"],role:"turn",axes:{light:_(-.8,-.8,"derived"),contrast:_(.6,.6,"derived"),warmth:_(-.5,-.5,"starting"),density:_(-.7,-.7,"starting"),nearness:_(.5,.5,"starting"),motion:_(-.9,-.9,"derived")},music:"Entzug: Kick und Bass weg, wenig bleibt stehen, die Spannung staut sich."},{kind:"image",id:"release",name:"Entladung im Bild",aliases:["Nachwelle","fallende Handlung","Breakdown"],role:"release",axes:{light:_(.4,.4,"derived"),contrast:_(-.4,-.4,"derived"),warmth:_(.3,.3,"starting"),density:_(-.2,-.4,"starting"),nearness:_(-.3,-.5,"derived"),motion:_(-.4,-.6,"sourced")},music:"Weniger Schichten, ein minimales Bild nach dem Gipfel, Raum zum Atmen vor der nächsten Welle."},{kind:"image",id:"resolution",name:"Auflösung im Bild",aliases:["Schluss","Abklang","Outro","Nachbild"],role:"resolution",axes:{light:_(.5,.5,"derived"),contrast:_(-.6,-.6,"starting"),warmth:_(.4,.4,"starting"),density:_(-.5,-.5,"starting"),nearness:_(-.7,-.7,"derived"),motion:_(-.8,-.8,"sourced")},music:"Die Energie sinkt, die Leute werden leicht entlassen; melodisch, offen."},{kind:"rules",id:"motion",name:"Bewegungsregeln",aliases:["Animationsprinzipien","twelve principles","Timing"],rules:[{id:"anticipation",rule:"Vor dem Höhepunkt eine Gegenbewegung: kurz dunkler, ruhiger — dann der Schlag.",value:"mindestens 1 Schlag, typisch 1 Takt; je größer der Gipfel, desto länger",confidence:"derived"},{id:"follow-through",rule:"Nichts stoppt als Ganzes: erst fällt das Licht, später dünnt die Menge aus, der Nebel hängt am längsten.",value:"je Ebene 1 Schlag bis 1 Takt später",confidence:"starting"},{id:"slow-in-out",rule:"Fades und Posenwechsel an den Enden langsam, in der Mitte schnell; Helligkeit wahrnehmungsgleich.",value:"S-Kurve; Helligkeit über eine Wurzel",confidence:"sourced"},{id:"staging",rule:"Eine Hauptgeste auf einmal; in einer wilden Szene ist der eine Stillstehende das Ereignis.",value:"eine Hauptgeste je Moment",confidence:"sourced"},{id:"exaggeration",rule:"Übertreibung gehört dem Höhepunkt: mehrere Achsen zugleich, keine über das Stimmige hinaus.",value:"Überschwingen nur am Höhepunkt, höchstens 10 %, abgeklungen in 1 Takt",confidence:"starting"},{id:"timing",rule:"Dieselbe Pose, andere Dauer, andere Bedeutung: schnell ist ein Schlag, langsam ein Nachdenken.",value:"≤ 0,1 s Schlag · ~0,2 s entschieden · ~0,3 s einladend · ≥ 0,4 s nachdenklich",confidence:"derived"},{id:"secondary-action",rule:"Eine Folgebewegung (Nebel, Haare, Wolken) bleibt kleiner als die Hauptgeste.",value:"höchstens die halbe Auslenkung der Hauptgeste",confidence:"starting"}]},{kind:"rules",id:"light-practice",name:"Licht zur Musik",aliases:["Lichtdesign","VJ","Busking","Club-Licht"],rules:[{id:"big-cues-big-moments",rule:"Große Cues nur auf große Momente der Musik, nicht auf jeden Schlag.",value:"Drop, Abschnittsgrenze",confidence:"sourced"},{id:"black-before",rule:"Schwarz ist der stärkste Cue — unmittelbar vor einem großen Effekt.",value:"so lang wie die Lücke in der Musik, endet auf dem Drop-Schlag",confidence:"sourced"},{id:"black-wears-off",rule:"Schwarz nutzt sich ab; nicht bei jedem Drop.",value:"Art der Dunkelheit wechseln",confidence:"sourced"},{id:"strobe-is-a-peak",rule:"Strobe ist ein Gipfel, kein Zustand; dazwischen ruhig.",value:"ein Stoß von 1–2 Takten, nie zwei Strobe-Gipfel hintereinander",confidence:"derived"},{id:"save-the-tricks",rule:"Nicht zu früh alles zeigen: Spezialeffekte erst spät.",value:"bis zur Hälfte höchstens ~70 % von Licht und Dichte",confidence:"derived"},{id:"waves",rule:"Wellen statt Dauersteigerung: nach einem starken Gipfel ein minimales Bild, dann neu aufbauen.",value:"zwei gleich hohe Gipfel hintereinander vermeiden",confidence:"sourced"},{id:"base-and-accent",rule:"Ein Viertel der Mittel trägt das Grundbild, der Rest ist Reserve für die Steigerung.",value:"~25 % Grund",confidence:"derived"},{id:"colour-per-section",rule:"Pro Abschnitt eine Grundfarbe und höchstens ein Akzent; Wechsel auf Abschnittsgrenzen.",value:"1 + 1",confidence:"starting"},{id:"flash-limit",rule:"Das ganze Bild blitzt höchstens dreimal in der Sekunde — die Grenze für photosensitive Menschen.",value:"≤ 3 Hz",confidence:"sourced"},{id:"break-is-not-drop",rule:"Breakdown und Drop nie gleich behandeln; vor dem Drop auf ein ruhiges, schwebendes Bild.",value:"Breakdown weich, Drop hart",confidence:"sourced"}]}],G=(Object.fromEntries(K.map(e=>[e.id,e])),Object.fromEntries([{modeId:"ionian",modeName:"Ionisch (Dur)",exampleRootMidi:60,intervals:[0,2,4,5,7,9,11],spelling:"sharp",character:"hell, freudig, offen — der klassische Dur-Klang",tuning:"12tet",quantizerEnum:0,aliases:["Dur","major","C major","C-Dur","natural major","Mode I"]},{modeId:"dorian",modeName:"Dorisch",exampleRootMidi:62,intervals:[0,2,3,5,7,9,10],spelling:"sharp",character:"moll-getönt aber heller als natürlich-Moll — Jazz, Funk, Folk",tuning:"12tet",quantizerEnum:1,aliases:["Dorian","minor with raised 6th","D Dorian","Mode II"]},{modeId:"phrygian",modeName:"Phrygisch",exampleRootMidi:64,intervals:[0,1,3,5,7,8,10],spelling:"flat",character:"dunkel, exotisch, flamenco-/spanisch — verminderte 2. Stufe ist die Signatur",tuning:"12tet",quantizerEnum:2,aliases:["Phrygian","Spanish minor","E Phrygian","Mode III"]},{modeId:"lydian",modeName:"Lydisch",exampleRootMidi:65,intervals:[0,2,4,6,7,9,11],spelling:"sharp",character:"schwebend, traumhaft, filmisch — erhöhte 4. Stufe (Tritonus) ist die Signatur",tuning:"12tet",quantizerEnum:3,aliases:["Lydian","F Lydian","major with raised 4th","Mode IV"]},{modeId:"mixolydian",modeName:"Mixolydisch",exampleRootMidi:67,intervals:[0,2,4,5,7,9,10],spelling:"sharp",character:"dur-getönt mit weicher 7. Stufe — Blues, Rock, Celtic Folk",tuning:"12tet",quantizerEnum:4,aliases:["Mixolydian","G Mixolydian","major with flat 7th","Mode V","dominant scale"]},{modeId:"aeolian",modeName:"Aeolisch (natürliches Moll)",exampleRootMidi:69,intervals:[0,2,3,5,7,8,10],spelling:"sharp",character:'melancholisch, kontemplativ — der "Pop-Moll"-Klang',tuning:"12tet",quantizerEnum:5,aliases:["Aeolian","natural minor","natürliches Moll","A minor","A-Moll","Moll","minor","Mode VI"]},{modeId:"locrian",modeName:"Lokrisch",exampleRootMidi:71,intervals:[0,1,3,5,6,8,10],spelling:"flat",character:"extrem dissonant, instabil — verminderte 5. macht die Tonika schwebend, kein klassischer Ruhepunkt",tuning:"12tet",quantizerEnum:6,aliases:["Locrian","B Locrian","half-diminished","Mode VII"]},{modeId:"harmonic-minor",modeName:"Harmonisch Moll",exampleRootMidi:69,intervals:[0,2,3,5,7,8,11],spelling:"sharp",character:"dramatisch, orientalisch — die erhöhte 7. erzeugt einen kraftvollen Leitton zur Tonika",tuning:"12tet",quantizerEnum:null,aliases:["harmonic minor","harmonisch Moll","A harmonic minor","minor with raised 7th"]},{modeId:"melodic-minor",modeName:"Melodisch Moll (aufsteigend)",exampleRootMidi:69,intervals:[0,2,3,5,7,9,11],spelling:"sharp",character:"Jazz-Standard, kontextabhängig changierender Charakter — 6. und 7. Stufe erhöht beim Aufstieg",tuning:"12tet",quantizerEnum:null,aliases:["melodic minor","melodisch Moll","A melodic minor","jazz minor","ascending melodic minor"]},{modeId:"pentatonic-major",modeName:"Dur-Pentatonik",exampleRootMidi:60,intervals:[0,2,4,7,9],spelling:"sharp",character:"einfach, universell, kann fast nie falsch klingen — Country, Folk, Pop-Hooks, Kinderlied",tuning:"12tet",quantizerEnum:null,aliases:["major pentatonic","Dur-Pentatonik","C major pentatonic","pentatonic","5-note scale"]},{modeId:"pentatonic-minor",modeName:"Moll-Pentatonik",exampleRootMidi:69,intervals:[0,3,5,7,10],spelling:"sharp",character:"Rock / Blues / Pop Lead-Standard — perfekt zum Improvisieren über fast jede Moll-Progression",tuning:"12tet",quantizerEnum:null,aliases:["minor pentatonic","Moll-Pentatonik","A minor pentatonic","pentatonic minor","rock pentatonic","blues scale base"]},{modeId:"blues",modeName:"Blues-Skala (Moll)",exampleRootMidi:69,intervals:[0,3,5,6,7,10],spelling:"flat",character:'klassischer Blues / Rock-Lead — die "Blue Note" (verminderte 5.) gibt den charakteristischen Crunch',tuning:"12tet",quantizerEnum:null,aliases:["blues scale","Blues-Skala","A blues","minor blues","hexatonic blues","blue note scale"]}].map(e=>[e.modeId,e]))),H=(Object.fromEntries([{qualityId:"major-triad",qualityName:"Dur-Dreiklang",exampleRootMidi:60,intervals:[0,4,7],spelling:"sharp",symbolSuffix:"",character:"hell, freudig, stabil — der klassische Dur-Akkord",tuning:"12tet",aliases:["major","major triad","Dur","Dur-Akkord","M","maj"]},{qualityId:"minor-triad",qualityName:"Moll-Dreiklang",exampleRootMidi:60,intervals:[0,3,7],spelling:"flat",symbolSuffix:"m",character:"traurig, kontemplativ — der Default-Moll-Klang in Pop / Rock",tuning:"12tet",aliases:["minor","minor triad","Moll","Moll-Akkord","m","min","mi"]},{qualityId:"diminished-triad",qualityName:"Verminderter Dreiklang",exampleRootMidi:60,intervals:[0,3,6],spelling:"flat",symbolSuffix:"dim",character:"instabil, dunkel, gespannt — verlangt nach Auflösung",tuning:"12tet",aliases:["diminished","dim","vermindert","°","o"]},{qualityId:"augmented-triad",qualityName:"Übermäßiger Dreiklang",exampleRootMidi:60,intervals:[0,4,8],spelling:"sharp",symbolSuffix:"aug",character:"schwebend, mehrdeutig, symmetrisch — alle drei Töne im Ganztonschritt zueinander",tuning:"12tet",aliases:["augmented","aug","übermäßig","+","#5"]},{qualityId:"sus2",qualityName:"Sus2-Akkord",exampleRootMidi:60,intervals:[0,2,7],spelling:"sharp",symbolSuffix:"sus2",character:"offen, schwebend, weder Dur noch Moll — die Terz fehlt",tuning:"12tet",aliases:["sus2","suspended 2nd","suspended second"]},{qualityId:"sus4",qualityName:"Sus4-Akkord",exampleRootMidi:60,intervals:[0,5,7],spelling:"sharp",symbolSuffix:"sus4",character:"gespannt, drängend zur Auflösung in die Dur-Terz — klassisch in Folk und Rock-Intros",tuning:"12tet",aliases:["sus4","suspended 4th","suspended fourth","sus"]},{qualityId:"major7",qualityName:"Dur-Septakkord (Maj7)",exampleRootMidi:60,intervals:[0,4,7,11],spelling:"sharp",symbolSuffix:"maj7",character:"verträumt, jazzig, weich — typischer Bossa / Smooth-Pop-Klang",tuning:"12tet",aliases:["major 7","major 7th","maj7","Maj7","M7","Δ7","Dur 7","Dur-Septakkord"]},{qualityId:"minor7",qualityName:"Moll-Septakkord (m7)",exampleRootMidi:60,intervals:[0,3,7,10],spelling:"flat",symbolSuffix:"m7",character:"weich, jazzig, neutral-melancholisch — Soul- und Jazz-Standardakkord",tuning:"12tet",aliases:["minor 7","minor 7th","m7","min7","mi7","Moll 7","Moll-Septakkord"]},{qualityId:"dominant7",qualityName:"Dominantseptakkord (7)",exampleRootMidi:60,intervals:[0,4,7,10],spelling:"flat",symbolSuffix:"7",character:"spannungsreich, drängend, bluesig — verlangt nach Auflösung in den Dur-Tonika",tuning:"12tet",aliases:["dominant 7","dominant 7th","7","dom7","V7"]},{qualityId:"half-diminished",qualityName:"Halbverminderter Septakkord (m7♭5)",exampleRootMidi:60,intervals:[0,3,6,10],spelling:"flat",symbolSuffix:"m7♭5",character:"düster, schwebend, leicht-dissonant — Jazz-ii in Moll-ii-V-i-Kadenz",tuning:"12tet",aliases:["half-diminished","half diminished","halbvermindert","m7b5","m7♭5","minor 7 flat 5","ø7","ø"]},{qualityId:"diminished7",qualityName:"Verminderter Septakkord (dim7)",exampleRootMidi:60,intervals:[0,3,6,9],spelling:"flat",symbolSuffix:"dim7",character:"extrem dissonant, symmetrisch (alle kleinen Terzen) — dramatisch in Klassik und Filmmusik",tuning:"12tet",aliases:["diminished 7","diminished 7th","dim7","°7","fully diminished","vollvermindert"]},{qualityId:"minor-major7",qualityName:"Moll-Dur-Septakkord (mMaj7)",exampleRootMidi:60,intervals:[0,3,7,11],spelling:"sharp",symbolSuffix:"mMaj7",character:'mysteriös, filmisch — der „James-Bond-Akkord", spannungsreich aber elegant',tuning:"12tet",aliases:["minor-major 7","minor major 7","mMaj7","m(maj7)","minMaj7","mΔ7","James Bond chord"]}].map(e=>[e.qualityId,e])),Object.fromEntries([{chordId:"c",chordName:"C",qualityId:"major-triad",rootMidi:60,spelling:"sharp",scaleDegreeIn:[{keyName:"C-Dur",degree:"I",role:"Tonika"},{keyName:"G-Dur",degree:"IV",role:"Subdominante"},{keyName:"F-Dur",degree:"V",role:"Dominante"},{keyName:"A-Moll",degree:"♭III",role:"Tonika-Parallele"}],aliases:["C major","C","C-Dur","C Dur-Dreiklang"]},{chordId:"dm",chordName:"Dm",qualityId:"minor-triad",rootMidi:62,spelling:"flat",scaleDegreeIn:[{keyName:"C-Dur",degree:"ii",role:"Subdominanten-Parallele"},{keyName:"F-Dur",degree:"vi",role:"Tonika-Parallele"},{keyName:"A-Moll",degree:"iv",role:"Subdominante"},{keyName:"D-Moll",degree:"i",role:"Tonika"}],aliases:["D minor","Dm","D-Moll","D Moll-Dreiklang"]},{chordId:"em",chordName:"Em",qualityId:"minor-triad",rootMidi:64,spelling:"sharp",scaleDegreeIn:[{keyName:"C-Dur",degree:"iii",role:"Mediante"},{keyName:"G-Dur",degree:"vi",role:"Tonika-Parallele"},{keyName:"D-Dur",degree:"ii",role:"Subdominanten-Parallele"},{keyName:"A-Moll",degree:"v",role:"Moll-Dominante"},{keyName:"E-Moll",degree:"i",role:"Tonika"}],aliases:["E minor","Em","E-Moll"]},{chordId:"f",chordName:"F",qualityId:"major-triad",rootMidi:65,spelling:"flat",scaleDegreeIn:[{keyName:"C-Dur",degree:"IV",role:"Subdominante"},{keyName:"F-Dur",degree:"I",role:"Tonika"},{keyName:"B♭-Dur",degree:"V",role:"Dominante"},{keyName:"A-Moll",degree:"♭VI",role:"Sexte (Pop-Loop-Trittstein)"}],aliases:["F major","F","F-Dur"]},{chordId:"g",chordName:"G",qualityId:"major-triad",rootMidi:67,spelling:"sharp",scaleDegreeIn:[{keyName:"C-Dur",degree:"V",role:"Dominante"},{keyName:"G-Dur",degree:"I",role:"Tonika"},{keyName:"D-Dur",degree:"IV",role:"Subdominante"},{keyName:"A-Moll",degree:"♭VII",role:"Subtonika (Pop-Loop-Schluss)"}],aliases:["G major","G","G-Dur"]},{chordId:"am",chordName:"Am",qualityId:"minor-triad",rootMidi:57,spelling:"sharp",scaleDegreeIn:[{keyName:"C-Dur",degree:"vi",role:"Tonika-Parallele (Pop-Loop-Anker)"},{keyName:"G-Dur",degree:"ii",role:"Subdominanten-Parallele"},{keyName:"F-Dur",degree:"iii",role:"Mediante"},{keyName:"A-Moll",degree:"i",role:"Tonika"},{keyName:"D-Moll",degree:"v",role:"Moll-Dominante"}],aliases:["A minor","Am","A-Moll","A Moll-Dreiklang"]},{chordId:"bm7b5",chordName:"Bm7♭5",qualityId:"half-diminished",rootMidi:59,spelling:"flat",scaleDegreeIn:[{keyName:"C-Dur",degree:"vii°",role:"Leitton-Akkord (halbvermindert)"},{keyName:"A-Moll",degree:"ii°",role:"Subdominanten-Parallele (halbvermindert)"}],aliases:["B minor 7 flat 5","Bm7b5","Bm7♭5","B half-diminished","Bø7","Hm7b5"]}].map(e=>[e.chordId,e])),{low:{enters:4,sub:!0},groove:{enters:0},riff:{enters:1,melodic:!0},atmo:{enters:2,air:!0},texture:{enters:3,melodic:!0}}),L=e=>"string"==typeof e.start?{[e.start]:1}:e.start,W=e=>e.roles??H,J=["intro","core","breakdown","drift","outro"];var U=(e,t,n)=>e.includes("*")||e.includes(t)||e.includes(n.fn);var Q={i:0,ii:2,iii:4,iv:5,v:7,vi:9,vii:11};function Z(e){const t=/^([b#♭♯]?)(vii|vi|v|iv|iii|ii|i)(.*)$/i.exec(e);if(!t)return null;const n="b"===t[1]||"♭"===t[1]?-1:t[1]?1:0;return q(0,((Q[t[2].toLowerCase()]+n)%12+12)%12)}var X=e=>e.split(/[\s–—-]+/).filter(Boolean);function Y(e){const t=z[e.trim()],n=X(t?t.degreePattern:e),s=n.map(Z);return n.length&&s.every(e=>null!==e)?s:null}function ee(e,t,n){const s=n(e);if(!s)return`${e} is not an instrument (no kind of the IDE plays it as one)`;const r=s(t);return"string"==typeof r?`${e} ${r}`:r}function te(e){return t=>{const n=t.toLowerCase();return e.find(e=>e.instrumentOf&&(e.fileExtensions??[]).some(e=>n.endsWith(e.startsWith(".")?e.toLowerCase():`.${e.toLowerCase()}`)))?.instrumentOf}}function ne(e){const t=Object.values(e.fills.kinds).flatMap(e=>e.instrument?[e.instrument]:[]);return[...new Set([...Object.values(e.parts).map(e=>e.instrument),...t])]}function se(e,t){const n=new Set(e.parts[t]?.ev.map(e=>e[1]));return 1===n.size?[...n][0]:void 0}function re(e,t){const n=[],s=new Map,r=e=>(s.has(e)||s.set(e,(e=>{const s=t[e];if(void 0===s)n.push(`no instrument "${e}" in the project`);else{if("string"!=typeof s)return s;n.push(s)}return null})(e)),s.get(e)),o={},i={};for(const[p,f]of Object.entries(e.parts)){const e=r(f.instrument);if(e&&(o[p]=e.channel,i[p]=null!==e.notes,e.notes))for(const t of new Set([...f.ev,...(f.lines?.ev??[]).flat()].map(e=>e[1])))e.notes.includes(t)||n.push(`part ${p} plays note ${t} — ${f.instrument} has no key for it (it has ${e.notes.join(", ")})`)}const a={},c=[];for(const[p,f]of Object.entries(e.fills.kinds)){if(!f.instrument||!f.notes)continue;const e=r(f.instrument);if(e&&(a[p]=e.channel,e.notes)){c.push(e.channel);for(const[,t]of f.notes)e.notes.includes(t)||n.push(`the fill ${p} plays note ${t} — ${f.instrument} has no key for it`)}}if(n.length)return{doc:null,problems:[...new Set(n)]};const l=[...new Set([...Object.keys(i).filter(e=>i[e]).map(e=>o[e]),...c])],d=e.harmony?"tonic"in e.harmony?function(e){const t=[],n=F.indexOf(e.tonic),s=void 0===e.written?n:F.indexOf(e.written);s<0&&t.push(`harmony.written: "${e.written}" is no tonic (${F.join(", ")})`),n<0&&t.push(`harmony.tonic: "${e.tonic}" is no tonic (${F.join(", ")})`);const r=G[e.scale];r||t.push(`harmony.scale: no scale "${e.scale}" (${Object.keys(G).join(", ")})`);const o=Y(e.original??"");o||t.push(`harmony.original: "${e.original}" is not a row of degrees like "i bVI bIII bVII"`);const i=(e.progressions??[]).map((e,n)=>{const s=Y(e);return s?o&&s.length!==o.length&&t.push(`harmony.progressions[${n}]: ${s.length} degrees — the original has ${o.length}, one per bar`):t.push(`harmony.progressions[${n}]: "${e}" is not a row of degrees`),s??[]});if(t.length||!r||!o)return{harmony:null,problems:t};const a=q(s,n);return{harmony:{scale:r.intervals.map(e=>(n+e)%12),original:o,progressions:i,offset:a},problems:t}}(e.harmony):{harmony:e.harmony,problems:[]}:null;if(d?.problems.length)return{doc:null,problems:d.problems};const h=d?.harmony?.offset??0,u=Object.fromEntries(Object.entries(e.parts).map(([e,t])=>{const n=i[e]?0:h+12*(t.octave??0),s=e=>e.map(([e,t,s,r])=>[e,t+n,s,r]),r=n?{...t,ev:s(t.ev),...t.lines?{lines:{...t.lines,ev:t.lines.ev.map(s)}}:{}}:t;if(!t.variants?.euclid?.length)return[e,r];const o=t.variants.euclid.map(([e,n,s])=>{const r=function(e,t,n=0){return Array.from({length:e},(s,r)=>(Math.floor(r*t/e)+n)%t).sort((e,t)=>e-t)}(e,n,s);return r.map((e,s)=>[e,Math.min(t.ev[s][3],((r[s+1]??r[0]+n)-e+n)%n||n)])});return[e,{...r,variants:{...t.variants,rhythms:[...t.variants.rhythms??[],...o]}}]})),m=e.harmony&&"tonic"in e.harmony?e.harmony:void 0;return{doc:{...e,parts:u,harmony:d?.harmony??void 0,...m?{harmonyNames:m}:{},channels:o,keyed:i,fillChannels:a,keyedChannels:l},problems:[]}}async function oe(e,t,n){const s={};for(const r of ne(e))try{s[r]=ee(r,await t(`asset:assets/${r}`),n)}catch{s[r]=`no instrument "${r}" in the project`}return s}function ie(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}function ae(e,t,n=0){let s=2166136261^e>>>0;for(const r of`${t}:${n}`)s^=r.charCodeAt(0),s=Math.imul(s,16777619);return ie(s)}function ce(e,t){const n=Object.entries(e);let s=t()*n.reduce((e,[,t])=>e+t,0);for(const[r,o]of n)if((s-=o)<0)return r;return n[n.length-1][0]}var le=["more","less","breathe","build"],de={more:"more pressure",less:"calmer",breathe:"a rest soon",build:"towards a peak"};function he(e){const t={};for(const n of e)"noted"===n.status&&(t[n.kind]=Math.min(1,(t[n.kind]??0)+n.weight));return t}function ue(e,t,n,s=$.wishes){switch(e){case"more":return n>t;case"less":return n<t;case"breathe":return n<=s.rest;case"build":return n>=s.high}}var me={energy:0,hold:!1},pe=class e{doc;shape;#e;#t=-1;#n=0;#s=0;#r;#o;#i;#a="";#c=-1;#l=0;#d=0;#h=0;#u=null;#m=null;#p=null;#f=[];#g=new Map;#b=0;#k=0;#v;#y={};#w=null;#M;constructor(e,t,n=j){this.doc=e,this.#M=I(e),this.shape=n,this.#e=t,this.#r=e.bpm,this.#o=e.bpm,this.#v=e.harmony?.original;for(const s of Object.keys(e.parts))this.#y[s]=-1}clone(){const t=new e(this.doc,this.#e,this.shape);return t.#t=this.#t,t.#n=this.#n,t.#s=this.#s,t.#r=this.#r,t.#o=this.#o,t.#i=this.#i,t.#a=this.#a,t.#c=this.#c,t.#l=this.#l,t.#d=this.#d,t.#h=this.#h,t.#u=this.#u,t.#m=this.#m,t.#p=this.#p,t.#f=[...this.#f],t.#g=new Map(this.#g),t.#b=this.#b,t.#k=this.#k,t.#v=this.#v,t.#y={...this.#y},t.#w=this.#w?{...this.#w}:null,t}next(e=me){const t=this.doc,n=t.phraseBars;this.#t>=0&&this.#$(n),this.#t++;let s=null;this.#i=void 0,0===this.#t?s=this.#I(ce(L(t),ae(this.#e,"start",0)),null,e):(this.#n+=n,this.#d++,e.hold&&this.#m&&this.#m.startBar>=this.#n&&(this.#u=null,this.#m=null),this.#d>=this.#h&&(e.hold&&!this.#u?this.#h++:s=this.#I(this.#u??this.#S(e),this.#m,e)));const r=t.sections[this.#a],o=this.#h-this.#d;!this.#u&&!e.hold&&o<=this.#M.structure.chooseAhead&&this.#x(e,o*n);const i=ae(this.#e,"guests",this.#t),a=Object.entries(r.guests??{}).filter(([,e])=>i()<e).map(([e])=>e),c=e=>{const t=new Set([...r.layers,...e]);for(const s of r.grow??[])if(!(this.#d<s.phrase)){for(const e of s.add??[])t.add(e);for(const e of s.remove??[])t.delete(e)}const n=this.#p?.def.arrival;if(n?.add){const e=n.from??0;if(this.#d>=e&&this.#d<e+(n.phrases??1))for(const s of n.add)t.add(s)}return t},l=this.#M.checks.density[r.fn]?.[1]??1/0,d=e=>new Set([...e].map(e=>t.parts[e].instrument)).size,h=[];for(const g of a){const e=d(c([...h,g]));(e<=l||e===d(c(h)))&&h.push(g)}let u=[...c(h)];const m=0===this.#d&&!!this.#p?.drop;if(!m){const e=u.filter(e=>this.#f.includes(e)),n=W(t),s=e=>!!n[t.parts[e].role]?.air,r=!e.some(s),o=this.#M.structure.entries,i=ae(this.#e,"entries",this.#t),a=new Map(u.map(e=>[e,o.seeded?i():0])),c=e=>o.airFirst&&r&&s(e)?-1:o.seeded?a.get(e):n[t.parts[e].role].enters,l=u.filter(e=>!this.#f.includes(e)).sort((e,t)=>c(e)-c(t)),d=new Set(l.slice(o.max));u=u.filter(e=>!d.has(e))}this.#f=u;const p=Math.max(0,Math.min(1,r.energy+e.energy)),f={index:this.#t,bar:this.#n,ms:this.#s,section:this.#a,fn:r.fn,sectionIndex:this.#c,sectionStartBar:this.#l,phraseInSection:this.#d,sectionPhrases:this.#h,energy:p,target:B(this.shape,this.#s,this.#M.arc),playing:u,upcoming:this.#u,transition:this.#m,entered:this.#p,ornament:this.#j(m),fill:this.#B(p,m),chapter:s,...void 0!==this.#i?{tempo:this.#i}:{},variants:{...this.#y}};return this.#w=f,f}endWithPhrase(e,t){const n=this.doc.phraseBars;this.#h=this.#d+1;const s=this.#l+this.#h*n;this.#m&&this.#m.startBar<=e&&this.#m.changeBar===s||(this.#u=this.#u??this.#S(t),this.#x(t,Math.max(0,s-e-1),this.#u),this.#w&&(this.#w.sectionPhrases=this.#h,this.#w.upcoming=this.#u,this.#w.transition=this.#m))}#$(e){for(let t=0;t<e;t++){const e=this.#M.tempo;(this.#n+t)%e.everyBars===0&&this.#r!==this.#o&&(this.#r=this.#r<this.#o?Math.min(this.#o,this.#r+e.bpm):Math.max(this.#o,this.#r-e.bpm)),this.#s+=24e4/this.#r}}#I(e,t,n){const s=this.doc,r=s.sections[e];t&&this.#g.set(t.to,t.name),this.#c++,this.#a=e,this.#l=this.#n,this.#d=0,this.#h=r.phrases[Math.floor(ae(this.#e,"length",this.#c)()*r.phrases.length)],this.#p=t,this.#u=null,this.#m=null;const o=ae(this.#e,"variant",this.#c);for(const[l,d]of Object.entries(s.parts)){const t=d.variants;if(!t)continue;const n=this.#y[l];this.#y[l]=n<0&&t.sections.includes(e)&&o()<t.chance?Math.floor(o()*(t.rhythms?.length??0)):-1}const i=s.chapters,a="energy"===this.#M.tempo.follow&&!!i;if(a){const e=Math.max(0,Math.min(1,r.energy+n.energy));this.#o=Math.round(1e4*(i.bpm[0]+e*(i.bpm[1]-i.bpm[0])))/1e4,this.#i=this.#o}if(!i||this.#b>0&&this.#s<this.#k)return null;const c=ae(this.#e,"chapter",this.#c);if(this.#b++,this.#k=this.#s+6e4*(i.minutes[0]+c()*(i.minutes[1]-i.minutes[0])),s.harmony&&this.#b>1&&(this.#v=s.harmony.progressions[Math.floor(c()*s.harmony.progressions.length)]),this.#b>1){const e=Math.round(1e4*(i.bpm[0]+c()*(i.bpm[1]-i.bpm[0])))/1e4;a||(this.#o=e)}return{index:this.#b,progression:this.#v,bpm:this.#o}}#S(e){const t=this.doc,n=t.sections[this.#a],s=ae(this.#e,"next",this.#c),r=4*t.phraseBars*6e4/this.#r,o=this.#s+(this.#h-this.#d)*r,i=e.wishes??{},a=e=>t.sections[e]?.energy??.5,c=this.#M.arc,l=Math.max(0,Math.min(1,B(this.shape,o,c)+c.conductor*e.energy+function(e,t=$.wishes){return t.shift.more*((e.more??0)-(e.less??0))+t.shift.build*((e.build??0)-(e.breathe??0))}(i,this.#M.wishes)));return ce(function(e,t,n,s=$.wishes){const r={};for(const[o,i]of Object.entries(e)){const e=t(o);r[o]=i*(e<=s.rest?1+s.tilt*(n.breathe??0):1)*(e>=s.high?1+s.tilt*(n.build??0):1)}return r}(function(e,t,n,s=$.arc.pull){const r={};for(const[o,i]of Object.entries(e)){const e=t(o)-n;r[o]=i*Math.exp(-e*e/(2*s*s))}return Object.values(r).some(e=>e>1e-6)?r:e}(n.next,a,l,c.pull),a,i,this.#M.wishes),s)}#x(e,t,n=this.#S(e)){const s=this.doc,r=s.sections[this.#a],o=s.sections[n];this.#u=n;const i=Object.entries(s.transitions).filter(([,e])=>U(e.from,this.#a,r)&&U(e.to,n,o)&&e.lead<=t),a=this.#M.transitions,c=i.filter(([,e])=>!e.from.includes("*")||!e.to.includes("*"));let l=a.namedFirst&&c.length?c:i;const d=this.#g.get(n);a.noRepeat&&l.length>1&&(l=l.filter(([e])=>e!==d));const h=this.#l+this.#h*s.phraseBars;if(!l.length)return void(this.#m={name:"cut",from:this.#a,to:n,startBar:h,changeBar:h,drop:!1,def:{from:["*"],to:["*"],lead:0}});const u=ce(Object.fromEntries(l.map(([e,t])=>[e,t.weight??1])),ae(this.#e,"way",this.#c)),m=s.transitions[u];this.#m={name:u,from:this.#a,to:n,startBar:h-m.lead,changeBar:h,drop:!!m.drop,def:m}}#P(e,t){const n=this.doc.phraseBars;if(this.#m&&this.#m.startBar<t)return!0;const s=this.#p;if(!s)return!1;const r=s.def.arrival?.gesture?.beats??0,o=s.def.gesture?s.def.gesture.beats-4*s.def.lead:0,i=s.changeBar+Math.ceil(Math.max(r,o)/4),a=s.drop||s.def.gesture||s.def.arrival?.gesture?s.changeBar+n*this.#M.ornaments.calmPhrases:s.changeBar;return e<Math.max(i,a)}#j(e){const t=this.doc,n=t.phraseBars;if(e||!t.ornaments)return null;const s=t.sections[this.#a],r=ae(this.#e,"ornament",this.#t),o=Object.entries(t.ornaments).filter(([,e])=>{const t=r();return U(e.in,this.#a,s)&&t<e.chance});if(!o.length)return null;const[i,a]=o[Math.floor(r()*o.length)];if(!a.end&&0===this.#d&&!this.#M.ornaments.onSectionStart)return null;const c=a.end?this.#n+n-Math.ceil(a.beats/4):this.#n,l=c+Math.ceil(a.beats/4),d=this.#l+(this.#h-this.#M.structure.chooseAhead)*n;return this.#P(c,l)||!this.#m&&l>d?null:{name:i,bar:c}}#B(e,t){const n=this.doc.fills,s=this.#n+this.doc.phraseBars-1,r=ae(this.#e,"fill",this.#t);return r()>=n.chance||t||e<n.minEnergy||this.#P(s,s+1)?null:{kind:ce(Object.fromEntries(Object.entries(n.kinds).map(([e,t])=>[e,t.weight])),r),bar:s}}};function fe(e,t){switch(e){case"intro":return"exposition";case"breakdown":return"turn";case"drift":return"release";case"outro":return"resolution";default:return t>=.75?"climax":"rise"}}var ge=(e,[t,n])=>Math.max(t,Math.min(n,e)),be=24,ke=96,ve=class{doc;#e;#N;#A;#T;#D=()=>0;#O={};#R=[];#E=[];#C=[];#z=1/0;#F=0;#q=[];#V=[];#_=[];#K=0;#G=0;#r;#o;#H;#a;#L=null;#W=!1;#J=!1;#U=[];#Q={};#Z=null;#X=null;#Y=0;#ee=null;#te=!1;#ne=[];#se=null;#re=!1;#oe=null;#ie=new Set;#ae=new Set;#ce=[];#le=0;#de=-1;#he={};#ue={};#me;#pe;#fe={};#ge={};#be={};#ke={};#ve=new Set;#ye=[];#v;#b=0;#M;constructor(e,t,n,s){this.doc=e,this.#M=I(e);const r=W(e);this.#me=new Set(Object.keys(e.parts).filter(t=>r[e.parts[t].role]?.melodic&&!e.parts[t].keep&&!e.keyed[t])),this.#pe=new Set(Object.values(e.parts).map(e=>e.instrument)),this.#e=t,this.#N=n,this.#A=new pe(e,t,s),this.#T=[ie(2654435769^t)],this.#r=e.bpm,this.#o=e.bpm;for(const[o,i]of Object.entries(e.knobs)){this.#O[o]={...i,value:i.home};for(const e of i.swing??[])this.#Q[e]=o}for(const[o,i]of Object.entries(e.parts))this.#he[o]=i.ev.map(e=>[...e]),this.#ge[o]=-1,this.#ke[o]=-1;this.#v=e.harmony?.original}get bpm(){return this.#r}get elapsedMs(){return this.#G}get tickCount(){return this.#K}playAhead(e,t=1/0){if(!(e<=0)){for(this.#J=!0;this.#K<e*ke&&this.#G<t;)this.tick();this.#J=!1,this.#q=[],this.#V=[],this.#U=[this.#K,this.#K+ke],this.#we(`>>> from bar ${e} (${(this.#G/6e4).toFixed(1)} min in), ${this.#H.section}`)}}tick(){for(;this.#H&&this.#F<=this.#G;)this.#Me(this.#F),this.#F+=this.#M.hand.everyMs;this.#$e()}conduct(e){switch(e.kind){case"energy":this.#ee=Math.max(-1,Math.min(1,e.value)),this.#Ie();break;case"hold":this.#te=e.on,this.#Ie(),e.on&&(this.#re=!1);break;case"next":this.#re=!0,this.#te=!1,this.#Ie(),this.#H&&this.#A.endWithPhrase(this.#Se(this.#K),this.#xe());break;case"moment":this.doc.ornaments?.[e.name]&&(this.#oe=e.name);break;case"part":if(!(e.part in this.doc.parts))break;void 0!==e.muted&&(e.muted?this.#ie.add(e.part):this.#ie.delete(e.part)),void 0!==e.soloed&&(e.soloed?this.#ae.add(e.part):this.#ae.delete(e.part));break;case"wish":{if(!le.includes(e.wish))break;this.#Ie();const t=Math.max(0,Math.min(1,e.weight??1)),n=this.#ce.find(t=>t.kind===e.wish&&"noted"===t.status);n?n.weight=Math.min(1,n.weight+t):this.#ce=[...this.#ce,{id:++this.#le,kind:e.wish,weight:t,status:"noted",outcome:null}].slice(-8);break}}}finish(){for(const e of this.#q.splice(0))this.#je(e.bytes,e.late,e.to);this.#Be(),this.#Pe();for(const e of new Set(Object.values(this.doc.channels)))this.#je([176|e-1,123,0])}snapshot(){const e=this.#H,t=e?this.#f():[],n=new Set(this.#a?.layers??[]);return{elapsedMs:this.#G,bar:this.#Se(this.#K),bpm:this.#r,chapter:this.#b,section:e?.section??"",energy:this.#Ne(),sectionBar:e?this.#Se(this.#K)-e.sectionStartBar:0,sectionBars:e?e.sectionPhrases*this.doc.phraseBars:0,upcoming:e?.upcoming??null,role:fe(this.#a?.fn,this.#Ne()),upcomingRole:e?.upcoming&&this.doc.sections[e.upcoming]?fe(this.doc.sections[e.upcoming].fn,this.doc.sections[e.upcoming].energy):null,parts:t.filter(e=>n.has(e)),guests:t.filter(e=>!n.has(e)),moments:this.#_.map(e=>e.name),momentProgress:Object.fromEntries(this.#_.map(e=>[e.name,Math.min(1,(this.#K-e.startTick)/(e.def.beats*be))])),knobs:Object.entries(this.#O).map(([e,t])=>({name:e,value:t.value,range:this.#Ae(e)})),turning:this.#C.flatMap(e=>e?[e.name]:[]),sweeping:this.#E.map(e=>e.name),arrival:this.#_.find(e=>"transition"===e.kind||"arrival"===e.kind)?.name??null,conducting:{energy:this.#ee??this.#Y,hold:this.#te,next:this.#re,moment:this.#oe,muted:[...this.#ie],soloed:[...this.#ae]},wishes:this.#ce.map(e=>({...e}))}}#je(e,t=0,n){this.#J||this.#N.midi(e,t,n)}#Te(e,t){this.#J||this.#N.control?.(e,t)}#we(e){this.#J||this.#N.log?.(e)}#De(e){this.#J||this.#N.event?.(e)}#Se(e){return Math.floor(e/ke)}#Oe(){return`${(this.#G/6e4).toFixed(1).padStart(5)}min bar ${String(this.#Se(this.#K)).padStart(4)}`}#Ie(){this.#se??=this.#Se(this.#K)}get conductedFrom(){return this.#se}get phraseIndex(){return this.#H?.index??-1}projection(e){const t=[...this.#ne],n=this.#A.clone(),s=this.#ee??this.#Y,r=this.#ce.map(e=>({...e})),o=this.#M.wishes;let i=this.#de;const a=this.#H;for(let c=1;;c++){const l=this.#te&&!!a&&a.phraseInSection+c<=a.sectionPhrases;for(const e of r)"noted"===e.status&&(e.weight*=o.fade,e.weight<o.goneBelow&&(e.status="faded"));const d=n.next({energy:s,hold:l,wishes:he(r)});if(d.ms>=e)break;if(d.transition&&d.transition.changeBar!==i){i=d.transition.changeBar;for(const e of r)"noted"===e.status&&(e.status="honoured")}t.push(d)}return t}#xe(){return{energy:this.#Y,hold:this.#te,wishes:he(this.#ce)}}#Re(){for(const e of this.#ce)"noted"===e.status&&(e.weight*=this.#M.wishes.fade,e.weight<this.#M.wishes.goneBelow&&(e.status="faded",e.outcome="faded before the next change was chosen"))}#Ee(e){const t=e.transition;if(!t||t.changeBar===this.#de)return;this.#de=t.changeBar;const n=this.doc.sections[t.from].energy,s=this.doc.sections[t.to].energy;for(const r of this.#ce){if("noted"!==r.status)continue;const e=ue(r.kind,n,s,this.#M.wishes);r.status=e?"honoured":"outweighed",r.outcome=e?`${t.from} → ${t.to} at bar ${t.changeBar}`:`the arc and the document chose ${t.from} → ${t.to} at bar ${t.changeBar}`,this.#we(`${this.#Oe()} ~ wish ${de[r.kind]}: ${r.status} (${r.outcome})`)}}#Ce(e,t){const n=this.#O[e];(t=Math.round(ge(t,[0,127])))!==n.value&&(n.value=t,this.#Te(e,t))}#ze(e,t){if(!this.#ie.size&&!this.#ae.size)return!1;const n=Object.entries(this.doc.parts).filter(([n,s])=>this.doc.channels[n]===e&&s.ev.some(e=>e[1]===t));return!!n.some(([e])=>this.#ie.has(e))||this.#ae.size>0&&!n.some(([e])=>this.#ae.has(e))}#Ne(){return Math.max(0,Math.min(1,(this.#a?.energy??0)+this.#Y))}#Ae(e){const t=this.#a?.ranges?.[e];if(t)return t;const[n,s]=this.#O[e].range;if(!this.doc.hand?.widen||!this.#a)return[n,s];const[r,o]=this.#O[e].wide??[n,s],i=this.#Ne();return[Math.round(n+(r-n)*i),Math.round(s+(o-s)*i)]}#Fe(){this.#R=[];const e=this.#qe();for(const t of Object.keys(this.#O))e.has(t)||this.#E.some(e=>e.name===t)||this.#Ve(t)}#Ve(e){const[t,n]=this.#Ae(e),s=this.#O[e].value;if(s>=t&&s<=n)return;const{glideInset:r,glideBars:o}=this.#M.hand,i=s<t?t+Math.round((n-t)*r):n-Math.round((n-t)*r);this.#R=[...this.#R.filter(t=>t.name!==e),{name:e,from:s,to:i,startTick:this.#K,ticks:o*ke}]}#Pe(){for(const e of Object.keys(this.#O)){this.#O[e].value=-1;const t=this.#E.find(t=>t.name===e);this.#Ce(e,t?this.#_e(t):this.#O[e].home)}}#_e(e){return e.from+(e.to-e.from)*Math.min(1,(this.#K-e.startTick)/e.ticks)}#Be(){this.#V=[];for(const e of Object.keys(this.doc.buttons))this.#Te(e,0)}#Ke(){const e={},t=this.doc.hand?.others??0,n=this.#Ge();for(const s of Object.keys(this.#O))t&&!1!==this.#O[s].hand&&n(s)&&(e[s]=t);for(const s of this.#a.hands??[])!1!==this.#O[s].hand&&n(s)&&(e[s]=this.doc.hand?.focus??1);return e}#Ge(){const e=new Set(this.#f().map(e=>this.doc.parts[e].instrument));return t=>{const n=this.#O[t];return!n.instrument||!this.#pe.has(n.instrument)||e.has(n.instrument)}}#He(e){const t=this.#O[e];return t.master?"MASTER":t.swing?"SWING":t.instrument??e}#Me(e){if(e<this.#z)return;const t=this.#Ke(),n=this.#a.handCount??this.#M.hand.count;this.#C.length=Math.min(this.#C.length,n);for(let s=0;s<n;s++)this.#Le(s,e,t)}#Le(e,t,n){const s=this.#T[e]??=ae(this.#e,"hand",e);if(this.#C[e]&&!(this.#C[e].name in n)&&(this.#C[e]=null),null!=this.#a.handSpeed&&s()>this.#a.handSpeed)return;if(!Object.keys(n).length)return;let r=this.#C[e]??null;if(!r||t>r.until){const o=this.#M.hand;if(s()<o.pause)return void(this.#C[e]=null);const i=this.#C.filter((t,n)=>t&&n!==e);let a=n;if(i.length){const t=new Set(i.map(e=>e.name)),s=new Set(i.map(e=>this.#He(e.name))),r=Object.entries(n).filter(([e])=>!t.has(e)),o=r.filter(([e])=>!s.has(this.#He(e)));if(!r.length)return void(this.#C[e]=null);a=Object.fromEntries(o.length?o:r)}const c=ce(a,s);r=this.#C[e]={name:c,dir:s()<.5?-1:1,until:t+o.turnMs[0]+s()*(o.turnMs[1]-o.turnMs[0])}}const{name:o}=r;if(this.#R.some(e=>e.name===o)||this.#E.some(e=>e.name===o)||this.#qe().has(o))return;const[i,a]=this.#Ae(o),[c,l]=this.#M.hand.step,d=this.#O[o].value+r.dir*(c+Math.floor(s()*(l-c+1)));(d<=i||d>=a)&&(r.dir=-r.dir),this.#Ce(o,ge(d,[i,a]))}#We(e,t,n,s,r=0,o,i){const a=e-1,c=ge(Math.round(t),[0,127]),l=this.doc.keyedChannels.includes(e);if(l&&this.#q.some(e=>e.to===i&&e.bytes[0]===(128|a)&&e.bytes[1]===c))return;const d=l?Math.max(1,Math.round(s)-1):Math.max(1,Math.round(s));let h=Math.min(r,(d-.5)/6);for(let u=this.#q.length-1;u>=0;u--){const e=this.#q[u];e.to===i&&e.bytes[0]===(128|a)&&e.bytes[1]===c&&(this.#je(e.bytes,e.late,e.to),h=Math.max(h,e.late),this.#q.splice(u,1))}o&&this.#je(o,h,i),this.#je([144|a,c,ge(Math.round(n),[1,127])],h,i),this.#q.push({at:this.#K+d,bytes:[128|a,c,0],late:h,to:i})}#Je(e){const t=this.#Q[e];if(!t)return 0;const{min:n,max:s}=this.doc.knobs[t];return a(o(this.#O[t].value,n,s),Math.floor(this.#K/6))}#Ue(e,t){this.#Te(e,127),this.#V=[...this.#V.filter(t=>t.name!==e),{at:this.#K+t,name:e}]}#Qe(e,t,n){const s=e.startTick+(t.at??0)*be;return n>=s&&n<s+(t.len??1)*be}#Ze(e,t,n){const s="transition"===t||"arrival"===t?this.#_.filter(e=>"ornament"===e.kind||"conducted"===e.kind):[];this.#_=this.#_.filter(e=>!s.includes(e)),this.#_.push({name:e,kind:t,def:n,startTick:this.#K}),this.#we(`${this.#Oe()} * ${e}`),this.#De({kind:"gesture",tick:this.#K,ms:this.#G,bar:this.#Se(this.#K),name:e,gesture:t,cuts:s.map(e=>e.name)})}#qe(){return new Set(this.#_.flatMap(e=>e.def.do.filter(e=>e.knob).map(e=>e.knob)))}#Xe(){return this.#_.some(e=>e.def.do.some(t=>t.gap&&this.#Qe(e,t,this.#K)))}#Ye(){for(const n of this.#_){const e=new Map;n.def.do.forEach((t,s)=>{if(!t.knob||this.#K<n.startTick+(t.at??0)*be)return;const r=e.get(t.knob);(void 0===r||(n.def.do[r].at??0)<=(t.at??0))&&e.set(t.knob,s)}),n.def.do.forEach((t,s)=>{if(!t.knob||e.get(t.knob)!==s)return;const r=n.startTick+(t.at??0)*be,o=(t.len??1)*be;n.start??={},n.start[s]??=this.#O[t.knob].value;const i=this.#O[t.knob].wide??[0,127];if(null!=t.spike)return void this.#Ce(t.knob,ge(this.#K<r+o?t.spike:n.start[s],i));const a=Math.min(1,(this.#K-r)/o);this.#Ce(t.knob,ge(n.start[s]+((t.to??n.start[s])-n.start[s])*a,i))})}const e=this.#_.filter(e=>this.#K>=e.startTick+e.def.beats*be);if(!e.length)return;if(this.#_=this.#_.filter(t=>!e.includes(t)),!this.#W)return;const t=this.#qe();for(const n of new Set(e.flatMap(e=>e.def.do.filter(e=>e.knob).map(e=>e.knob))))t.has(n)||this.#E.some(e=>e.name===n)||this.#Ve(n)}#et(e){for(const t of this.#_)for(const n of t.def.do)if(this.#Qe(t,n,this.#K)){if(n.gap)return!1;if(n.mute?.includes(e))return!1;if(n.solo&&!n.solo.includes(e))return!1}return!0}#tt(){const e=this.#Xe();for(const t of this.#_)for(const n of t.def.do){if(!n.roll||e||!this.#Qe(t,n,this.#K))continue;const s=(this.#K-t.startTick-(n.at??0)*be)/((n.len??1)*be),r=(s<.25?24:s<.5?12:6)/(n.fast?2:1),o=this.doc.channels[n.roll],i=se(this.doc,n.roll);(this.#K-t.startTick)%r!==0||this.#ze(o,i)||this.#We(o,i,60+60*s,2,0,void 0,this.doc.parts[n.roll]?.instrument)}for(const t of this.#_)for(const e of t.def.do){const n=this.#K===t.startTick+(e.at??0)*be;if(e.hold&&n&&this.#Ue(e.hold,(e.len??1)*be),e.cut&&n)for(let e=this.#q.length-1;e>=0;e--)128==(240&this.#q[e].bytes[0])&&(this.#je(this.#q[e].bytes,this.#q[e].late,this.#q[e].to),this.#q.splice(e,1))}}#nt(e,t){const n=this.doc.mutation,s=this.doc.parts[e],r=this.#he[e],o=s.cycle??this.doc.loopSteps,i=t();if(n.resetChance&&(this.#ue[e]??0)>=n.maxChanges)return this.#he[e]=this.#st(e).map(e=>[...e]),(this.#ge[e]??-1)>=0&&this.#rt(e),this.#ue[e]=0,void this.#ye.push(e+" reset");const a=this.#M.mutation;if(this.doc.keyed[e]){const n={...a.kit,...s.mutate},c=r[0]?.[1]??40,l=i*(n.add+n.remove+n.shift);if(l<n.add){const s=Math.floor(t()*o);r.some(e=>e[0]===s)||(r.push([s,c,n.addVelocity[0]+Math.floor(t()*(n.addVelocity[1]-n.addVelocity[0])),1]),this.#ue[e]=(this.#ue[e]??0)+1,this.#ye.push(e+" +hit"))}else if(l<n.add+n.remove&&r.length>n.keepHits&&!s.keep&&!s.variants)r.splice(Math.floor(t()*r.length),1),this.#ue[e]=(this.#ue[e]??0)+1,this.#ye.push(e+" -hit");else if(!s.keep){const n=r[Math.floor(t()*r.length)];n[0]=(n[0]+(t()<.5?-1:1)+o)%o,this.#ue[e]=(this.#ue[e]??0)+1,this.#ye.push(e+" shift")}return}if(s.keep||!r.length)return;this.#ue[e]=(this.#ue[e]??0)+1;const c=r[Math.floor(t()*r.length)],l={...a.melodic,...s.mutate},d=i*(l.step+l.octave+l.gate+l.copy);if(d<l.step){const n=t()<.5?-l.stepSemis:l.stepSemis;if("chord"===s.tones){const e=e=>this.#ot(e+this.#it(c[0]),c[0]),t=e(c[1]);let s,r=c[1];do{s=this.#at(r+=n)}while(e(s)===t&&Math.abs(r-c[1])<12);c[1]=s}else c[1]=this.#at(c[1]+n);this.#ye.push(e+" step")}else if(d<l.step+l.octave)c[1]+=t()<.5?-12:12,c[1]=Math.max(s.low??0,Math.min(s.high??127,c[1])),this.#ye.push(e+" oct");else if(d<l.step+l.octave+l.gate)c[3]=Math.max(l.gateRange[0],Math.min(l.gateRange[1],c[3]*(t()<.5?.5:2))),this.#ye.push(e+" gate");else{const n=Math.floor(t()*o);r.some(e=>e[0]===n)||(r.push([n,c[1],c[2]+l.copyVelocity,c[3]]),this.#ye.push(e+" +note"))}}#st(e){const t=this.doc.parts[e],n=this.#ke[e]??-1;return n>=0?t.lines.ev[n]:t.ev}#rt(e){const t=this.doc.parts[e],n=this.#ge[e];(n>=0?t.variants.rhythms[n]:t.ev.map(e=>[e[0],e[3]])).forEach(([t,n],s)=>{this.#he[e][s][0]=t,this.#he[e][s][3]=n})}#at(e){const t=this.doc.harmony;if(!t)return e;for(let n=0;n<12;n++)if(t.scale.includes(((e-n)%12+12)%12))return e-n;return e}#ot(e,t){const n=this.doc.harmony;if(!n)return e;const s=Math.floor(t/16)%n.original.length,r=((n.scale[0]+(this.#v??n.original)[s])%12+12)%12,o=n.scale.indexOf(r);if(o<0)return this.#at(e);const i=[0,2,4].map(e=>n.scale[(o+e)%n.scale.length]);for(let a=0;a<12;a++)if(i.includes(((e-a)%12+12)%12))return e-a;return e}#it(e){const t=this.doc.harmony;if(!t||!this.#v)return 0;const n=Math.floor(e/16)%t.original.length;return this.#v[n]-t.original[n]}#ct(){this.#Re();const e=this.#A.next(this.#xe());this.#ne.push(e),this.#Ee(e);const t=!this.#H||e.sectionIndex!==this.#H.sectionIndex;this.#H=e,this.#D=ae(this.#e,"notes",e.index);for(const[n,s]of Object.entries(this.doc.parts)){const t=s.each?.sets?.length??0;if(t<2)continue;const r=ae(this.#e,`each:${n}`,e.index),o=this.#be[n];let i=Math.floor(r()*t);i===o&&(i=(i+1+Math.floor(r()*(t-1)))%t),this.#be[n]=i}if(e.chapter&&(this.#b=e.chapter.index,this.#v=e.chapter.progression,this.#o=e.chapter.bpm,this.#we(`--- chapter ${e.chapter.index}: progression [${e.chapter.progression?.join(" ")}] tempo -> ${e.chapter.bpm}`)),void 0!==e.tempo&&(this.#o=e.tempo,this.#we(`--- ${e.section}: tempo -> ${e.tempo}`)),t){this.#a=this.doc.sections[e.section],this.#re=!1;for(const r of Object.keys(this.doc.parts)){const t=e.variants[r]??-1;t!==this.#ge[r]&&(this.#ge[r]=t,this.#rt(r))}this.#C=[];const t=e.sectionPhrases*this.doc.phraseBars*ke;this.#E=Object.entries(this.#a.sweep??{}).map(([e,[n,s]])=>({name:e,from:n,to:s,startTick:this.#K,ticks:t})),this.#W&&this.#Fe();const n=e.entered;this.#we(`${this.#Oe()} > ${e.section}${n?` (via ${n.name})`:""}`),this.#De({kind:"section",tick:this.#K,ms:this.#G,bar:e.bar,name:e.section,phrases:e.sectionPhrases,via:n?.name??null,drop:!!n?.drop});const s=n?.def.arrival?.gesture;n&&s&&this.#X!==`${n.name}@${n.changeBar}`&&(this.#X=`${n.name}@${n.changeBar}`,this.#Ze(n.name,"arrival",s))}this.#ye.length=0;for(const[n,s]of Object.entries(this.doc.parts)){const t=s.lines;if(!t)continue;const r=ae(this.#e,`line:${n}`,e.index),o=this.#ke[n];let i=-1;if(this.#ve.has(n)&&r()<t.chance){const e=t.ev.map((e,t)=>t).filter(e=>e!==o);e.length&&(i=e[Math.floor(r()*e.length)])}i!==o&&(this.#ke[n]=i,this.#he[n]=this.#st(n).map(e=>[...e]),this.#ue[n]=0,this.#ye.push(`${n} line ${i<0?"ev":i+1}`))}if(this.#ve=new Set(e.playing),this.doc.mutation){const t=ae(this.#e,"mutate",e.index),n=Math.floor(t()*(this.doc.mutation.perPhrase+1)),s=new Set;for(let o=0;o<n&&e.playing.length;o++){const n=e.playing[Math.floor(t()*e.playing.length)];this.#nt(n,t),s.add(n)}const r=ae(this.#e,"move",e.index);for(const o of e.playing)this.#me.has(o)&&(this.#fe[o]=s.has(o)?0:(this.#fe[o]??0)+1,this.#fe[o]<this.#M.mutation.melodicEvery||(this.#nt(o,r),this.#fe[o]=0))}this.#lt(),this.#De({kind:"phrase",tick:this.#K,ms:this.#G,bar:e.bar,section:e.section,playing:[...e.playing]})}#f(){const e=this.#H.transition,t=this.#Se(this.#K);return!e?.def.with||t<e.startBar||t>=e.changeBar?this.#H.playing:[...new Set([...this.#H.playing,...e.def.with])]}#dt(e){if(null!==this.#ee){const e=this.#ee!==this.#Y;this.#Y=this.#ee,this.#ee=null,e&&this.#W&&this.#a&&this.#Fe()}e%this.doc.phraseBars===0&&this.#ct();const t=this.#H,n=this.#M.tempo;e%n.everyBars===0&&this.#r!==this.#o&&(this.#r=this.#r<this.#o?Math.min(this.#o,this.#r+n.bpm):Math.max(this.#o,this.#r-n.bpm));const s=t.transition;s&&e===s.startBar&&s.def.gesture&&this.#Z!==`${s.name}@${s.changeBar}`&&(this.#Z=`${s.name}@${s.changeBar}`,this.#Ze(s.name,"transition",s.def.gesture));const r=this.#_.some(e=>"transition"===e.kind||"arrival"===e.kind);t.ornament&&e===t.ornament.bar&&!r&&this.#Ze(t.ornament.name,"ornament",this.doc.ornaments[t.ornament.name]),this.#oe&&!r&&(this.#Ze(this.#oe,"conducted",this.doc.ornaments[this.#oe]),this.#oe=null),this.#L=t.fill&&e===t.fill.bar?t.fill.kind:null}#ht(e){const t=this.doc,n=e%16,s=this.#H,r=(e-16*s.sectionStartBar)%t.loopSteps,o=this.#M.density.thin*(1-this.#Ne()),i=this.#Xe(),a=this.#L?t.fills.kinds[this.#L]:void 0,c=a?.at??0;for(const l of this.#f()){const i=t.parts[l];if(a?.mute?.includes(l)&&n>=c)continue;if(!this.#et(l))continue;const d=i.cycle?(e-16*s.sectionStartBar)%i.cycle:r,h=this.doc.keyed[l]?0:this.#it(r),u=this.#ie.has(l)||this.#ae.size>0&&!this.#ae.has(l),m=this.#he[l],p=i.unfold?Math.ceil(m.length*Math.min(1,(s.phraseInSection+1)/i.unfold.phrases)):m.length;for(let e=0;e<p;e++){const[t,n,s,a]=m[e];if(t!==d)continue;if(!i.keep&&!1!==i.thin&&this.#D()<o)continue;const c=s+(this.#D()-.5)*(i.jitter??12);if(u)continue;const p="chord"===i.tones?this.#ot(n+h,r):h?this.#at(n+h):n,f=i.each?i.each.sets?i.each.sets[this.#be[l]??0]:i.each.values:void 0,g=f?f[e%f.length]:void 0,b=this.doc.channels[l],k="number"==typeof g?[176|b-1,i.each.cc,g]:void 0;this.#We(b,p,c,6*a,this.#Je(l),k,i.instrument)}}if(!i){if(a?.notes){const e=this.doc.fillChannels[this.#L];for(const[t,s,r]of a.notes)t!==n||this.#ze(e,s)||this.#We(e,s,r,6,0,void 0,a.instrument)}a?.hold&&n===c&&this.#Ue(a.hold,(a.len??1)*be)}}#$e(){if(this.#U.includes(this.#K)){this.#Be();for(const[e,t]of Object.entries(this.#O))this.#Te(e,t.value)}this.#K%ke===0&&this.#dt(this.#Se(this.#K)),96===this.#K&&(this.#Be(),this.#Pe(),this.#W=!0,this.#z=-1/0,this.#Fe());for(let e=this.#q.length-1;e>=0;e--)this.#q[e].at<=this.#K&&(this.#je(this.#q[e].bytes,0,this.#q[e].to),this.#q.splice(e,1));for(const e of this.#V.filter(e=>e.at<=this.#K))this.#Te(e.name,0);this.#V=this.#V.filter(e=>e.at>this.#K);for(const e of this.#R){const t=Math.min(1,(this.#K-e.startTick)/e.ticks);this.#Ce(e.name,e.from+(e.to-e.from)*t)}if(this.#R=this.#R.filter(e=>this.#K-e.startTick<e.ticks),this.#E.length&&this.#W){const e=this.#qe();for(const t of this.#E)e.has(t.name)||this.#Ce(t.name,this.#_e(t))}this.#K%6==0&&this.#ht(this.#K/6),this.#Ye(),this.#tt(),this.#K++,this.#G+=6e4/(24*this.#r)}#lt(){const e=this.#H,t=(this.#ye.length?" ~ "+this.#ye.join(", "):"")+(this.#r!==this.doc.bpm?` ${this.#r}bpm`:""),n=e.transition&&e.transition.startBar<e.bar+this.doc.phraseBars?` → ${e.transition.to} via ${e.transition.name}`:"";this.#we(`${this.#Oe()} ${e.section.padEnd(6)} e${this.#a.energy} [${e.playing.join(" ")}]${n}${t}`)}},ye={C:0,D:2,E:4,F:5,G:7,A:9,B:11};function we(e){const t=/^([A-Ga-g])([#♯b♭]?)(-?\d)$/.exec(e.trim());if(!t)return null;const n="#"===t[2]||"♯"===t[2]?1:t[2]?-1:0,s=12*(Number(t[3])+1)+ye[t[1].toUpperCase()]+n;return s>=0&&s<=127?s:null}var Me=e=>"number"==typeof e?Number.isInteger(e)&&e>=0&&e<=127?e:null:"string"==typeof e?we(e):null;async function $e(e){if(!e.trim())return{doc:null,problems:["This performer document is empty — start from one that plays, such as assets/<style>.performer."]};let t;try{t=JSON.parse(e)}catch(i){return{doc:null,problems:[`not JSON: ${i instanceof Error?i.message:String(i)}`]}}try{const e=function(e){const t=[];for(const[n,s]of Object.entries(e.parts??{}))for(const e of[...s.ev??[],...Array.isArray(s.lines?.ev)?s.lines.ev.flat():[]]){const s=Me(e[1]);null===s?t.push(`part ${n}: the note "${e[1]}" does not read — a name like "F1", "Ab3", "C#4" or a number 0..127`):e[1]=s}for(const[n,s]of Object.entries(e.fills?.kinds??{}))for(const e of s.notes??[]){const s=Me(e[1]);null===s?t.push(`fill ${n}: the note "${e[1]}" does not read`):e[1]=s}return t}(t);if(e.length)return{doc:null,problems:e};const n=function(e){const t=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),n=e;if("performer"!==n?.format)return['not a performer document (no "format": "performer")'];const s=[];for(const I of["parts","knobs","sections","buttons","fills","transitions"])t(n[I])||s.push(`no "${I}" object`);if("string"==typeof e.start||t(e.start)||s.push('no "start" — a section name, or several with their weights'),Number.isFinite(e.bpm)||s.push('no "bpm" number'),Number.isFinite(e.loopSteps)&&Number.isFinite(e.phraseBars)||s.push('no "loopSteps" / "phraseBars" numbers'),!t(n.fills)||Number.isFinite(e.fills.chance)&&Number.isFinite(e.fills.minEnergy)&&t(e.fills.kinds)||s.push('"fills" is { "chance": 0..1, "minEnergy": 0..1, "kinds": { "<name>": … } } — "kinds" may be empty'),s.length)return s;for(const[I,x]of Object.entries(e.sections))t(x)?(Array.isArray(x.phrases)||s.push(`section ${I}: no "phrases" list`),Array.isArray(x.layers)||s.push(`section ${I}: no "layers" list`),t(x.next)||s.push(`section ${I}: no "next" object — the sections that may follow, with weights`)):s.push(`section ${I}: not an object`);for(const[I,x]of Object.entries(e.parts))t(x)?Array.isArray(x.ev)||s.push(`part ${I}: no "ev" list`):s.push(`part ${I}: not an object`);if(s.length)return s;const r=[],o=(e,t)=>{e||r.push(t)},i=t=>t in e.parts,a=t=>t in e.knobs,c=t=>t in e.sections,l=e=>"*"===e||c(e)||J.includes(e),d=e.phraseBars;for(const[I,x]of Object.entries(L(e)))o(c(I),`start: no section "${I}"`),o(Number.isFinite(x)&&x>0,`start: "${I}" needs a weight above 0`);o(void 0===e.genre||e.genre in V,`genre: no genre "${e.genre}" (${Object.keys(V).join(", ")})`);const h=W(e);for(const[I,x]of Object.entries(h))o(!!x&&Number.isFinite(x.enters),`roles.${I}: no "enters" — its place when layers may not all come at once`);const u=I(e),m=u.structure.chooseAhead,p=e=>Number.isFinite(e)&&e>=0&&e<=1;o(Number.isInteger(m)&&m>=1,"style.structure.chooseAhead: a whole number of phrases, at least 1"),o(Number.isInteger(u.structure.entries.max)&&u.structure.entries.max>=1,"style.structure.entries.max: a whole number, at least 1");for(const[I,x]of Object.entries(u.arc.shapes))o(Array.isArray(x)&&x.length>=2&&x.every((e,t)=>Array.isArray(e)&&p(e[0])&&p(e[1])&&(0===t||e[0]>=x[t-1][0])),`style.arc.shapes.${I}: at least two [time, energy] points in 0..1, time rising`);o(Object.values(u.arc.character).every(e=>Number.isFinite(e)&&Math.abs(e)<=1),"style.arc.character: a lift between -1 and 1 per character"),o(Number.isFinite(u.arc.pull)&&u.arc.pull>0,"style.arc.pull: a width above 0"),o(p(u.density.thin),"style.density.thin: 0..1");const f=u.hand;o(f.everyMs>0&&f.step[0]>=1&&f.step[1]>=f.step[0]&&f.turnMs[0]>0&&f.turnMs[1]>=f.turnMs[0]&&p(f.pause)&&f.glideBars>=0&&p(f.glideInset)&&Number.isInteger(f.count)&&f.count>=1,"style.hand: everyMs > 0, step [least ≥ 1, most], turnMs [shortest, longest], pause and glideInset 0..1, glideBars ≥ 0, count a whole number ≥ 1"),o(Number.isInteger(u.ornaments.calmPhrases)&&u.ornaments.calmPhrases>=0,"style.ornaments.calmPhrases: a whole number, at least 0");const g=(...e)=>e.every(e=>Number.isFinite(e)&&e>=0)&&e.some(e=>e>0),b=u.mutation.kit;o(g(b.add,b.remove,b.shift)&&b.addVelocity[0]>=1&&b.addVelocity[1]>b.addVelocity[0]&&b.addVelocity[1]<=128&&Number.isInteger(b.keepHits)&&b.keepHits>=0,"style.mutation.kit: add/remove/shift weights ≥ 0 (one above 0), addVelocity [low ≥ 1, high ≤ 128], keepHits a whole number");const k=u.mutation.melodic;o(g(k.step,k.octave,k.gate,k.copy)&&Number.isInteger(k.stepSemis)&&k.gateRange[0]>0&&k.gateRange[1]>=k.gateRange[0]&&Number.isFinite(k.copyVelocity),"style.mutation.melodic: step/octave/gate/copy weights ≥ 0 (one above 0), stepSemis whole, gateRange [above 0, at least that], copyVelocity a number"),o(Number.isInteger(u.mutation.melodicEvery)&&u.mutation.melodicEvery>=1,"style.mutation.melodicEvery: a whole number of phrases ≥ 1"),o(u.tempo.bpm>0&&Number.isInteger(u.tempo.everyBars)&&u.tempo.everyBars>=1,"style.tempo: bpm above 0, everyBars a whole number ≥ 1"),o("chapters"===u.tempo.follow||"energy"===u.tempo.follow,'style.tempo.follow: "chapters" or "energy"'),o("energy"!==u.tempo.follow||!!e.chapters?.bpm,'style.tempo.follow "energy" needs chapters.bpm — the range it moves in');const v=u.wishes,y=u.checks;o(Number.isInteger(y.melodic.max)&&y.melodic.max>=1,"style.checks.melodic.max: a whole number ≥ 1");for(const[I,x]of Object.entries(y.density))o(J.includes(I)&&Array.isArray(x)&&Number.isInteger(x[0])&&Number.isInteger(x[1])&&x[0]>=0&&x[1]>=x[0],`style.checks.density.${I}: a section function (${J.join(", ")}) with [fewest, most] instruments`);o(p(y.densityShare),"style.checks.densityShare: 0..1"),o(v.fade>0&&v.fade<=1&&p(v.goneBelow)&&p(v.rest)&&p(v.high)&&v.rest<v.high&&Number.isFinite(v.shift.more)&&Number.isFinite(v.shift.build)&&v.tilt>=0,"style.wishes: fade 0..1, goneBelow/rest/high 0..1 with rest below high, shift numbers, tilt ≥ 0");const w=(e,t)=>{o(!!t.instrument!=!!t.master,`${e}: name either the "instrument" (a file of the project) or the "master" slot its param is on`),o("string"==typeof t.param&&t.param.startsWith("/"),`${e}: no "param" — its path, like "/BASS/Cutoff"`),o(void 0===t.min==(void 0===t.max)&&(void 0===t.min||Number.isFinite(t.min)&&Number.isFinite(t.max)),`${e}: "min" and "max" go together, as numbers`)};for(const[I,x]of Object.entries(e.buttons))w(`button ${I}`,x),o(!a(I),`button ${I}: a knob has that name too`);for(const[I,x]of Object.entries(e.knobs)){if(x.swing){o(!x.instrument&&!x.master&&!x.param,`knob ${I}: a swing knob turns no param — no "instrument", "master" or "param"`),o(Array.isArray(x.swing)&&x.swing.length>0&&x.swing.every(t=>t in e.parts),`knob ${I}: "swing" names the parts it moves (${Object.keys(e.parts).join(", ")})`);const t=Array.isArray(x.swing)?x.swing.filter(t=>Object.entries(e.knobs).some(([e,n])=>e!==I&&Array.isArray(n.swing)&&n.swing.includes(t))):[];o(!t.length,`knob ${I}: ${t.join(", ")} already swing${1===t.length?"s":""} by another knob — one swing per part`),o(void 0===x.min==(void 0===x.max)&&(void 0===x.min||x.min>=50&&x.max<=75&&x.min<=x.max),`knob ${I}: a swing's "min" and "max" go together, Linn % 50..75`)}else w(`knob ${I}`,{...x,param:x.param??""});x.wide&&o(x.range[0]>=x.wide[0]&&x.range[1]<=x.wide[1],`knob ${I}: range ${x.range.join("-")} reaches past its wide limits ${x.wide.join("-")}`)}for(const[I,x]of Object.entries(e.parts)){o(x.role in h,`part ${I}: no role "${x.role}" (${Object.keys(h).join(", ")})`),o("string"==typeof x.instrument&&x.instrument.length>0,`part ${I}: no instrument — name the .dsp or .builder it plays`),o(void 0===x.thin||"boolean"==typeof x.thin,`part ${I}: "thin" is true or false`),o(!x.mutate||Object.entries(x.mutate).every(([e,t])=>["add","remove","shift","step","octave","gate","copy"].includes(e)&&Number.isFinite(t)&&t>=0),`part ${I}: "mutate" weighs add, remove, shift (a kit) or step, octave, gate, copy (a line), each ≥ 0`),o(!x.unfold||Number.isInteger(x.unfold.phrases)&&x.unfold.phrases>=1,`part ${I}: "unfold" needs "phrases", a whole number ≥ 1`);const t=e=>"number"==typeof e&&Number.isInteger(e)&&e>=0&&e<=127||"string"==typeof e&&e.length>0,n=e=>Array.isArray(e)&&e.length>0&&e.every(t);if(o(!x.each||Number.isInteger(x.each.cc)&&x.each.cc>=0&&x.each.cc<=127&&void 0===x.each.values!=(void 0===x.each.sets)&&(void 0===x.each.values||n(x.each.values))&&(void 0===x.each.sets||Array.isArray(x.each.sets)&&x.each.sets.length>0&&x.each.sets.every(n)),`part ${I}: "each" is { "cc": 0..127, "values": [a number 0..127 or a name, …] } or { "cc", "sets": [[…], […]] } (one list drawn per phrase) — a value before each note, over that MIDI controller`),o(void 0===x.octave||Number.isInteger(x.octave)&&Math.abs(x.octave)<=3,`part ${I}: "octave" is a whole number −3..3`),o(void 0===x.tones||"scale"===x.tones||"chord"===x.tones,`part ${I}: "tones" is "scale" or "chord"`),o(!x.lines||Number.isFinite(x.lines.chance)&&x.lines.chance>=0&&x.lines.chance<=1&&Array.isArray(x.lines.ev)&&x.lines.ev.length>0&&x.lines.ev.every(e=>Array.isArray(e)&&e.length>0&&e.every(e=>Array.isArray(e)&&4===e.length)),`part ${I}: "lines" is { "chance": 0..1, "ev": [[[step, note, velocity, gate], …], …] } — other figures, one drawn per phrase instead of ev`),o(!x.lines||!x.variants,`part ${I}: "lines" and "variants" not together — a variant's rhythm belongs to ev`),x.variants){for(const e of x.variants.sections)o(c(e),`part ${I}: variants in no section "${e}"`);for(const e of x.variants.rhythms??[])o(e.length===x.ev.length,`part ${I}: a variant needs ${x.ev.length} [step, gate] pairs`);for(const t of x.variants.euclid??[]){const n=x.cycle??e.loopSteps;o(Array.isArray(t)&&t[0]===x.ev.length&&Number.isInteger(t[1])&&t[1]>=t[0]&&t[1]<=n&&(void 0===t[2]||Number.isInteger(t[2])),`part ${I}: a euclid variant is [hits = its ${x.ev.length} events, steps ${x.ev.length}..${n}, rotation?]`)}o(!!x.variants.rhythms?.length||!!x.variants.euclid?.length,`part ${I}: variants need rhythms or euclid`)}}for(const[I,x]of Object.entries(e.fills.kinds??{})){const t=`fill ${I}`;o(Number.isFinite(x.weight)&&x.weight>0,`${t}: no "weight" — how often it comes against the others`),o(void 0===x.at||Number.isInteger(x.at)&&x.at>=0&&x.at<=15,`${t}: "at" is a step of the bar, 0..15`);for(const e of x.mute??[])o(i(e),`${t}: mutes no part "${e}"`);x.hold&&o(x.hold in e.buttons,`${t}: no button "${x.hold}"`),o(!x.notes==!x.instrument,`${t}: "notes" and the "instrument" that plays them go together`)}const M=(t,n)=>{if(n)for(const s of n.do){if(s.knob&&o(a(s.knob),`${t}: no knob "${s.knob}"`),s.hold&&o(s.hold in e.buttons,`${t}: no button "${s.hold}"`),void 0!==s.roll){const n=new Set(e.parts[s.roll]?.ev.map(e=>e[1]));o(1===n.size,i(s.roll)?`${t}: a roll on ${s.roll}, which plays more than one note`:`${t}: a roll on no part "${s.roll}"`)}for(const e of[...s.mute??[],...s.solo??[]])o(i(e),`${t}: no part "${e}"`);o((s.at??0)+(s.len??1)<=n.beats,`${t}: an action runs past its ${n.beats} beats`)}},$=e=>(e?.do??[]).filter(e=>e.gap),S=e=>new Set((e?.do??[]).filter(e=>e.knob).map(e=>e.knob));for(const[I,x]of Object.entries(e.sections)){o(J.includes(x.fn),`section ${I}: no function "${x.fn}" (${J.join(", ")})`),o(x.phrases.length>0&&x.phrases.every(e=>Number.isInteger(e)&&e>=1),`section ${I}: phrases must be whole numbers from 1 on`);for(const t of x.layers)o(i(t),`section ${I}: no part "${t}"`);for(const t of Object.keys(x.guests??{}))o(i(t),`section ${I}: no guest part "${t}"`);for(const t of Object.keys(x.next))o(c(t),`section ${I}: next to no section "${t}"`);o(Object.values(x.next).some(e=>Number.isFinite(e)&&e>0),`section ${I}: "next" needs a section with a weight above 0 — the run has to go on somewhere`);for(const t of x.hands??[])o(a(t),`section ${I}: hand on no knob "${t}"`);void 0!==x.handCount&&o(Number.isInteger(x.handCount)&&x.handCount>=1,`section ${I}: handCount is a whole number, at least 1`);for(const t of Object.keys(x.ranges??{}))o(a(t),`section ${I}: range for no knob "${t}"`);for(const[t,n]of Object.entries(x.sweep??{}))o(a(t),`section ${I}: sweep of no knob "${t}"`),o(Array.isArray(n)&&2===n.length&&n.every(e=>Number.isFinite(e)&&e>=0&&e<=127),`section ${I}: the sweep of ${t} runs [from, to] within 0..127`);const e=Math.min(...x.phrases);for(const t of x.grow??[]){for(const e of[...t.add??[],...t.remove??[]])o(i(e),`section ${I}: grow names no part "${e}"`);o(Number.isInteger(t.phrase)&&t.phrase>=1&&t.phrase<e,`section ${I}: its growth at phrase ${t.phrase+1} does not fit its shortest length of ${e} phrases`)}}for(const[I,x]of Object.entries(e.transitions)){const t=`transition ${I}`;for(const e of[...x.from,...x.to])o(l(e),`${t}: no section or function "${e}"`);for(const e of[...x.with??[],...x.arrival?.add??[]])o(i(e),`${t}: no part "${e}"`);M(t,x.gesture),M(`${t} (arrival)`,x.arrival?.gesture),o(Number.isInteger(x.lead)&&x.lead>=0&&x.lead<=m*d,`${t}: a lead of ${x.lead} bars — at most ${m*d}, the planner chooses the next section ${m} phrases ahead`);for(const[r,i]of Object.entries(e.sections))U(x.from,r,i)&&!x.from.includes("*")&&o(x.lead<=Math.min(...i.phrases)*d,`${t}: its ${x.lead}-bar lead is longer than ${r} can be`);const n=[...$(x.gesture),...$(x.arrival?.gesture)];o(n.length<=1,`${t}: ${n.length} silences — one at most`);for(const e of n)o((e.len??1)<=4,`${t}: a silence of ${e.len} beats — one bar at most; longer is a break, not a gap`);const s=[...S(x.gesture)].filter(e=>S(x.arrival?.gesture).has(e));if(x.gesture&&x.arrival?.gesture&&x.gesture.beats>4*x.lead&&o(!s.length,`${t}: its gesture runs past the change and its arrival moves the same knobs (${s.join(", ")})`),void 0!==x.arrival?.phrases||void 0!==x.arrival?.from)for(const[r,i]of Object.entries(e.sections)){if(!U(x.to,r,i)||x.to.includes("*"))continue;const e=(x.arrival.from??0)+(x.arrival.phrases??1);o(e<=Math.min(...i.phrases),`${t}: its arrival runs ${e} phrases, longer than ${r} can be`)}}for(const[I,x]of Object.entries(e.sections))for(const t of Object.keys(x.next)){const n=e.sections[t];n&&o(Object.values(e.transitions).some(e=>U(e.from,I,x)&&U(e.to,t,n)),`no transition from ${I} to ${t}`)}for(const[I,x]of Object.entries(e.ornaments??{})){for(const e of x.in)o(l(e),`ornament ${I}: no section or function "${e}"`);M(`ornament ${I}`,x),o(x.beats<=4*d,`ornament ${I}: ${x.beats} beats — an ornament fits in a phrase`)}return r}(t);if(n.length)return{doc:null,problems:n}}catch(i){return{doc:null,problems:[`not a readable performer document: ${i instanceof Error?i.message:String(i)}`]}}const n=e=>l().files.readText(e),s=re(t,await oe(t,n,te(l().extensions.listTabKinds()))),r=Object.entries({...t.buttons,...t.knobs}),o=[];for(const a of new Set(r.map(([,e])=>e.instrument).filter(e=>!!e)))try{await n(`asset:assets/${a}`)}catch{o.push(`${r.filter(([,e])=>e.instrument===a).map(([e])=>e).join(", ")}: no document "${a}" in the project`)}return o.length?{doc:null,problems:[...s.problems,...o]}:s}async function Ie(n){const s=n||m(N).ruleBook;if(s||e("No performer document chosen — name one like asset:assets/<style>.performer."),!t(s))return`"${s}" is not a project asset — name it like asset:assets/<style>.performer.`;let r;try{r=await l().files.readText(s)}catch(a){return`The document ${s} could not be read: ${a instanceof Error?a.message:String(a)}`}const{doc:o,problems:i}=await $e(r);return o?{ref:s,doc:o}:{ref:s,problems:i}}function Se(e,t){const n=e.map(e=>{const n=t.find(t=>t.filePath===`asset:assets/${e}`);return n?{file:e,state:n.runStatus??"idle",module_id:n.id}:{file:e,state:"closed"}});return{ready:n.every(e=>"running"===e.state),instruments:n}}var xe=e=>e.replace(/\.[^.]+$/,"");function je(e){const t=new Map,n=(e,n)=>t.get(e)??t.set(e,{name:e,...n?{file:n}:{},parts:[],knobs:[]}).get(e);for(const[r,o]of Object.entries(e.parts))n(xe(o.instrument),o.instrument).parts.push(r);for(const[r,o]of Object.entries(e.knobs))o.instrument&&n(xe(o.instrument),o.instrument).knobs.push(r);for(const[r,o]of Object.entries(e.knobs))o.swing&&n("SWING").knobs.push(r);for(const[r,o]of Object.entries(e.knobs))o.master&&n("MASTER").knobs.push(r);let s=0;for(const r of t.values())r.parts.length&&(r.track=s++%6+1);return[...t.values()]}function Be(e){const t=t=>e.do.some(e=>Array.isArray(e[t])?e[t].length>0:!!e[t]);return t("roll")?"roll":t("hold")?"stutter":t("gap")?"hole":t("mute")?"mute":t("solo")?"solo":"sweep"}var Pe=null,Ne=2e4,Ae=!1,Te=!1;async function De(e={}){if(Pe||Ae)return"The Performer is already playing.";Ae=!0,Te=!1;try{return await async function(e){const t=l(),n=m(N),r=e=>(N.update(t=>({...t,error:e})),e),o=await Oe(e);if("string"==typeof o)return r(o);const{ref:i,rules:a,shape:c,seed:d}=o,h=void 0!==e.minutes?e.minutes:n.choice.minutes;if(Te)return"Stopped before the run began.";qe.clear();for(const s of function(e){return e.instruments.flatMap(e=>e.module_id&&"running"!==e.state&&"error"!==e.state?[e.module_id]:[])}(Se(ne(a),t.documents.listModules())))if(await t.actions.run("dsp.run",{module_id:s}),qe.add(s),Te)return"Stopped before the run began.";await async function(e){const t=l(),n=new Set(t.routing.getTable().connections.filter(e=>"midi"===e.kind&&"performer"===e.from.sourceId).map(e=>e.to.sinkId));for(const s of ne(e)){const e=He({instrument:s});e&&![...n].some(t=>t===e||t.startsWith(`${e}:`))&&await t.actions.run("routing.connect",{kind:"midi",from_source:P,from_port:"out",to_sink:`${e}:midi-in`,to_port:"in"})}}(a);const u=s("Performer"),p=t.transport.listPlayers().find(e=>e.playing&&"performer"!==e.id);if(p)return r(`${p.label} is playing — stop it first; the Performer starts the song.`);const g=t.transport.getBpm();try{t.transport.setBpm(a.bpm,{transient:!0})}catch(M){return r(`The Performer leads the tempo, but an external clock does now (${M instanceof Error?M.message:String(M)}). Stop that clock or remove its route to the transport, then start again.`)}t.transport.isPlaying()&&t.transport.stop();const k={core:null,release:null,scheduledUpTo:-1,time:void 0,dur:15/a.bpm,stale:!1,lastTime:void 0,bpm:a.bpm,bpmBefore:g,minutes:h,ruleBook:i,seed:d,shape:c,ending:!1,ended:!1,notes:{onTime:0,late:0,dropped:0},touched:new Map,projectedPhrase:-1,modules:new Map};k.core=new ve(a,d,{midi:(e,t,n)=>function(e,t,n=0,s){const r=l();if(144==(240&t[0])&&t[2]>0){if(e.stale)return void e.notes.dropped++;void 0!==e.time&&e.time>r.audio.getContext().currentTime?e.notes.onTime++:e.notes.late++}const o=void 0!==e.time&&n?e.time+n*e.dur:e.time;(void 0===e.lastTime||void 0!==o&&o>e.lastTime)&&(e.lastTime=o);void 0===s||e.modules.has(s)||e.modules.set(s,He({instrument:s}));const i=void 0===s?void 0:e.modules.get(s);r.midi.dispatchFromSource(P,t,i?{time:o,to:i}:{time:o})}(k,e,t,n),control:(e,t)=>function(e,t,n){if(e.ending)return;const r=l();let o=_e.get(t);if(null===o)return;if(void 0===o){const n=e.core.doc.knobs[t]??e.core.doc.buttons[t];if(!n||!n.param)return void _e.set(t,null);const i=s("Performer"),a=He(n);if(!a)return _e.set(t,null),Ke.add(t),void i.warn(`"${t}": ${n.instrument} is not open in the project — the Performer cannot turn it.`);if(Le(a,n.param))return _e.set(t,null),Ke.add(t),void i.warn(`"${t}": ${n.param} on ${a} is driven by a modulation — the Performer leaves it alone.`);const c=r.params.list(a).find(e=>e.path===n.param),l=n.min??c?.min,d=n.max??c?.max;if(void 0===l||void 0===d)return;o={sinkId:a,path:n.param,range:[l,d],whole:[c?.min??l,c?.max??d],scale:c?.scale??"linear"},_e.set(t,o)}if(l().params.held(o.sinkId,o.path))return;e.touched.set(`${o.sinkId} ${o.path}`,[o.sinkId,o.path]),r.params.setLive(o.sinkId,o.path,f(n/127,o.range[0],o.range[1],o.whole[0],o.whole[1],o.scale),e.time)}(k,e,t),log:e=>u.info(e)},c),k.core.playAhead(e.fromBar??0),u.info(`START "${a.name}" ${i} seed=${d}${e.fromBar?` from bar ${e.fromBar}`:""}${k.minutes?` minutes=${k.minutes}`:""}`),Pe=k,_e.clear(),Ke.clear(),N.update(e=>({...e,ruleBook:i,playing:!0,error:null,run:{seed:d,ruleBook:i,name:a.name,startedAt:Date.now(),minutes:k.minutes,shape:c,allParts:Object.keys(a.parts),groups:je(a),knobLabels:Object.entries(a.knobs).flatMap(([e,t])=>t.label?[[e,t.label]]:[]),momentNames:Object.keys(a.ornaments??{}),momentFits:Object.fromEntries(Object.entries(a.ornaments??{}).map(([e,t])=>[e,t.in])),momentKinds:Object.fromEntries(Object.entries(a.ornaments??{}).map(([e,t])=>[e,Be(t)])),momentBeats:Object.fromEntries(Object.entries(a.ornaments??{}).map(([e,t])=>[e,t.beats])),snapshot:k.core.snapshot(),projection:null,conductedFrom:null,blocked:[],notes:{...k.notes}}}));try{const e=await t.transport.clock.acquire((e,t)=>function(e,t){if(Pe!==e)return;const n=l().transport.clock,s=b(n,t);for(let r=e.scheduledUpTo>=0?e.scheduledUpTo+1:t;r<=s&&Pe===e;r++)Ve(e,r)}(k,t));if(Pe!==k)return e(),"Stopped before the clock came up.";k.release=e}catch(M){return Ce(k,!1),r(`The transport clock could not start: ${M instanceof Error?M.message:String(M)}`)}t.transport.play(e.fromBar?{fromStep:16*e.fromBar}:void 0);const v=t.transport.clock,y=v.startStep(),w=v.stepTime(y);null!==w&&w>t.audio.getContext().currentTime-(v.stepDuration()??0)&&Ve(k,y);return`Performing "${a.name}" from ${i}, seed ${d}${e.fromBar?`, from bar ${e.fromBar}`:""}.`}(e)}finally{Ae=!1}}async function Oe(e){const n=m(N),s=e.ruleBook??n.ruleBook;if(!s)return"No rule book chosen — pick a .performer asset of the project, such as asset:assets/<style>.performer.";if(!t(s))return`"${s}" is not a project asset — a rule book is named like asset:assets/<style>.performer.`;const r=await Ie(s);if("string"==typeof r)return r;if(!("doc"in r))return`${s} is not a playable rule book: ${r.problems.join("; ")}.`;const o=r.doc,i=await async function(e){for(const[t,n]of Object.entries(e.parts)){const s=n.each,r=s?s.sets??(s.values?[s.values]:[]):[];if(!s||r.every(e=>e.every(e=>"number"==typeof e)))continue;const o=He({instrument:n.instrument}),i=[...new Set(r.flat().filter(e=>"string"==typeof e))].join(", ");if(!o)return`Part "${t}": its instrument ${n.instrument} is not open — its "each" names (${i}) come from it. Open it, or write numbers.`;const a=l();"running"!==a.documents.listModules().find(e=>e.id===o)?.runStatus&&await a.actions.run("dsp.run",{module_id:o});const c=a.params.list(o).find(e=>e.cc===s.cc);if(!c)return`Part "${t}": ${n.instrument} has no param on MIDI CC ${s.cc} — a slider needs [midi:ctrl ${s.cc}] for "each" to reach it.`;const d=[];for(const e of r){const s=[];for(const r of e){const e="number"==typeof r?r:c.options?.[r];if(void 0===e){const e=c.options?` (${Object.keys(c.options).join(", ")})`:" (it has no menu — write numbers)";return`Part "${t}": "${r}" is no value of ${n.instrument} ${c.path}${e}.`}const o=(c.max??127)-(c.min??0);s.push("number"!=typeof r&&o>0?Math.min(127,Math.ceil((e-(c.min??0))/o*127-1e-9)):e)}d.push(s)}e.parts[t]={...n,each:s.sets?{cc:s.cc,sets:d}:{cc:s.cc,values:d[0]}}}return null}(o);if(i)return i;if(void 0!==e.arc&&!S.includes(e.arc))return`No arc "${e.arc}" — ${S.join(", ")}.`;if(void 0!==e.character&&!x.includes(e.character))return`No character "${e.character}" — ${x.join(", ")}.`;const a=void 0!==e.minutes?e.minutes:n.choice.minutes,c={arc:e.arc??n.choice.arc,character:e.character??n.choice.character,minutes:a??j.minutes};if(void 0!==e.fromBar&&!(Number.isInteger(e.fromBar)&&e.fromBar>=0&&e.fromBar<=2e4))return"from_bar must be a whole bar from 0 to 20000.";const d=e.seed??n.seed??Math.floor(1e6*Math.random());if(e.fromBar&&null!==a){const t=new ve(o,d,{midi:()=>{},control:()=>{},log:()=>{}},c);if(t.playAhead(e.fromBar,6e4*a),t.elapsedMs>=6e4*a)return`Bar ${e.fromBar} lies past the run's ${a} minutes.`}return{ref:s,rules:o,shape:c,seed:d}}async function Re(t,n){const s=l(),r=s.transport.listPlayers().filter(e=>e.playing&&"performer"!==e.id).map(e=>e.id),o=await Oe(n??{});"string"==typeof o&&e(o);const i=[...qe];let a;qe.clear(),Ce(t,!0,{keepState:!0});try{a=await De(n)}finally{const e=s.documents.listModules(),t=new Set(e.map(e=>e.id)),n=new Set(Se(ne(o.rules),e).instruments.flatMap(e=>e.module_id?[e.module_id]:[]));for(const r of i)Pe&&n.has(r)?qe.add(r):t.has(r)&&await s.actions.run("dsp.stop",{module_id:r});Pe||N.update(e=>({...e,playing:!1,run:null}))}return Pe&&r.length&&await s.transport.startPlayers(r),a}function Ee(){return Ae&&!Pe?(Te=!0,"Stopped the Performer before it began."):Pe?(Ce(Pe,!1),"Stopped the Performer."):"The Performer is not playing."}function Ce(e,t,n={}){if(e.ended)return;e.ended=!0;const r=l();e.time=e.lastTime,e.stale=!1,e.ending=!0,e.core.finish();for(const[s,i]of e.touched.values())r.params.held(s,i)||r.params.setLive(s,i,r.params.getBase(s,i),e.time);e.release?.(),Pe===e&&(Pe=null);try{r.transport.setBpm(e.bpmBefore,{transient:!0})}catch{}n.keepState||N.update(e=>({...e,playing:!1,run:null}));const o=e.notes;s("Performer").info(`STOP at ${(e.core.elapsedMs/6e4).toFixed(1)} min, bar ${e.core.snapshot().bar}; note-ons ${o.onTime} on time, ${o.late} late, ${o.dropped} dropped`),t&&r.transport.isPlaying()&&r.transport.stop()}function ze(t){Pe||e("The Performer is not playing — start it first."),"moment"!==t.kind||Pe.core.doc.ornaments?.[t.name]||e(`No moment "${t.name}" in this rule book — performer.state lists them.`),"part"!==t.kind||t.part in Pe.core.doc.parts||e(`No part "${t.part}" in this rule book.`),Pe.core.conduct(t);const n=Pe.core.snapshot(),s=Fe(Pe);return N.update(e=>e.run?{...e,run:{...e.run,snapshot:n,...s}}:e),function(e){switch(e.kind){case"energy":return`Energy ${e.value>0?"+":""}${e.value.toFixed(2)} from the next bar.`;case"hold":return e.on?"Holding the section — it grows phrase by phrase.":"Let go — the section ends as planned.";case"next":return"The section ends with this phrase.";case"moment":return`${e.name} on the next bar.`;case"part":return`${e.part}: ${[void 0!==e.muted?e.muted?"muted":"unmuted":"",void 0!==e.soloed?e.soloed?"solo":"solo off":""].filter(Boolean).join(", ")}.`;case"wish":return`Noted: ${de[e.wish]}. It tilts the choice of the next section, within the arc and the rules — performer.state says what became of it.`}}(t)}function Fe(e){const t=e.core.conductedFrom;return null===t?{projection:null,conductedFrom:null}:{projection:e.core.projection(6e4*(e.minutes??60)),conductedFrom:t}}var qe=new Set;function Ve(e,t){const n=l(),s=n.transport.clock,{t0:r,dur:o,stale:i}=g(s,t,e.bpm,n.audio.getContext().currentTime);e.dur=o,e.stale=i;for(let l=0;l<6;l++)e.time=null===r?void 0:r+l*o/6,void 0!==e.time&&(void 0===e.lastTime||e.time>e.lastTime)&&(e.lastTime=e.time),e.core.tick();if(e.scheduledUpTo=t,e.core.bpm!==e.bpm){e.bpm=e.core.bpm;try{n.transport.setBpm(e.bpm,{transient:!0})}catch(h){return N.update(e=>({...e,error:`An external clock took the tempo: ${h instanceof Error?h.message:String(h)}`})),void Ce(e,!0)}}const a=e.core.snapshot(),c=e.core.phraseIndex,d=c!==e.projectedPhrase?(e.projectedPhrase=c,Fe(e)):{};N.update(t=>t.run?{...t,run:{...t.run,snapshot:a,...d,blocked:[...Ke],notes:{...e.notes}}}:t),null!==e.minutes&&e.core.elapsedMs>=6e4*e.minutes&&Ce(e,!l().transport.listPlayers().some(e=>e.playing&&"performer"!==e.id))}var _e=new Map,Ke=new Set,Ge=e=>e.slice(e.lastIndexOf("/")+1);function He(e){return e.master?h(e.master):l().documents.listModules().find(t=>t.filePath&&Ge(t.filePath)===e.instrument)?.id}function Le(e,t){return l().routing.getTable().connections.some(n=>"modulation"===n.kind&&!1!==n.enabled&&n.to.sinkId===e&&n.to.portId===t)}async function We(e){const t=await async function(e){const t=await Ie(e);return"string"==typeof t?t:"doc"in t?ne(t.doc):`${t.ref}: ${t.problems.join("; ")}`}(e);return"string"==typeof t?t:Se(t,l().documents.listModules())}async function Je(e){const t=await We(e);if("string"==typeof t)return t;if(t.ready)return`${Ue(e)} is ready: every instrument runs.`;const n=l();for(const o of t.instruments)o.module_id&&"running"!==o.state&&await n.actions.run("dsp.run",{module_id:o.module_id});const s=await We(e);if("string"==typeof s)return s;const r=function(e){const t=e.instruments.filter(e=>"running"!==e.state);if(!t.length)return null;const n=e=>t.filter(t=>t.state===e).map(e=>e.file);return[n("idle").length?`not running: ${n("idle").join(", ")}`:"",n("compiling").length?`compiling: ${n("compiling").join(", ")}`:"",n("error").length?`failing: ${n("error").join(", ")}`:"",n("closed").length?`not open: ${n("closed").join(", ")}`:""].filter(Boolean).join("; ")}(s);return r?`${Ue(e)} is not ready — ${r}.`:`${Ue(e)} is ready: every instrument runs.`}var Ue=e=>e.replace(/^.*\//,"").replace(/\.performer$/,""),Qe="conductor";function Ze(){const e=l().routing.registerSource({id:P,kind:"midi",label:"Performer",outputs:[{id:"out",label:"out"}],meta:{kind:"performer"},permanent:!0}),t=function(){const e=l(),t=e.routing.registerSource({id:Qe,kind:"modulation",label:"Conductor",outputs:[{id:"energy",label:"energy"},{id:"section",label:"section"},{id:"change",label:"change"},{id:"moment",label:"moment"}],meta:{kind:"conductor"},permanent:!0}),n=new Map,s=(t,s)=>{n.get(t)!==s&&(n.set(t,s),e.modulation.setSourceValue(Qe,t,s))},r=N.subscribe(e=>{const t=e.run?.snapshot;s("energy",t?.energy??0),s("section",t&&t.sectionBars>0?Math.min(1,t.sectionBar/t.sectionBars):0),s("change",t&&0===t.sectionBar?1:0),s("moment",t&&t.moments.length>0?1:0)});return()=>{r(),e.modulation.clearSourceValues(Qe),t()}}(),n=d(l().transport,{onStop:()=>{if(Pe&&Ce(Pe,!1),!qe.size)return;const e=l(),t=new Set(e.documents.listModules().map(e=>e.id));for(const n of qe)t.has(n)&&e.actions.run("dsp.stop",{module_id:n});qe.clear()}}),s=function(){const e=l();let t="";const n=N.subscribe(n=>{const s=`${!!n.run}|${(n.run?.groups??[]).map(e=>e.file??"").join(",")}|${n.run?.snapshot?.section??""}|${n.run?.snapshot?.role??""}|${n.run?.snapshot?.sectionBars??""}|${n.run?.snapshot?.upcoming??""}`;s!==t&&(t=s,e.transport.playersChanged())}),s=e.transport.registerPlayer({id:P,label:()=>{const e=m(N).ruleBook;return e?e.slice(e.lastIndexOf("/")+1):"Performer"},follows:()=>{const e=m(N);return e.follows&&null!==e.ruleBook},playing:()=>null!==Pe||Ae,leads:!0,start:async()=>{const e=await De();return{ok:null!==Pe,message:e}},cancelStart:()=>{Ae&&!Pe&&Ee()},plays:()=>(m(N).run?.groups??[]).flatMap(e=>e.file?[e.file]:[]),part:()=>{const e=m(N).run?.snapshot;return e?{name:e.section,role:e.role,bars:e.sectionBars,bar:e.sectionBar,next:e.upcoming?{name:e.upcoming,role:e.upcomingRole??""}:null,...e.chapter>0?{chapter:e.chapter}:{}}:null}});return()=>{n(),s()}}();return()=>{Ee(),s(),n(),t(),e()}}var Xe=(e,t)=>e===t?`${e}`:`${e}–${t}`;function Ye(e){const t=e.genre?V[e.genre]:void 0;if(!t)return[];const n=[],{min:s,max:r}=t.tempo,i=e=>e<s?"below":e>r?"above":null;i(e.bpm)&&n.push(`its ${e.bpm} BPM lie ${i(e.bpm)} ${t.name}'s ${Xe(s,r)}`);for(const o of e.chapters?.bpm??[])o!==e.bpm&&i(o)&&n.push(`its chapters move the tempo to ${o} BPM, ${i(o)} ${t.name}'s ${Xe(s,r)}`);const a=Object.entries(e.knobs).filter(([,e])=>e.swing);!a.length&&t.swing.default>50&&n.push(`it does not swing — ${t.name} swings at ${t.swing.default} % (${Xe(t.swing.min,t.swing.max)})`);for(const[d,h]of a){const e=Math.round(o(h.home,h.min,h.max));(e<t.swing.min||e>t.swing.max)&&n.push(`its swing "${d}" sits at ${e} % — ${t.name} swings ${Xe(t.swing.min,t.swing.max)} %`)}const c=e.harmonyNames;c&&!t.harmony.scales.includes(c.scale)&&n.push(`its scale ${c.scale} is not one of ${t.name}'s (${t.harmony.scales.join(", ")})`);const l=[c?.original,...c?.progressions??[]].filter(e=>!!e&&e in z&&!t.harmony.progressions.includes(e));if(l.length&&n.push(`it plays ${[...new Set(l)].join(", ")}, which ${t.name} does not name (${t.harmony.progressions.join(", ")})`),null===t.form.breakdownBars){const s=Object.entries(e.sections).filter(([,e])=>"breakdown"===e.fn).map(([e])=>e);s.length&&n.push(`${s.join(", ")} ${1===s.length?"is a breakdown":"are breakdowns"} — ${t.name} does without one`)}return n.map(e=>({rule:"genre",text:`${t.genreId}: ${e}`}))}var et=96,tt=24,nt=(e,t)=>`bar ${e} (${(e=>`${Math.floor(e/6e4)}:${String(Math.floor(e%6e4/1e3)).padStart(2,"0")}`)(t)})`;var st=()=>new Promise(e=>setTimeout(e,0));async function rt(e,t,n,s,r=st){const o={...j,minutes:n,...s},i=function(e,t,n){const s=[],r=[],o=new ve(e,t,{midi:e=>{144==(240&e[0])&&e[2]>0&&r.push({tick:o.tickCount,ch:1+(15&e[0]),note:e[1]})},event:e=>s.push(e)},n);return{core:o,events:s,notes:r}}(e,t,o);let a=performance.now();for(;i.core.elapsedMs<6e4*n;)i.core.tick(),performance.now()-a>8&&(await r(),a=performance.now());return i.core.finish(),function(e,t,n,s,{core:r,events:o,notes:i}){const a=[],c=W(e),l=(t,n)=>!!c[e.parts[t]?.role]?.[n],d=o.filter(e=>"section"===e.kind),h=o.filter(e=>"phrase"===e.kind),u=o.filter(e=>"gesture"===e.kind),m=t=>e.sections[t]?.energy??0,p=t=>{if("ornament"===t.gesture||"conducted"===t.gesture)return e.ornaments?.[t.name];const n=e.transitions[t.name];return"arrival"===t.gesture?n?.arrival?.gesture:n?.gesture},f=new Set(d.filter(e=>e.drop).map(e=>e.tick));for(let I=1;I<h.length;I++){const e=h[I],t=e.playing.filter(e=>!h[I-1].playing.includes(e));if(t.length>=3&&!f.has(e.tick)){const n=h[I-1].section;a.push({rule:"R3",bar:e.bar,ms:e.ms,text:`${nt(e.bar,e.ms)}: ${t.join(", ")} enter at once${n!==e.section?` (${n} → ${e.section})`:""}`})}}const g=u.flatMap(e=>(p(e)?.do??[]).filter(e=>e.gap).map(t=>({name:e.name,from:e.tick+(t.at??0)*tt,to:e.tick+((t.at??0)+(t.len??1))*tt})));for(const I of d.slice(1)){const e=g.filter(e=>e.to>I.tick-768&&e.from<I.tick+768);e.length>1&&a.push({rule:"R4",bar:I.bar,ms:I.ms,text:`${nt(I.bar,I.ms)}: ${e.length} silences around the change into ${I.name} (${e.map(e=>e.name).join(", ")})`});const t=u.filter(e=>e.tick>=I.tick-192&&e.tick<I.tick+192);t.length>2&&a.push({rule:"R5",bar:I.bar,ms:I.ms,text:`${nt(I.bar,I.ms)}: ${t.length} gestures on the change into ${I.name} (${t.map(e=>e.name).join(", ")})`})}const b=e=>[...h].reverse().find(t=>t.tick<=e)?.playing??[];for(const I of u)if("arrival"!==I.gesture)for(const e of p(I)?.do??[]){if(!e.solo)continue;const t=I.tick+((e.at??0)+(e.len??1))*tt,n=b(t).filter(t=>!e.solo.includes(t));if(n.length>=4){const e=Math.floor(t/et);a.push({rule:"R7",bar:e,ms:I.ms,text:`${nt(e,I.ms)}: ${I.name}'s solo ends with ${n.length} layers back at once (${n.join(", ")})`})}}const k=Object.entries(e.parts).filter(([,e])=>e.flow).map(([e])=>e),v=e.phraseBars;for(const I of u)for(const t of p(I)?.do??[]){const n=t.gap||t.hold&&e.buttons[t.hold]?.cut?k:t.mute?k.filter(e=>t.mute.includes(e)):t.solo?k.filter(e=>!t.solo.includes(e)):[];if(!n.length)continue;const s=I.tick+(t.at??0)*tt,r=s+(t.len??1)*tt,o=(Math.floor(s/et/v)*v+v-1)*et;if(s>=o&&r<=o+et)continue;const i=Math.floor(s/et),c=b(s),l=n.filter(e=>c.includes(e));l.length&&a.push({rule:"R13",bar:i,ms:I.ms,text:`${nt(i,I.ms)}: ${I.name} cuts ${l.join(", ")} for ${t.len??1} beat${1===(t.len??1)?"":"s"} in the middle of a phrase — the flow breaks`})}let y=0,w=null;for(const I of h)I.playing.some(e=>l(e,"air"))||(y++,w??=I);y&&w&&a.push({rule:"R14",bar:w.bar,ms:w.ms,text:`${y} phrase${1===y?"":"s"} without any atmosphere (no part whose role is air), the first at ${nt(w.bar,w.ms)} in ${w.section}`});const M=new Map,$=(t,n)=>Object.values(e.transitions).filter(s=>U(s.from,t,e.sections[t])&&U(s.to,n,e.sections[n])).length;d.forEach((e,t)=>{if(0===t||$(d[t-1].name,e.name)<2)return;const n=e.via??"nothing",s=M.get(e.name),r=s&&s.via===n?s.run+1:1;M.set(e.name,{via:n,run:r}),3===r&&a.push({rule:"R8",bar:e.bar,ms:e.ms,text:`${nt(e.bar,e.ms)}: the way into ${e.name} is ${n} for the third time in a row`})});const S=I(e).wishes;let x=0,j=0;d.forEach((e,t)=>{const n=d[t+1];!n||m(e.name)<S.high||(x++,m(n.name)<=S.rest&&j++)}),x>=4&&j/x>.7&&a.push({rule:"R9",text:`${j} of ${x} high sections fall straight into a rest (${Math.round(100*j/x)} %) — no plateau, a seesaw`});let P=0,N=0;d.forEach((t,r)=>{const o=d[r+1]?.ms??6e4*n,i=B(s,(t.ms+o)/2,I(e).arc);P+=Math.abs(m(t.name)-i)*(o-t.ms),N+=o-t.ms}),N&&P/N>.2&&a.push({rule:"R10",text:`the run strays from its ${s.arc} arc by ${(P/N).toFixed(2)} on average — its sections cannot follow the dramaturgy`});const A=new Set(Object.keys(e.parts).filter(e=>l(e,"sub")));let T=0,D=0;h.forEach((e,t)=>{const n=(h[t+1]?.bar??Math.floor(r.tickCount/et))-e.bar;D+=n,e.playing.filter(e=>A.has(e)).length>2&&(T+=n)}),A.size>2&&D&&T/D>.1&&a.push({rule:"R11",text:`${[...A].join(", ")} all play together in ${Math.round(100*T/D)} % of the bars — three low parts at once muddy the sub`});const O=new Map;for(const I of Object.keys(e.parts))O.set(e.channels[I],[...O.get(e.channels[I])??[],I]);for(const[I,B]of O){if(e.keyed[B[0]]||1!==B.length||!l(B[0],"melodic"))continue;const t=new Map;for(const e of i){if(e.ch!==I)continue;const n=Math.floor(e.tick/384);t.set(n,[...t.get(n)??[],`${e.tick%384}:${e.note}`])}let n=0,s="",r=0;const o=()=>{if(n<8)return;const e=4*r,t=h.find(t=>t.bar>=e)?.ms??0;a.push({rule:"R12",bar:e,ms:t,text:`${nt(e,t)}: ${B[0]} plays the same notes for ${4*n} bars`})};for(const e of[...t.keys()].sort((e,t)=>e-t)){const i=t.get(e).join(",");i===s&&t.has(e-1)?n++:(o(),n=1,r=e),s=i}o()}a.sort((e,t)=>(e.bar??-1)-(t.bar??-1));const R=I(e).checks,E=Object.keys(c).filter(e=>c[e].melodic),C=h.filter(e=>e.playing.filter(e=>l(e,"melodic")).length>R.melodic.max);if(C.length){const e=C[0];a.push({rule:"R17",bar:e.bar,ms:e.ms,text:`${C.length} phrases with more than ${R.melodic.max} melodic voices (${E.join(", ")}) at once — first at ${nt(e.bar,e.ms)}`})}const z=new Map;for(const I of h){const t=e.sections[I.section]?.fn,n=t?R.density[t]:void 0;if(!t||!n)continue;const s=z.get(t)??z.set(t,{n:0,out:[]}).get(t);s.n++;const r=new Set(I.playing.map(t=>e.parts[t].instrument)).size;(r<n[0]||r>n[1])&&s.out.push(r)}for(const[I,B]of z){if(B.out.length/B.n<=R.densityShare)continue;const e=R.density[I],t=[...new Set(B.out)].sort((e,t)=>e-t).join(", ");a.push({rule:"R18",text:`${I}: ${B.out.length} of ${B.n} phrases with ${t} instruments — the style gives ${e[0]}–${e[1]}`})}return{seed:t,minutes:n,findings:[...Ye(e),...a]}}(e,t,n,o,i)}function ot(e,t,n){const s=function(e,t,n){return s=>{const r=e.findIndex((t,n)=>s>=t.bar&&(n===e.length-1||s<e[n+1].bar));if(r<0)return s<(e[0]?.bar??0)?0:n;const o=e[r],i=e[r+1]?.ms??n;return o.ms+(s-o.bar)*(i-o.ms)/t}}(t,e.phraseBars,n),r=[],o=[],i=[],a=[],c=new Map;let l=0;t.forEach((d,h)=>{const u=(e=>t[e+1]?.ms??n)(h);d.chapter&&(l=d.chapter.index);const m=r[r.length-1];0!==d.phraseInSection&&m?m.to=u:(r.push({name:d.section,fn:d.fn,energy:e.sections[d.section].energy,from:d.ms,to:u,bar:d.bar,role:fe(d.fn,d.energy),chapter:l}),d.entered&&o.push({name:d.entered.name,to:d.section,from:s(d.entered.startBar),at:d.ms,bar:d.bar,drop:d.entered.drop}));for(const e of d.playing){const t=c.get(e)??[],n=t[t.length-1];n&&Math.abs(n[1]-d.ms)<1?n[1]=u:t.push([d.ms,u]),c.set(e,t)}d.ornament&&i.push({name:d.ornament.name,at:s(d.ornament.bar)}),d.fill&&a.push({kind:d.fill.kind,at:s(d.fill.bar)})});const d=Object.keys(e.parts),h=Object.keys(W(e));return{ms:n,sections:r,transitions:o,lanes:[...c.entries()].map(([t,n])=>({part:t,role:e.parts[t].role,spans:n})).sort((e,t)=>h.indexOf(e.role)-h.indexOf(t.role)||d.indexOf(e.part)-d.indexOf(t.part)),ornaments:i,fills:a,arc:t.map(e=>[e.ms,e.target])}}var it=e=>`${Math.floor(e/6e4)}:${String(Math.floor(e%6e4/1e3)).padStart(2,"0")}`,at=-10,ct=-1,lt=e=>{const t=e.report;return!e.error&&t&&e.recording_id?{lufs:t.loudness.integratedLufs,rmsDb:t.level.rmsDb,peakDb:t.level.peakDb,crestDb:t.level.crestDb,subDb:t.spectrum.bandsDb.sub??NaN,fundDb:t.spectrum.bandsDb.fund??NaN,recordingId:e.recording_id}:{error:e.error??"no take"}},dt=(e,t,n)=>(e+1)*(4*t*60/n+2);var ht=new Map;function ut(e){return ht.get(e)}var mt={kick:36,rim:37,snare:38,clap:39,"hat-closed":42,"hat-open":46,ride:51,perc:63,shaker:82};function pt(e){const t=new Set(e.ev.map(e=>{return"number"==typeof(t=e[1])?t:we(t);var t}));return 1===t.size?[...t][0]:null}function ft(e,t){delete e.parts[t];const n=e=>e?.filter(e=>e!==t),s=e=>{e&&(e.do=e.do.filter(e=>e.roll!==t).map(e=>({...e,...e.mute?{mute:n(e.mute)}:{},...e.solo?{solo:n(e.solo)}:{}})))};for(const r of Object.values(e.sections)){r.layers=n(r.layers),r.guests&&delete r.guests[t];for(const e of r.grow??[])e.add&&(e.add=n(e.add)),e.remove&&(e.remove=n(e.remove))}for(const r of Object.values(e.transitions))r.with&&(r.with=n(r.with)),r.arrival?.add&&(r.arrival.add=n(r.arrival.add)),s(r.gesture),s(r.arrival?.gesture);for(const[r,o]of Object.entries(e.ornaments??{}))s(o),o.do.length||delete e.ornaments[r];for(const r of Object.values(e.fills?.kinds??{}))r.mute&&(r.mute=n(r.mute))}function gt(e,t){const n=z[e];if(!n||!Y(e))return null;const s=X(n.degreePattern).map(e=>e.replace("♭","b").replace("♯","#"));return t%s.length?null:s.flatMap(e=>Array(t/s.length).fill(e)).join(" ")}async function bt(t){const n=await t;return null===Pe&&e(n),n}async function kt(t){const n=await Ie(t.rule_book);if("string"==typeof n&&e(n),"problems"in n)return{rule_book:n.ref,playable:!1,problems:n.problems};const{ref:s,doc:r}=n,o=m(N).run,i=o&&o.ruleBook===s&&o.projection&&(void 0===t.seed||t.seed===o.seed)?o:null,a=i?i.seed:t.seed??m(N).seed??1,c=m(N).choice,l=i?i.minutes??60:t.minutes??c.minutes??60,d={arc:t.arc??c.arc,character:t.character??c.character},h=ot(r,i?i.projection:function(e,t,n,s){const r=new pe(e,t,{...j,minutes:n,...s}),o=[];for(;;){const e=r.next();if(e.ms>=6e4*n)break;o.push(e)}return o}(r,a,l,d),6e4*l);return{rule_book:s,playable:!0,seed:a,minutes:l,arc:i?i.shape.arc:d.arc,character:i?i.shape.character:d.character,...i?{conducted_from_bar:i.conductedFrom}:{},sections:h.sections.map(e=>({name:e.name,fn:e.fn,role:e.role,chapter:e.chapter,bar:e.bar,from:it(e.from),to:it(e.to)})),transitions:h.transitions.map(e=>({name:e.name,to:e.to,at:it(e.at),lead_from:it(e.from),drop:e.drop})),ornaments:h.ornaments.map(e=>({name:e.name,at:it(e.at)})),parts:h.lanes.map(e=>({part:e.part,role:e.role,plays:e.spans.map(([e,t])=>`${it(e)}–${it(t)}`)}))}}function vt(){return[{id:"performer.start",title:"Performer: Start",category:"MIDI",description:"Start the Performer: it plays the project live from a performer document (a .performer asset such as assets/<style>.performer) — sections, transitions, ornaments, chapters, a hand on the knobs — and starts the transport. The same rule book and seed play the same set. Its notes leave the `performer` MIDI source (route it to the instruments like the sequencer, with routing.connect); its knob moves write the live value of the param each knob names, without changing the project. Refuses while another player (a sequencer) plays or an external MIDI clock leads the tempo; a transport running with no player it stops and starts anew. First it starts every instrument of the band that does not run (that can take seconds). An omitted rule_book is the one chosen last (kept with the project); an omitted seed is the fixed one (performer.seed.set) or a new one; an omitted minutes, arc or character is the choice the document view shows (performer.choice.set).",input_schema:{type:"object",properties:{rule_book:{description:'The rule book, as a project asset ref: "asset:assets/<style>.performer".',type:"string"},seed:{description:"The seed. The same seed plays the same set; omit for a new one.",type:"integer",minimum:0},minutes:{description:"Stop by itself after this much music; null plays until stopped. Omit for the choice the document view shows.",type:["number","null"],exclusiveMinimum:0},arc:{description:"The dramaturgy: waves (one main peak at about two thirds, smaller ones before), plateau, slow-burn. Default waves.",type:"string",enum:[...S]},character:{description:"driving lifts the whole arc, deep lowers it; default balanced.",type:"string",enum:[...x]},from_bar:{description:"Begin at this bar instead of the first: the run is played ahead to it in silence, so from there it plays what the whole run plays (performer.plan gives the bars of the sections). The song position begins there too (bar × 16 sixteenths: fwSongPos, [midi:songpos]).",type:"integer",minimum:0,maximum:Ne}},additionalProperties:!1},run:()=>bt(De()),mcpRun:e=>bt(De({fromBar:e.from_bar,ruleBook:e.rule_book||void 0,seed:e.seed,minutes:e.minutes,arc:e.arc,character:e.character}))},{id:"performer.seek",title:"Performer: Jump to a Bar",category:"MIDI",description:"Jump the running run to a bar, forwards or back: it starts again there with the same rule book, seed and shape, played ahead in silence — what the whole run plays at that bar. What was conducted (energy, hold, wishes) is not carried: from the bar on it plays the plan; the song position begins at that bar (bar × 16 sixteenths: fwSongPos, [midi:songpos]). Not playing: performer.start takes from_bar.",input_schema:{type:"object",properties:{bar:{description:"The bar to jump to (performer.plan gives the bars of the sections).",type:"integer",minimum:0,maximum:Ne}},required:["bar"],additionalProperties:!1},mcpRun:t=>bt(async function(t){const n=Pe;return n||e("The Performer is not playing — performer.start takes from_bar to begin at a bar."),Re(n,{ruleBook:n.ruleBook,seed:n.seed,minutes:n.minutes,arc:n.shape.arc,character:n.shape.character,fromBar:t})}(t.bar))},{id:"performer.mix.check",slow:!0,title:"Performer: Mix-Check",category:"AUDIO",description:"How loud each part of the playing run is, in the real run: each part alone from the same bar (a jump, then its solo) recorded for `bars` bars, then all of them — the mix. Per part: integrated loudness (LUFS), rms, peak, crest, the sub and fund bands; the mix also as its distance from the standard (rms −10 dB, peaks −1 dBFS: docs/AUDIO-ANALYSE-WERKZEUGE.md). It SOUNDS: the recorder takes the master after its volume (at 0 it records silence). After it the set goes on from the bar it was at, conducted as it was (energy, hold, mutes, solos — a wish was a moment and is not made again). The Performer must be playing; about (parts + 1) × bars it takes, at most 300 s: by default the parts that play at the bar it measures (now, or `bar`), 4 bars each or fewer to fit; parts or bars asked for that do not fit are refused.",input_schema:{type:"object",properties:{bar:{description:"The bar each take starts at (default: the bar playing now).",type:"integer",minimum:0,maximum:Ne},bars:{description:"Bars per take (default 4, fewer when the takes would pass 300 s).",type:"integer",minimum:1,maximum:16},parts:{description:"These parts (default: the parts that play now — performer.state snapshot.parts and guests; all: run.allParts).",type:"array",items:{type:"string"}}},additionalProperties:!1},mcpRun:t=>async function(t,n){const s=m(N);s.playing&&s.run||e("The Mix-Check measures the playing run — start the Performer first (performer.start).");const r=s.run,o=t.transport.getBpm(),i={bar:Math.floor(r.snapshot.bar),...r.snapshot.conducting,muted:[...r.snapshot.conducting.muted],soloed:[...r.snapshot.conducting.soloed]},a=n.bar??i.bar,c=[];let l={error:"not measured"},d=n.bars??1,h=!1,u=!1;const p=async()=>{u||await t.actions.runMcp("performer.seek",{bar:a}),h=!0,u=!1};try{void 0===n.bar||n.parts?.length||(await t.actions.runMcp("performer.seek",{bar:a}),h=u=!0);const s=m(N).run?.snapshot??r.snapshot,i=[...new Set([...s.parts,...s.guests])],f=n.parts?.length?n.parts:i,g=f.filter(e=>!r.allParts.includes(e));g.length&&e(`No part ${g.map(e=>`"${e}"`).join(", ")} in this rule book — performer.state lists them (run.allParts).`),f.length||e("No part plays now — the Mix-Check measures the parts that play (or name them: parts).");const b=e=>dt(f.length,e,o)<=300;d=n.bars??[4,3,2,1].find(b)??1;const k=dt(f.length,d,o);k>300&&e(`That is about ${Math.round(k)} s of takes — more than the 300 s an action may take. Fewer parts (parts) or bars (bars).`);const v=e=>r.groups.find(t=>t.parts.includes(e))?.file??null,y=async()=>await t.actions.runMcp("analysis.capture",{bars:d});for(const e of f)await p(),await t.actions.runMcp("performer.part.set",{part:e,soloed:!0}),c.push({part:e,instrument:v(e),...lt(await y())});await p();const w=lt(await y());l="error"in w?w:{...w,rmsFromStandardDb:w.rmsDb-at,peakFromStandardDb:w.peakDb-ct}}finally{if(h&&m(N).run){await t.actions.runMcp("performer.seek",{bar:i.bar}),0!==i.energy&&await t.actions.runMcp("performer.energy.set",{value:i.energy}),i.hold&&await t.actions.runMcp("performer.hold.set",{on:!0});for(const e of i.muted)await t.actions.runMcp("performer.part.set",{part:e,muted:!0});for(const e of i.soloed)await t.actions.runMcp("performer.part.set",{part:e,soloed:!0})}}return{bar:a,bars:d,bpm:o,parts:c,mix:l}}(l(),t)},{id:"performer.stop",title:"Performer: Stop",category:"MIDI",description:"Stop the Performer: its notes end, its buttons are released, every param it turned goes back to the project's saved value, every channel gets an All Notes Off. The transport and the instruments keep running (transport.stop stops them).",input_schema:{type:"object",properties:{},additionalProperties:!1},run:()=>Ee(),mcpRun:()=>Ee()},{id:"performer.switch",title:"Performer: Play This One",category:"MIDI",description:"Play this performer document now — what a tile of the Live surface does. Nothing plays: it starts. Another one plays: that run ends and this one starts in its place, at once (a hard switch, not a transition at a phrase end). It plays already: nothing changes. Seed, length and shape are the document's choice (performer.choice.set), as for performer.start. List the documents with project.files.",input_schema:{type:"object",properties:{rule_book:{description:'The rule book, as a project asset ref: "asset:assets/<style>.performer".',type:"string"}},required:["rule_book"],additionalProperties:!1},mcpRun:n=>(t(n.rule_book)&&n.rule_book.endsWith(".performer")||e(`${n.rule_book}: name a performer document of the project (asset:assets/<style>.performer).`),bt(async function(e){const t=Pe;return t&&t.ruleBook===e?`${e} is already playing.`:t?Re(t,{ruleBook:e}):De({ruleBook:e})}(n.rule_book)))},{id:"performer.ready",title:"Performer: Is It Ready?",category:"MIDI",description:"Is this performer document ready to play — every instrument it plays open and RUNNING? One that does not run wakes with its first note: it compiles in the middle of the set and the room hears the gap. Returns { ready, instruments: [{ file, state: running | idle | compiling | error | closed, module_id }] } — what a tile of the Performers surface shows. performer.prepare starts the missing ones.",input_schema:{type:"object",properties:{rule_book:{description:'The rule book, as a project asset ref: "asset:assets/<style>.performer".',type:"string"}},required:["rule_book"],additionalProperties:!1},mcpRun:e=>t(e.rule_book)&&e.rule_book.endsWith(".performer")?We(e.rule_book):`${e.rule_book}: name a performer document of the project (asset:assets/<style>.performer).`},{id:"performer.prepare",title:"Performer: Prepare",category:"MIDI",description:"Start every instrument of this performer document that does not run yet (dsp.run each), so the set plays without a gap — what Prepare on a tile of the Performers surface does. An instrument whose document is not open is named, not opened. Says whether it is ready afterwards.",input_schema:{type:"object",properties:{rule_book:{description:'The rule book, as a project asset ref: "asset:assets/<style>.performer".',type:"string"}},required:["rule_book"],additionalProperties:!1},mcpRun:e=>t(e.rule_book)&&e.rule_book.endsWith(".performer")?Je(e.rule_book):`${e.rule_book}: name a performer document of the project (asset:assets/<style>.performer).`},{id:"performer.state",title:"Performer: Get State",category:"MIDI",description:"What the Performer is doing: playing or not, rule book, seed, whether it starts with Master Play (`follows`), and during a run (`run`) the music time, bar, tempo, chapter, section (its effective energy, bar in section, length, the section that comes next), the parts playing (the section's own and its guests this phrase) and all parts (`allParts`), the moments running (`momentProgress`: how far, 0..1) and all of the rule book (`momentNames`; `momentKinds` — roll, stutter, hole, mute, solo or sweep, by what each does — and `momentBeats`), every knob with its value and current range, the knobs it cannot reach — their instrument is not open, or a modulation drives their param (`blocked`) — the conducting (in the snapshot: energy offset, hold, a pending next or moment, muted and soloed parts, the wishes) and the note-on timing (`notes`: on time / late / dropped). Once conducted, `conducted` and `conductedFrom` in `run` (the bar it left its plan) — the run as it now goes, phrase by phrase, is performer.plan. Also the last error.",input_schema:{type:"object",properties:{},additionalProperties:!1},mcpRun:()=>{const e=m(N);if(!e.run)return e;const{projection:t,...n}=e.run;return{...e,run:{...n,conducted:null!==t}}}},{id:"performer.rulebook.set",title:"Performer: Set Rule Book",category:"MIDI",description:"Choose the performer document the next run plays — a .performer asset of the project (it opens in the workspace as its planned run). List candidates with project.files. Kept with the project.",input_schema:{type:"object",properties:{rule_book:{description:'Project asset ref, e.g. "asset:assets/<style>.performer".',type:"string"}},required:["rule_book"],additionalProperties:!1},mcpRun:n=>(n.rule_book||e("No rule book given."),t(n.rule_book)||e(`"${n.rule_book}" is not a project asset — name it like asset:assets/<style>.performer.`),N.update(e=>({...e,ruleBook:n.rule_book,error:null})),`The next run plays ${n.rule_book}.`)},{id:"performer.transport.follow.set",title:"Performer: Follow Master Play",category:"MIDI",description:"Link or detach the Performer from Master Play — the link switch in a performer document's footer. Linked (the default): Master Play (transport.play) starts the chosen rule book first, then the sequencers that follow. Detached: Master Play leaves it silent; performer.start still starts it. `rule_book` also makes that document the chosen one (as performer.rulebook.set). One flag per project, because one run plays. Under an external MIDI clock Master Play never starts it (the tempo is the clock's).",input_schema:{type:"object",properties:{enabled:{type:"boolean",description:"true = the chosen rule book starts with Master Play."},rule_book:{description:'Optional: make this .performer asset the chosen one, e.g. "asset:assets/<style>.performer".',type:"string"}},required:["enabled"],additionalProperties:!1},mcpRun:e=>function(e,n){if(void 0!==n&&!t(n))return`"${n}" is not a project asset — name it like asset:assets/<style>.performer.`;N.update(t=>({...t,follows:e,...void 0!==n?{ruleBook:n,error:null}:{}}));const s=n??m(N).ruleBook;return e?s?`${s} starts with Master Play.`:"The Performer follows Master Play once a rule book is chosen (performer.rulebook.set).":"The Performer is detached — Master Play leaves it silent; its own Start still plays it."}(e.enabled,e.rule_book||void 0)},{id:"performer.seed.set",title:"Performer: Set Seed",category:"MIDI",description:"Fix the seed of the next run — the same seed plays the same set, for comparing two versions of a sound. `seed` omitted: every run takes a new one. Kept with the project.",input_schema:{type:"object",properties:{seed:{description:"The seed; omit for a new one per run.",type:"integer",minimum:0}},additionalProperties:!1},mcpRun:e=>(N.update(t=>({...t,seed:e.seed??null})),void 0===e.seed?"Every run takes a new seed.":`The next run plays seed ${e.seed}.`)},{id:"performer.choice.set",title:"Performer: Choose Length, Arc and Character",category:"MIDI",description:"Choose what the next run plays, as the selects above a performer document do: its length (minutes; null plays until stopped, drawn an hour ahead), its arc (waves, plateau, slow-burn) and its character (driving, balanced, deep). The document view shows that run at once; a performer.start without them plays it. Not while a run plays — it keeps its own.",input_schema:{type:"object",properties:{minutes:{description:"The length in minutes, or null for until stopped.",type:["number","null"],exclusiveMinimum:0},arc:{description:"The dramaturgy.",type:"string",enum:[...S]},character:{description:"driving lifts the whole arc, deep lowers it.",type:"string",enum:[...x]}},additionalProperties:!1},mcpRun:t=>{m(N).run&&e("A run plays — it keeps its length, arc and character; stop it first."),N.update(e=>({...e,choice:{minutes:void 0!==t.minutes?t.minutes:e.choice.minutes,arc:t.arc??e.choice.arc,character:t.character??e.choice.character}}));const n=m(N).choice;return`The next run: ${null===n.minutes?"until stopped":`${n.minutes} min`}, ${n.arc}, ${n.character}.`}},{id:"performer.labels.set",title:"Performer: Show the Names in the Timeline",category:"MIDI",description:"Write the names of the ways, ornaments and fills into the performer timeline (the view's Labels button) — so one sees which effect comes. Changes only the view.",input_schema:{type:"object",properties:{on:{description:"true writes the names, false leaves the marks bare.",type:"boolean"}},required:["on"],additionalProperties:!1},mcpRun:e=>(N.update(t=>({...t,labels:e.on})),e.on?"The timeline writes the names.":"The timeline shows the marks bare.")},{id:"performer.document.from-genre",title:"Performer: Start a Style from a Genre",category:"MIDI",description:'Write a new performer document from a genre of the music theory — deterministic, no AI. The band comes from `base` (an existing style of the project: its parts and instruments, knobs, sections, transitions, ornaments, hand); the music from the genre: "genre", tempo and chapters, a swing knob on the kit and the bass (the kick straight), scale and progressions (each stretched over the loop, one degree per bar), the genre\'s first grid for each voice on its kit key (kick 36, rim 37, snare 38, clap 39, closed hat 42, open hat 46, ride 51, perc 63 — a conga, shaker 82), its first pump or pulse bass figure, and no breakdown where the genre does without one. Answers what it set and what it left out; refuses to overwrite a file. Then open it, hear it and change it — performer.check reads it against its genre.',input_schema:{type:"object",properties:{genre:{description:"A genreId: club, deep-house, dub-techno, techno, dark-techno.",type:"string"},base:{description:"The style whose band it takes, a project asset ref (asset:assets/<style>.performer).",type:"string"},path:{description:"Where to write it, a new project asset ref (asset:assets/<new style>.performer).",type:"string"}},required:["genre","base","path"],additionalProperties:!1},mcpRun:async s=>{const r=l().files;let o;t(s.path)&&s.path.endsWith(".performer")||e(`${s.path}: name a new project asset ending in .performer (asset:assets/<name>.performer).`);try{o=JSON.parse(await r.readText(s.base))}catch(c){e(`${s.base}: not a readable performer document (${c instanceof Error?c.message:String(c)}).`)}await r.readText(s.path).then(()=>!0,()=>!1)&&e(`${s.path} exists — name a new file.`);const{doc:i,notes:a}=function(e,t,s){const r=V[t];if(!r)return{doc:null,notes:[`no genre "${t}" (${Object.keys(V).join(", ")})`]};const o=JSON.parse(JSON.stringify(e)),i=e=>{const t=e?s[e]:void 0;return t&&"string"!=typeof t?t:null},a=e=>{const t=i(e);return!!t&&null!==t.notes&&10===t.channel},c=[];o.name=r.name,o.genre=r.genreId,o.bpm=r.tempo.default,o.chapters={minutes:r.form.trackMinutes,bpm:[r.tempo.min,r.tempo.max]},c.push(`tempo ${r.tempo.default} BPM, chapters ${r.tempo.min}–${r.tempo.max} BPM every ${r.form.trackMinutes.join("–")} minutes`);const l=new Set;for(const[n,g]of Object.entries(mt)){const e=r.grids.find(e=>e.voice===n),t=Object.entries(o.parts).filter(([,e])=>a(e.instrument)&&pt(e)===g);if(!e||!t.length)continue;const[s,i]=t[0],d=Math.max(...i.ev.map(e=>e[2])),h=new Set(e.quiet??[]);i.ev=e.steps.map(t=>[t,g,h.has(t)?Math.round(.55*d):d,e.gate??1]),i.cycle=16*(e.bars??1),delete i.variants,l.add(s),c.push(`${s} plays "${e.name}" (${e.confidence})`)}const d=Object.entries(o.parts).filter(([e,t])=>a(t.instrument)&&!l.has(e)).map(([e])=>e);for(const n of d)ft(o,n);d.length&&c.push(`${d.join(", ")} left out — ${r.name} has no grid of its own for ${1===d.length?"it":"them"} on the kit`);const h=new Set(Object.entries(mt).filter(([e])=>r.grids.some(t=>t.voice===e)).map(([,e])=>e));for(const[n,g]of Object.entries(o.fills?.kinds??{}))g.notes&&a(g.instrument)&&!g.notes.every(([,e])=>h.has(e))&&(delete o.fills.kinds[n],c.push(`the fill ${n} left out — it strikes kit keys no grid of ${r.name} plays`));const u=[...new Set(r.grids.map(e=>e.voice))].filter(e=>!(e in mt)&&"tom"!==e&&"stab"!==e);u.length&&c.push(`no kit key for ${u.join(", ")} — those grids are left out`);const m=o.harmony&&"tonic"in o.harmony?o.harmony:null,p=Object.entries(o.parts).find(([,e])=>o.roles?.[e.role]?.sub&&null===i(e.instrument)?.notes),f=r.basslines.find(e=>"pump"===e.role||"pulse"===e.role);if(p&&f&&m){const[e,t]=p,n=24+F.indexOf(m.written??m.tonic),s=Math.max(...t.ev.map(e=>e[2]));t.ev=f.notes.map(([e,t,r])=>[e,n+t,s,r]),t.cycle=16*f.bars,delete t.variants,c.push(`${e} plays "${f.name}" (${f.confidence})`)}if(m){const e=o.loopSteps/16,t=[];for(const n of r.harmony.progressions){const s=gt(n,e);s?t.push(s):c.push(`${n} left out — it does not divide into ${e} bars or is not a row of degrees`)}t.length&&(m.scale=r.harmony.scales[0],m.original=t[0],m.progressions=t,c.push(`harmony ${m.tonic} ${m.scale}, "${m.original}"; chapters may lay ${t.map(e=>`"${e}"`).join(", ")}`))}for(const[n,g]of Object.entries(o.knobs))g.swing&&delete o.knobs[n];if(r.swing.default>50){const e=Object.entries(o.parts).filter(([e,t])=>(a(t.instrument)||e===p?.[0])&&pt(t)!==mt.kick).map(([e])=>e),t=n(r.swing.default);o.knobs.swing={label:"swing",swing:e,home:t,range:[t,t],hand:!1},c.push(`swing ${r.swing.default} % on ${e.join(", ")}`)}else c.push("straight — no swing");if(null===r.form.breakdownBars){const e=Object.entries(o.sections).filter(([,e])=>"breakdown"===e.fn).map(([e])=>e);if(e.length){const t=new Set([...e,"breakdown"]);for(const n of e)delete o.sections[n];for(const n of Object.values(o.sections))for(const t of e)delete n.next[t];for(const[e,n]of Object.entries(o.transitions))n.from=n.from.filter(e=>!t.has(e)),n.to=n.to.filter(e=>!t.has(e)),n.from.length&&n.to.length||delete o.transitions[e];for(const e of Object.values(o.parts))e.variants&&(e.variants.sections=e.variants.sections.filter(e=>!t.has(e)),e.variants.sections.length||delete e.variants);for(const[e,n]of Object.entries(o.ornaments??{}))n.in=n.in.filter(e=>!t.has(e)),n.in.length||delete o.ornaments[e];c.push(`${e.join(", ")} left out — ${r.name} does without a breakdown`)}}return{doc:o,notes:c}}(o,s.genre,await oe(o,e=>r.readText(e),te(l().extensions.listTabKinds())));return i||e(a.join("; ")),await r.writeText(s.path,`${function(e){const t=String.raw`-?[\d.]+|"[^"\n]*"|true|false|null`,n=new RegExp(String.raw`\[\s*((?:${t})(?:,\s*(?:${t}))*)\s*\]`,"g");return JSON.stringify(e,null,2).replace(n,(e,t)=>`[${t.split(/,\s*/).join(", ")}]`)}(i)}\n`),{path:s.path,genre:s.genre,base:s.base,notes:a}}},{id:"performer.document.edit",title:"Performer: Edit the Document",category:"MIDI",description:"Switch an open performer document to edit — its JSON source in the code editor (the view's Edit button). editor.source.get/set read and write it; performer.document.compile brings it back to ready.",input_schema:{type:"object",properties:{module_id:{description:"The open performer document (documents.list).",type:"string"}},required:["module_id"],additionalProperties:!1},mcpRun:e=>ut(e.module_id)?.edit()??`No open performer document ${e.module_id}.`},{id:"performer.document.compile",title:"Performer: Compile the Document",category:"MIDI",description:"Save an open performer document and check it (the view's Compile button): a playable one goes to ready and shows its run; one that cannot be played stays in edit — the answer names its problems.",input_schema:{type:"object",properties:{module_id:{description:"The open performer document (documents.list).",type:"string"}},required:["module_id"],additionalProperties:!1},mcpRun:async e=>await(ut(e.module_id)?.compile())??`No open performer document ${e.module_id}.`},{id:"performer.plan",title:"Performer: Show the Planned Run",category:"MIDI",description:"What a performer document will play, laid out without playing it — the timeline the document view draws: sections (name, function, from–to), the transitions between them (name, the change, where its lead begins, drop), the ornaments, and per part when it plays. The same seed gives the same run. While this document plays and has been conducted (energy, hold, next, a wish), it reads that run as it really goes — the phrases played, then what the planner now plans (energy as set, wishes fading, a hold kept one phrase past the planned end of its section) — with `conducted_from_bar`, the bar it left the plan. Plays nothing.",input_schema:{type:"object",properties:{rule_book:{description:"Project asset ref; omit for the one chosen (performer.state).",type:"string"},seed:{description:"The run to lay out; omit for the fixed seed (performer.seed.set) or 1.",type:"integer",minimum:0},minutes:{description:"Music time to lay out, default 60.",type:"number",exclusiveMinimum:0,maximum:240},arc:{description:"The dramaturgy: waves (one main peak at about two thirds, smaller ones before), plateau, slow-burn. Default waves.",type:"string",enum:[...S]},character:{description:"driving lifts the whole arc, deep lowers it; default balanced.",type:"string",enum:[...x]}},additionalProperties:!1},mcpRun:e=>kt(e)},{id:"performer.check",title:"Performer: Check (Compile)",category:"MIDI",description:'Compile a performer document — what its edit view shows as errors and warnings, read without listening; use it after every change you make to one. What it cannot keep (a growth longer than its section, a transition with two silences or a lead the planner never starts, a lead and an arrival fighting over a knob, a change without a transition) makes it unplayable: `playable: false` and the `problems` as sentences. A playable one is played `minutes` ahead in silence and read — the warnings: `run` lists R3 three or more layers entering at once outside a drop, R4 more than one silence around a section change, R5 more than two gestures on one change, R7 a solo ending with many layers back at once, R8 the same way into a section three times in a row, R9 high sections falling straight into rest, R11 low parts playing together, R12 a riff or a voice with the same notes for 32 bars, R13 a part that carries the flow (`flow: true`, e.g. the riff and the bass) silenced anywhere but the last bar of a phrase, R14 phrases without any atmosphere — each a sentence with bar and music time; genre: where the style leaves the genre it names ("genre": its tempo, swing, scale, progressions, a breakdown the genre does without — a hint, never a refusal); blocked: a knob or button whose param a modulation of the project drives (the hand leaves it alone — take the knob out or the modulation; no bar, no time); `counts` per rule. Plays nothing, changes nothing; the same seed gives the same findings.',input_schema:{type:"object",properties:{rule_book:{description:"Project asset ref; omit for the one chosen (performer.state).",type:"string"},seed:{description:"The run to read; omit for the fixed seed (performer.seed.set) or 1.",type:"integer",minimum:0},minutes:{description:"Music time to play ahead, default 60.",type:"number",exclusiveMinimum:0,maximum:240},arc:{description:"The dramaturgy: waves (one main peak at about two thirds, smaller ones before), plateau, slow-burn. Default waves.",type:"string",enum:[...S]},character:{description:"driving lifts the whole arc, deep lowers it; default balanced.",type:"string",enum:[...x]},rules:{description:'Only these rules, e.g. ["R3","R6"].',type:"array",items:{type:"string"}}},additionalProperties:!1},mcpRun:t=>async function(t){const n=await Ie(t.rule_book);if("string"==typeof n&&e(n),"problems"in n)return{rule_book:n.ref,playable:!1,problems:n.problems};const{ref:s,doc:r}=n,{seed:o,choice:i}=m(N),a=t.seed??o??1,c=t.minutes??i.minutes??60,l=(d=[...(h=r,Object.entries({...h.knobs,...h.buttons}).filter(([,e])=>{const t=e.param?He(e):void 0;return void 0!==t&&Le(t,e.param)}).map(([e])=>e)).map(e=>{const t=r.knobs[e]??r.buttons[e];return{rule:"blocked",text:`"${e}": a modulation drives ${t.param} on ${t.instrument??t.master} — the hand cannot turn it`}}),...(await rt(r,a,c,{arc:t.arc??i.arc,character:t.character??i.character})).findings],t.rules?.length?d.filter(e=>t.rules.includes(e.rule)):d);var d,h;const u={};for(const e of l)u[e.rule]=(u[e.rule]??0)+1;return{rule_book:s,playable:!0,seed:a,minutes:c,counts:u,run:l}}(t)}]}var yt=new Set(["performer.start","performer.stop","performer.state","performer.seek","performer.switch","performer.ready","performer.prepare"]);function wt(e){c(e);const t=e.extensions.registerDocumentKind(D),n=function(e){const t=()=>{const t=m(N).run?.ruleBook??null;for(const n of e.documents.listModules()){if("performer"!==n.type)continue;const s=null!==n.filePath&&n.filePath===t?"running":"idle";n.runStatus!==s&&e.documents.updateModuleMeta(n.id,{runStatus:s})}},n=N.subscribe(t),s=e.documents.subscribeModules(t);return()=>{n(),s()}}(e),s=w(),r=Ze();for(const a of[{id:"performer.energy.set",title:"Performer: Set Energy",category:"MIDI",description:"Conduct the energy: -1 (calm) .. 0 (as the rule book says) .. +1 (all in). From the next bar it moves how far the hand opens the knobs, whether fills come, how sparse the parts play, and which section comes next (leaning to more or less energy). Stays until set again.",input_schema:{type:"object",properties:{value:{description:"The energy offset, -1..1.",type:"number",minimum:-1,maximum:1}},required:["value"],additionalProperties:!1},mcpRun:e=>ze({kind:"energy",value:e.value})},{id:"performer.hold.set",title:"Performer: Hold the Section",category:"MIDI",description:"Conduct the form: `on: true` keeps the current section going — it grows phrase by phrase until let go; `on: false` lets it end as planned.",input_schema:{type:"object",properties:{on:{description:"Hold (true) or let go (false).",type:"boolean"}},required:["on"],additionalProperties:!1},mcpRun:e=>ze({kind:"hold",on:e.on})},{id:"performer.next",title:"Performer: Next Section",category:"MIDI",description:"Conduct the form: the current section ends with the phrase it is in, and the next one begins.",input_schema:{type:"object",properties:{},additionalProperties:!1},run:()=>ze({kind:"next"}),mcpRun:()=>ze({kind:"next"})},{id:"performer.moment",title:"Performer: Call a Moment",category:"MIDI",description:"Conduct a moment of the rule book — a drop, build, pause, stutter … — on the next bar. performer.state lists the names (run.momentNames).",input_schema:{type:"object",properties:{name:{description:"The moment's name in the rule book.",type:"string"}},required:["name"],additionalProperties:!1},mcpRun:e=>ze({kind:"moment",name:e.name})},{id:"performer.part.set",title:"Performer: Mute / Solo a Part",category:"MIDI",description:"Conduct the parts: mute one, or solo it (then only soloed parts sound). The run's draws go on as before — only the sound is left out — so unmuting brings the part back exactly where it would be.",input_schema:{type:"object",properties:{part:{description:"The part name, as performer.state lists it (run.allParts).",type:"string"},muted:{description:"Mute (true) or unmute (false).",type:"boolean"},soloed:{description:"Solo (true) or unsolo (false).",type:"boolean"}},required:["part"],additionalProperties:!1},mcpRun:e=>ze({kind:"part",part:e.part,muted:e.muted,soloed:e.soloed})},{id:"performer.wish",title:"Performer: Wish",category:"MIDI",description:"Wish something of a playing run — like someone in the crowd, not like the conductor: more (more pressure), less (calmer), breathe (a rest soon), build (towards a peak). A wish has a weight (default 1) that fades over a few phrases; asked again, it adds up. It only tilts the choice of the next section among what the document and the arc allow — it never forces a change or breaks a rule. performer.state (snapshot.wishes) says what became of each: noted, honoured (and how), outweighed, faded.",input_schema:{type:"object",properties:{kind:{description:"more, less, breathe or build.",type:"string",enum:[...le]},weight:{description:"How much, 0..1; default 1.",type:"number",minimum:0,maximum:1}},required:["kind"],additionalProperties:!1},mcpRun:e=>ze({kind:"wish",wish:e.kind,weight:e.weight})},...vt().filter(e=>yt.has(e.id))])e.actions.register(a);const o=e.project.registerSection(M),i=e.project.registerSection(T);return()=>{o(),i(),s(),r(),n(),t()}}export{wt as activateMidiSourcesRuntime};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./StageView-_SwGWnwx.js","./disclose-version-BvIhFN19.js","./fileMirror-CkgB9zNS.js","./paths-DFjX1bFA.js","./fileRef-BmnWhXuY.js","./client-DksDHYQL.js","./src-DyDfRe65.js","./kit--nsV_OZy.js","./kit-vVQ5cDnW.css","./sun-Bi-OgPry.js","./codeEditorBridge-Bl202hrO.js","./runtime-7lvdeERt.js","./errors-BdUU2zPt.js","./dist-DfaMbR-1.js","./dist-BvRk9kiK.js","./scale-D2nqiPek.js","./StageView-CSu--ASd.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./errors-BdUU2zPt.js";import{s as t}from"./paths-DFjX1bFA.js";import{A as s,B as o,D as i,E as n,F as a,G as r,H as d,I as l,L as p,N as c,O as h,P as u,R as m,U as g,V as y,W as w,_ as f,d as v,h as k,k as b,l as $,m as j,n as _,o as x,q as P,r as I,s as T,u as S,w as M,x as D,z as A}from"./runtime-7lvdeERt.js";import{t as q}from"./lazy-ClEpU-Ev.js";import{t as R}from"./preload-helper-9MKZsTCd.js";import{a as O}from"./src-DyDfRe65.js";var F={id:"stage",label:"Stage",icon:"Sun",description:"A stage document: a scene driven by the music — its lights, a 3D world — and where they hang — every channel a param the Performer, a modulation or a controller turns.",fileExtensions:[".stage"],shows:{extensions:[".world"],documentOf:e=>async function(e,t,s){const o=e.documents.listModules().filter(e=>"stage"===e.type&&e.filePath),i=o.find(e=>s(e.id)?.src===t);if(i)return i.filePath;const n=new Set(o.filter(e=>s(e.id)).map(e=>e.filePath));for(const a of(await e.project.listAssets(".stage")).map(e=>e.ref).filter(e=>!n.has(e)))try{if(JSON.parse(await e.files.readText(a)).elements?.some(e=>"world"===e.type&&e.src===t))return a}catch{}return null}(r(),e,h)},pluginPageFor:e=>function(e){const t=e.replace(/^.*\//,"").replace(/\.[^.]+$/,"");return{world:`asset:assets/${t}-device.world`,stage:`asset:assets/${t}-device.stage`}}(e).stage,playable:!0,viewForPlayer:({world:e,...t})=>t,createRuntime:e=>_(e),viewport:q(()=>R(()=>import("./StageView-_SwGWnwx.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]),import.meta.url))},L={description:'The stage document — omit for the open one (documents.list { type: "stage" }).',type:"string"},E="No stage document is open — open a .stage of the project (documents.add { ref }).";function N(e){return e||O(I)}var W=new Map;function B(e){const t=M(e),s=t?O(t).doc:null;return{controls:s?.controls??{},steered:A(s?.elements??[])}}function C(t,s,i,n){const{controls:a,steered:r}=B(t),d=a[s];if(d||e(`No control "${s}" on the stage — it has ${Object.keys(a).join(", ")||"none"} (stage.control.list).`),"look"===d.kind&&e(`"${s}" is a look — stage.control.look { dx, dy } moves it.`),"menu"===d.kind)return n?$(t):`${s} let go.`;"stick"!==d.kind||i&&u.includes(i)&&d.inputs[i]||e(`"${s}" is a stick — press one of its parts: ${u.filter(e=>d.inputs[e]).join(", ")}.`);const l=o(d,"stick"===d.kind?i:void 0,r),p="stick"===d.kind?`${s}.${i}`:s,c=W.get(t)??new Set;if(W.set(t,c),"hit"===d.kind)return n?(x(t,l.element,l.input)||e("That stage is not open in a view — open it (documents.add { ref }) to play it."),`${s}: ${l.element}.${l.input} fired.`):`${s} let go.`;if(n?c.add(p):c.delete(p),!x(t,l.element,l.input,n?1:0)){if(!n)return`${p} let go — its stage is no longer shown.`;e("That stage is not open in a view — open it (documents.add { ref }) to play it.")}return`${p}: ${l.element}.${l.input} ${n?"held":"let go"}.`}function G(){return[{id:"stage.control.list",title:"Stage: List Controls",category:"MIDI",description:'The stage\'s controls ("controls" in the .stage): each with its kind (stick, hit, hold, look), the world inputs it moves, its keys, mouse and MIDI notes — and what is held down now. A player steers the world through them: the keys and the mouse (while the pointer is locked on the stage — a click locks it, Esc lets go) run stage.control.press / release / look.',input_schema:{type:"object",properties:{module_id:L},additionalProperties:!1},mcpRun:t=>{const s=N(t.module_id);return s?function(e){const{controls:t}=B(e),s=Object.keys(t);if(!s.length)return'The stage has no controls ("controls" in the .stage: stick, hit, hold, look).';const o=[...W.get(e)??[]];return[...s.map(e=>l(e,t[e])),o.length?`held now: ${o.join(", ")}`:"nothing held now"].join("\n")}(s):e(E)}},{id:"stage.control.press",title:"Stage: Press a Control",category:"MIDI",description:"Press a control of the stage, as its key does: a hit fires its event input (jump, fire, enter …), a hold holds its input until stage.control.release, a stick holds its part (left, right, up, down) until released. Press and release in two calls — a held part keeps the player going.",input_schema:{type:"object",properties:{control:{description:"The control (stage.control.list names them).",type:"string",minLength:1},part:{description:"A stick's part: left, right, up or down.",type:"string",enum:[...u]},module_id:L},required:["control"],additionalProperties:!1},mcpRun:t=>{const s=N(t.module_id);return s?C(s,t.control,t.part||void 0,!0):e(E)}},{id:"stage.control.release",title:"Stage: Release a Control",category:"MIDI",description:"Let go a control of the stage (a hold, a stick's part) pressed by stage.control.press — as its key comes up. A hit has nothing to let go.",input_schema:{type:"object",properties:{control:{description:"The control.",type:"string",minLength:1},part:{description:"A stick's part: left, right, up or down.",type:"string",enum:[...u]},module_id:L},required:["control"],additionalProperties:!1},mcpRun:t=>{const s=N(t.module_id);return s?C(s,t.control,t.part||void 0,!1):e(E)}},{id:"stage.control.play",title:"Stage: Play a Drive",category:"MIDI",description:'Play a fixed drive on the stage\'s world: its controls pressed and let go (and its look moved) at seconds of the world\'s own physics time (it steps 120 a second) — the world plays each press on the step it falls on, so the same drive is the same path whatever the screen\'s rate or the pipe\'s delay (a test drive; npm run perf:world). Segment marks name its stretches: stage.desk.state\'s cost.drive then tells each segment\'s cost a picture (ms, compute, draw, most, fps, draw calls, triangles, GPU ms where measured) and where the player ended it; done once its last entry is played. E.g. [{ at: 0, segment: "in" }, { at: 0, press: "walk.up" }, { at: 1.5, release: "walk.up" }, { at: 1.6, press: "enter" }, { at: 2, segment: "end" }].',input_schema:{type:"object",properties:{drive:{description:'The entries: { at, press: "<control>[.<part>]" } (a stick\'s part, a hold, a hit), { at, release: … }, { at, look: { dx, dy } } (the look, as the mouse moves it), { at, segment: "<name>" }. It ends with its last entry.',type:"array",items:{type:"object",properties:{at:{description:"Seconds of the world's time from the drive's start.",type:"number",minimum:0},press:{description:'A control pressed: "walk.up" (a stick\'s part), "run" (a hold), "enter" (a hit).',type:"string"},release:{description:"A control let go (a stick's part, a hold).",type:"string"},look:{description:"The stage's look moved as stage.control.look moves it — pixels right (dx) and down (dy): the camera turned and tilted; in a ship its aim (dy -100: the nose ~27° up).",type:"object",properties:{dx:{type:"number"},dy:{type:"number"}},additionalProperties:!1},segment:{description:"A segment begins here (the one before ends).",type:"string"}},required:["at"],additionalProperties:!1},minItems:1},cars:{description:"false: the world's cars not drawn while it plays (they still drive) — what drawing them costs. Default true.",type:"boolean"},module_id:L},required:["drive"],additionalProperties:!1},mcpRun:t=>{const s=N(t.module_id);return s?function(t,s,i=!0){const n=M(t),a=n?O(n).doc:null,r=a?.controls??{},d=A(a?.elements??[]);n&&O(n).world.edit&&e("The world is being edited — it stands; stage.world.edit { on: false } plays it, then the drive."),Array.isArray(s)&&s.length||e('A drive is a list of { at, press | release: "<control>[.<part>]" } and { at, segment: "<name>" }.');const l=[];let c=null;for(const[m,g]of s.entries()){const t=`entry ${m+1}`;"number"==typeof g?.at&&g.at>=0||e(`${t}: "at" is seconds of the world's time from the drive's start, 0 or more.`);const[s,i,n]=[g.press||void 0,g.release||void 0,g.segment||void 0];s&&i&&e(`${t}: a press or a release, not both.`);const a=s??i,h=g.look&&(g.look.dx||g.look.dy)?g.look:void 0;h&&a&&e(`${t}: a press, a release or a look, one of them.`),a||n||h||e(`${t}: { at, press | release: "<control>[.<part>]" }, { at, look: { dx, dy } } or { at, segment: "<name>" }.`);const y={at:g.at,...n?{segment:n}:{}};if(h){const s=Object.keys(r).find(e=>"look"===r[e].kind),o=s?r[s]:void 0;o&&"look"===o.kind||e(`${t}: the stage has no look control to move.`);const i=o.element??d[0];i||e(`${t}: the stage has no world for the look to turn.`),c&&i!==c&&e(`${t}: a drive plays one world (${c}), not ${i} too.`),c=i;const n=p(o,h.dx??0,h.dy??0),a=["turn","tilt"].filter(e=>o.inputs[e]&&n[e]).map(e=>({at:g.at,input:o.inputs[e],value:n[e]}));a.length||e(`${t}: the look control moves neither turn nor tilt.`),l.push({...y,...a[0]},...a.slice(1));continue}if(a){const[n,l]=a.split("."),p=r[n];p||e(`${t}: no control "${n}" on the stage — it has ${Object.keys(r).join(", ")||"none"} (stage.control.list).`),"look"!==p.kind&&"menu"!==p.kind||e(`${t}: "${n}" is a ${p.kind} — a drive presses sticks, holds and hits.`),"stick"!==p.kind||l&&p.inputs[l]||e(`${t}: "${n}" is a stick — name its part: ${u.filter(e=>p.inputs[e]).map(e=>`${n}.${e}`).join(", ")}.`),"hit"===p.kind&&i&&e(`${t}: "${n}" is a hit — it fires as pressed, there is nothing to let go.`);const h=o(p,"stick"===p.kind?l:void 0,d);h||e(`${t}: the stage has no world for "${n}" to steer.`),c&&h.element!==c&&e(`${t}: a drive plays one world (${c}), not ${h.element} too.`),c=h.element,Object.assign(y,{input:h.input},"hit"===p.kind?{}:{value:s?1:0})}l.push(y)}c||e("A drive presses at least one control of a world."),v(t,c,l,i)||e("That stage is not open in a view — open it (documents.add { ref }) to play it.");const h=Math.max(...l.map(e=>e.at));return`${c} plays a drive of ${l.length} entries, ${h.toFixed(2)} s of its physics time${i?"":", its cars not drawn"} — stage.desk.state's cost.drive tells each segment's cost and where it ended (done once played).`}(s,t.drive,t.cars??!0):e(E)}},{id:"stage.pause",title:"Stage: Pause / Play On",category:"MIDI",description:"Pause the stage's world — its physics, its figures and its mission's time stand, the music plays on — and lay its pause menu over the picture (Resume, Start/Restart the mission when it has missions, Fullscreen, the volume, and what another extension adds with stage.overlay.set), or play it on (on: false); without on it turns over. A player opens it with the stage's menu control (\"kind\": \"menu\", Esc as a rule) or by letting the pointer lock go (Esc while the mouse looks); the menu's buttons run stage.pause, stage.mission.start and master.volume.set.",input_schema:{type:"object",properties:{on:{description:"true pauses, false plays on — omit to turn it over.",type:"boolean"},module_id:L},additionalProperties:!1},run:()=>{const t=N();return t?$(t):e(E)},mcpRun:t=>{const s=N(t.module_id);return s?$(s,t.on):e(E)}},{id:"stage.restart",title:"Stage: From Its Start",category:"MIDI",description:"The stage from its start: its world made anew — the player at `spawn` (a mark of its world) or where the .world puts it, the cars and targets where they stand —, playing (not paused), every value at the start.",input_schema:{type:"object",properties:{module_id:L,spawn:{description:"A mark of its world the player starts at; omit for where the .world puts it.",type:"string"}},additionalProperties:!1},mcpRun:t=>{const s=N(t.module_id);return s||e(E),j(s,t.spawn||null)||e("That stage is not open — open it (documents.add { ref })."),`The stage starts anew${t.spawn?` — the player at the mark ${t.spawn}`:""}.`}},{id:"stage.overlay.set",title:"Stage: Overlay",category:"MIDI",description:"Lay something over a stage's picture, or take it away (overlay null): a cover while something loads (its text), a notice, a panel (a title, lines, entries — each runs an action) and entries of its pause menu. The stage draws it and does not know whose it is — a game shows its loading, its results and its way back to its menu so.",input_schema:{type:"object",properties:{module_id:L,overlay:{description:"What lies over it: { cover?: text, notice?: { id, text }, panel?: { title, lines, entries, testid? }, menu?: entries } — each entry { label, testid, action, input?, playsOn? }; null takes it away.",type:["object","null"]}},required:["overlay"],additionalProperties:!1},mcpRun:t=>{const s=N(t.module_id);return s||e(E),k(s,t.overlay??null),t.overlay?"Laid over the stage.":"Nothing over the stage."}},{id:"stage.control.look",title:"Stage: Look",category:"MIDI",description:"Move the stage's look control as the mouse does while the pointer is locked on the stage: dx pixels to the right turns the view right (its speed: degrees a pixel, 0.15), dy pixels down tilts it down — the world's camera follows at once. E.g. dx 600 is a quarter turn.",input_schema:{type:"object",properties:{dx:{description:"Pixels to the right (left: negative).",type:"number"},dy:{description:"Pixels down (up: negative).",type:"number"},control:{description:"The look control — omit for the stage's first.",type:"string"},module_id:L},additionalProperties:!1},mcpRun:t=>{const s=N(t.module_id);return s?function(t,s,o,i){const{controls:n,steered:a}=B(t),r=s||Object.keys(n).find(e=>"look"===n[e].kind),d=r?n[r]:void 0;r&&d&&"look"===d.kind||e(`No look control "${s??""}" on the stage — it has ${Object.keys(n).join(", ")||"none"} (stage.control.list).`);const l=d.element??a[0],c=p(d,o,i);for(const p of["turn","tilt"])d.inputs[p]&&c[p]&&!x(t,l,d.inputs[p],void 0,c[p])&&e("That stage is not open in a view — open it (documents.add { ref }) to play it.");return`${r}: turned ${c.turn.toFixed(1)}°, tilted ${c.tilt.toFixed(1)}°.`}(s,t.control||void 0,t.dx??0,t.dy??0):e(E)}}]}var H="That stage is not open in a view — open it (documents.add { ref }) to play it.";function U(e){const t=null!==e.left?`, ${e.left.toFixed(1)} s left`:"";return"plays"===e.phase?`mission ${e.name} plays: objective ${e.objective+1} of ${e.of} — ${e.say}${e.progress?` (${e.progress})`:""}${null!==e.distance?`, ${e.mark} ${Math.round(e.distance)} m away`:""}${t}, ${e.took.toFixed(1)} s in`:`mission ${e.name} ${"won"===e.phase?`won in ${e.took.toFixed(1)} s`:"lost"===e.phase?`lost — ${e.why} (${e.took.toFixed(1)} s)`:`stopped after ${e.took.toFixed(1)} s`}`}function V(t){const s=N(t),o=s?M(s):null;s&&o||e(E);const i=h(s);return i||e('The stage has no world ("type": "world" in its elements) — a mission plays on one.'),O(o).world.edit&&e("The world is being edited — it stands; stage.world.edit { on: false } plays it, then the mission."),{id:s,element:i.name,src:i.src}}async function z(t){const s=V(t.module_id),o=O(M(s.id)).doc?.missions??[];o.length||e('The stage has no missions ("missions" in the .stage — stage:missions in the knowledge base).');const i=t.mission||o[0].name,n=o.find(e=>e.name===i);n||e(`No mission "${i}" — the stage has ${o.map(e=>e.name).join(", ")}.`);const{world:a,problems:l}=d(await r().files.readText(s.src));if(!a)return`${s.src}: ${l.join("; ")}.`;const p=c(n,a);if(p.length)return`${p.join("; ")} — fix the .stage or the .world.`;const h=T(s.id,s.element,{start:i});h||e(H);const u=await h;return u||e(H),u.problem?`It did not begin: ${u.problem}.`:`${u.state?U(u.state):`mission ${i} begun`} — stage.mission.state follows it; the HUD shows it over the picture.`}async function J(t){const s=V(t.module_id),o=await T(s.id,s.element,{stop:!0});return o||e(H),o.problem?`Nothing stopped: ${o.problem}.`:o.state?`${U(o.state)}.`:"Stopped."}var K='The stage has no world ("type": "world" in its elements, stage:element:world).';function Y(e,s){const o=O(M(e)).doc?.knobs?.[s];if(!o)return null;const i=r(),n=i.documents.listModules().find(e=>t(e.filePath,o.doc));return n&&i.params.list(n.id).some(e=>e.path===o.param)?{patch:n.id,path:o.param}:null}function Q(){return[{id:"stage.world.grab",title:"Stage: Grab in the World",category:"MIDI",description:'A press on the picture of a world being PLAYED, at x, y (shares of the picture across and down, 0..1): a button there (a model whose "press" in the .world says it: preset-next / preset-prev) is pressed — the patch the knobs of the stage turn loads its next or previous preset (dsp.preset.load); else the thing to grab there — a model whose "grab" in the .world names a scene quantity of the stage — with that quantity and where it stands. Then stage.world.drag moves it. The knob of a patch\'s param (the .stage\'s knobs) is held while grabbed — players that turn params leave it alone, an exported plugin\'s host hears a gesture begin — until stage.world.release lets it go. By name you need no press: stage.world.drag { thing } alone.',input_schema:{type:"object",properties:{module_id:L,x:{description:"Across the picture, 0..1.",type:"number"},y:{description:"Down the picture, 0..1.",type:"number"}},required:["x","y"],additionalProperties:!1},mcpRun:async o=>{const n=N(o.module_id);n&&M(n)||e(E);const a=h(n);a||e(K),(e=>{const t=M(e);return t?O(t).world:null})(n).edit&&e("The world is being edited — stage.world.edit { on: false } to play it.");const d=S(n,a.name,o.x,o.y);d||e("That stage is not open in a view — open it (documents.add { ref }).");const l=(await d)?.thing,p=l?(await b(n))?.get(l):void 0;if(l&&p){const s=D(O(M(n)).doc),o=s?r().documents.listModules().find(e=>t(e.filePath,s)):void 0;o||e(`${l} steps through the presets of the stage's patch — its knobs name ${s??"no one patch"}${s?", which is not open (documents.add { ref })":""}.`);const i=await r().actions.run("dsp.preset.load",{instance_id:o.id,step:"preset-next"===p?1:-1});return`${l} pressed: ${String(i)}`}const c=l?(await i(n))?.get(l):void 0;if(!l||!c)return"Nothing to grab there.";const u=O(M(n)).values[s(c.value)]??0,m=Y(n,c.value);return m&&r().params.hold(m.patch,m.path,!0),{thing:l,value:c.value,at:u,message:`${l} grabbed — a drag writes ${c.value} (now ${u}).`}}},{id:"stage.world.drag",title:"Stage: Drag a Thing of the World",category:"MIDI",description:'Move a grabbed thing of the world played (a model with "grab" in the .world): its scene quantity of the stage is written — by a drag of dy pixels down the screen (up, negative, is more; 200 pixels are its whole range 0..1; fine: a quarter of the way), to a value (to, 0..1), or back to where the stage starts it (reset). What the thing shows of it is its "follows". Written as dsp.param.set writes any param of the stage. A quantity the .stage lists in its "knobs" is the knob of a patch\'s param: the drag writes that param (0..1 laid onto its range; reset: its init) — running or silent, nothing started — and the quantity shows the param, whoever turns it.',input_schema:{type:"object",properties:{module_id:L,thing:{description:"The model's name in the .world (stage.world.grab tells the one under a point).",type:"string"},dy:{description:"A drag: pixels down the screen (negative: up, more).",type:"number"},fine:{description:"With dy: a quarter of the way (the hand holds Shift).",type:"boolean"},to:{description:"Set the quantity, 0..1.",type:"number"},reset:{description:"true: back to where the stage starts it.",type:"boolean"}},required:["thing"],additionalProperties:!1},mcpRun:async o=>{const n=N(o.module_id);n&&M(n)||e(E),h(n)||e(K);const a=await i(n),d=a.get(o.thing);d||e(`"${o.thing}" is not grabbed — its model has no "grab" in the .world (grabbed: ${[...a.keys()].join(", ")||"none"}).`);const l=O(M(n)),p=s(d.value);p in l.values||e(`The stage has no scene quantity "${d.value}" — add it to its "scene".`);const c=l.doc?.knobs?.[d.value],u=r(),m=c?u.documents.listModules().find(e=>t(e.filePath,c.doc)):void 0;c&&!m&&e(`${d.value} is the knob of ${c.doc}, which is not open — open it (documents.add { ref }).`);const v=c&&m?u.params.list(m.id).find(e=>e.path===c.param):void 0;c&&!v&&e(`${c.doc} has no param "${c.param}" (or it is not compiled yet) — dsp.params.list says what it has.`),v?.voiceControlled&&e(`${v.path}: the voices set it with every note — a knob on it would be overwritten; take another param.`);const k=v?g(v,v.init):l.doc?.scene[d.value]??0,b=o.reset?k:"number"==typeof o.to?o.to:"number"==typeof o.dy?y(l.values[p],o.dy,!!o.fine):null;null===b&&e("A drag needs one of dy, to, reset.");const $=Math.round(1e4*Math.min(1,Math.max(0,b)))/1e4;if(v&&m){const e=w(v,$);return await u.actions.run("dsp.param.set",{instance_id:m.id,path:v.path,value:e}),f(n,d.value,$),`${o.thing}: ${v.path} = ${e} (${d.value} = ${$}).`}return await u.actions.run("dsp.param.set",{instance_id:n,path:p,value:$}),`${o.thing}: ${d.value} = ${$}.`}},{id:"stage.world.release",title:"Stage: Let Go in the World",category:"MIDI",description:"Let go of a thing of the world grabbed (stage.world.grab): the knob of a patch's param it held is free again — players may turn it, an exported plugin's host hears the gesture end (one step of its undo). A thing that holds nothing: nothing to let go.",input_schema:{type:"object",properties:{module_id:L,thing:{description:"The model's name in the .world.",type:"string"}},required:["thing"],additionalProperties:!1},mcpRun:async t=>{const s=N(t.module_id);s&&M(s)||e(E),h(s)||e(K);const o=(await i(s))?.get(t.thing),n=o?Y(s,o.value):null;return n&&r().params.held(n.patch,n.path)?(r().params.hold(n.patch,n.path,!1),`${t.thing} let go — ${n.path} is free.`):`${t.thing} holds nothing.`}}]}function X(t){P(t);const s=t.extensions.registerDocumentKind(F),o=n();for(const e of G())t.actions.register(e);for(const n of[{id:"stage.mission.start",title:"Stage: Start a Mission",category:"MIDI",description:"Begin a mission of the stage (its \"missions\": objectives in order on its world's marks — get into a car, reach a mark, hit targets — within a time) where the player is now; one playing is let go. It plays on the world's physics steps; the HUD shows its objective and time over the picture, won or lost a banner; its moments are notes from the stage (sounds: mission, objective, win, lose) and its music's cue dos (the Performer follows). A mission with a start mark also begins as the player walks into it. Omit mission for the stage's first.",input_schema:{type:"object",properties:{mission:{description:"The mission's name — omit for the first.",type:"string"},module_id:L},additionalProperties:!1},run:()=>z({}),mcpRun:z},{id:"stage.mission.stop",title:"Stage: Stop the Mission",category:"MIDI",description:"Stop the mission playing on the stage — neither won nor lost (its music is not told).",input_schema:{type:"object",properties:{module_id:L},additionalProperties:!1},run:()=>J({}),mcpRun:J},{id:"stage.mission.state",title:"Stage: Mission State",category:"MIDI",description:"How the stage's missions stand: each (its title, start mark, time, objectives), the one playing or played last — its phase (plays, won, lost, stopped), objective now, words, seconds taken and left, how far its mark is (metres), how many hit — and the marks the player is in now.",input_schema:{type:"object",properties:{module_id:L},additionalProperties:!1},mcpRun:async t=>{const s=V(t.module_id),o=(O(M(s.id)).doc?.missions??[]).map(e=>({name:e.name,title:e.title,start:e.start,within:e.within,steps:e.steps})),i=await T(s.id,s.element,{});return i||e(H),{module_id:s.id,missions:o,now:i.state,said:i.state?U(i.state):i.problem??"no mission has played yet",inside:i.inside}}}])t.actions.register(n);for(const e of Q())t.actions.register(e);const i=function(){const e=r();let t,s=()=>{},o=()=>{},i=()=>{};const n=(t,i)=>{if(s(),o(),s=()=>{},o=()=>{},!t||!i||!Object.keys(i).length)return;s=e.keys.setDefaults("stage",a(t,i));const n=m(i);n.length&&(o=e.midi.onBusTap(s=>{const[o,i,a]=s.data,r=144==(240&o)&&a>0;if(r||128==(240&o)||144==(240&o)&&!a)for(const d of n)1+(15&o)===d.channel&&d.note===i&&e.actions.run(r?"stage.control.press":"stage.control.release",{module_id:t,control:d.control,...d.part?{part:d.part}:{}})}))},d=I.subscribe(e=>{i(),i=()=>{},t=void 0;const s=e?M(e):null;if(!s)return n(null,void 0);i=s.subscribe(s=>{s.doc?.controls!==t&&(t=s.doc?.controls,n(e,s.doc?.controls))})});return()=>{d(),i(),s(),o()}}();return()=>{s(),o(),i()}}export{X as activateStageRuntime};
|