INTERFACE 1000,100
VSTVARS 8
VSTVAR 0, .98, "LPROOMSIZE", "", .8, .9999, 0
VSTVAR 1, .97, "HPROOMSIZE", "", .8, .9999, 0
VSTVAR 2, 200, "F Thres", "Hz", 10, 20000, 0
VSTVAR 3, 50, "Dry/Wet", "%", 0, 100, 1
VSTVAR 5,0,"CHORD","",0,6,4,"Cmaj","Dm","Em","Fmaj","Gmaj","Am","Bdim"
VSTVAR 6, .1, "Volume", "", 0, 1, 1
VSTVAR 7, 0, "Brilliance", "", 0, 1, 1
VSTVAR 127, 0, "", "", 0, 6, 2

// Kirnberger III
TEMPERAMENT 15
// Allow layering
CHOKE 0
// Random seed every time different
SEED -2

// MIDI CC 604
SEQUENCERI "ACTIVATE 604, 10",0,15

// Initialize with a tonic chord. Set MCC727 to 0 (tonic chord) at 3.9 to force the loop to last 4 BARS
SEQUENCERI "MOVE 0,0;ADD 0,36,3.9,30;ADDMCC 3.9,727,0;ADD 0,48,4,30;ADD 0.1,60,3.8,25;ADD 0.1,52,3.8,35;ADD 0.1,55,3.8,25;",0,0

// The program. Step 1: clear the tape and reset the cursor
SEQUENCER "CLEAR;",0,0
// Step 2: series of if - goto to go to the code relative to the current chord
// If it's I, goto to the code for I
SEQUENCER "IF &727=0;GOTO 15;"
// If it's ii, goto to the code for ii
SEQUENCER "IF &727=1;GOTO 34;"
// If it's iii, goto to the code for iii
SEQUENCER "IF &727=2;GOTO 53;"
// If it's IV, goto to the code for IV
SEQUENCER "IF &727=3;GOTO 72;"
// If it's V, goto to the code for V
SEQUENCER "IF &727=4;GOTO 91;"
// If it's vi, goto to the code for vi
SEQUENCER "IF &727=5;GOTO 110;"
// If it's vii°, goto to the code for vii°
SEQUENCER "IF &727=6;GOTO 129;"

// The main switchboard
// We are in the I. 5% to remain in I
SEQUENCER "PROB 5;GOTO 22;" // Slot 15
// We are in the I. 30% to go in IV
SEQUENCER "PROB 40;GOTO 79;"
// We are in the I. 15% to go in vi
SEQUENCER "PROB 32;GOTO 117;"
// We are in the I. 15% to go in V
SEQUENCER "PROB 44;GOTO 98;"
// We are in the I. 10% to go in ii
SEQUENCER "PROB 45;GOTO 41;"
// We are in the I. 10% to go in iii
SEQUENCER "GOTO 60;"
// We are in the I. 5% to go in vii°
SEQUENCER "GOTO 135;"
// We must play chord I
// --- NOTE BASE ---
SEQUENCER "ADDMCC 0,727,0;" // Slot 22
SEQUENCER "ADD 0, 36, 4, 30;",0,0 // Basso Tonica
SEQUENCER "ADDMCC 3.9,727,0;"
SEQUENCER "ADD 0, 48, 4, 30;",0,0 // Ottava
SEQUENCER "ADD 0.1, 60, 3.8, 25; ADD 0.1, 52, 3.8, 55; ADD 0.1, 55, 3.8, 25;",0,0 // Triade
// --- VARIANTI ---
SEQUENCER "PROB 10; ADD 0.3, 64, 3.2, 10;",0,0 // 11
SEQUENCER "PROB 30; ADD 0.4, 59, 3.1, 15;",0,0 // 7+
SEQUENCER "PROB 10; ADD 0.5, 62, 2.5, 10;",0,0 // 9
// --- UMANIZZAZIONE (MOD globale per l'accordo) ---
// Parametri: minbars=0, maxbars=1 (copre tutti i trigger), 
// dtrig(0, 0.2), ddur(-.2, 0), dpitch(0), dvel(-8, 2)
SEQUENCER "MOD 0, 1, 0, 0.2, -.2, 0, 0, 0, -8, 2;"
// Jump to end
SEQUENCER "GOTO 9999;" // Slot 33.


// We are in the ii. 60% to go in V
SEQUENCER "PROB 60;GOTO 98;" // Slot 34
// We are in the ii. 15% to remain in ii
SEQUENCER "PROB 5;GOTO 41;"
// We are in the ii. 10% to go in IV
SEQUENCER "PROB 35;GOTO 79;"
// We are in the ii. 10% to go in vi
SEQUENCER "PROB 50;GOTO 117;"
// We are in the ii. 5% to go in I
SEQUENCER "PROB 60;GOTO 22;"
// We are in the ii. 5% to go in iii
SEQUENCER "GOTO 60;"
// We are in the ii. 5% to go in vii°
SEQUENCER "GOTO 135;"
// We must play chord ii
// --- NOTE BASE ---
SEQUENCER "ADDMCC 0,727,1;" // Slot 41
SEQUENCER "ADD 0, 38, 4, 45;",0,0 // Basso Tonica
SEQUENCER "ADDMCC 3.9,727,1;"
SEQUENCER "ADD 0, 50, 4, 45;",0,0 // Ottava
SEQUENCER "ADD 0.1, 62, 3.8, 25; ADD 0.1, 53, 3.8, 55; ADD 0.1, 57, 3.8, 30;",0,0 // Triade
// --- VARIANTI ---
SEQUENCER "PROB 20; ADD 0.3, 55, 3.2, 10;",0,0 // 4
SEQUENCER "PROB 40; ADD 0.4, 60, 3.1, 10;",0,0 // 7
SEQUENCER "PROB 20; ADD 0.5, 64, 2.5, 10;",0,0 // 9
// --- UMANIZZAZIONE (MOD globale per l'accordo) ---
// Parametri: minbars=0, maxbars=1 (copre tutti i trigger), 
// dtrig(0, 0.2), ddur(-.2, 0), dpitch(0), dvel(-8, 2)
SEQUENCER "MOD 0, 1, 0, 0.2, -.2, 0, 0, 0, -8, 2;"
// Jump to end
SEQUENCER "GOTO 9999;" // Slot 52.


// We are in the iii. 65% to go in vi
SEQUENCER "PROB 65;GOTO 117;" // Slot 53
// We are in the iii. 15% to go in IV
SEQUENCER "PROB 45;GOTO 79;"
// We are in the iii. 10% to remain in iii
SEQUENCER "PROB 5;GOTO 60;"
// We are in the iii. 10% to go in I
SEQUENCER "PROB 40;GOTO 22;"
// We are in the iii. 10% to go in ii
SEQUENCER "PROB 40;GOTO 41;"
// We are in the iii. 10% to go in V
SEQUENCER "GOTO 98;"
// We are in the iii. 5% to go in vii°
SEQUENCER "GOTO 135;"
// We must play chord iii
// --- NOTE BASE ---
SEQUENCER "ADDMCC 0,727,2;" // Slot 60
SEQUENCER "ADD 0, 40, 4, 55;",0,0 // Basso Tonica
SEQUENCER "ADDMCC 3.9,727,2;"
SEQUENCER "ADD 0, 52, 4, 55;",0,0 // Ottava
SEQUENCER "ADD 0.1, 64, 3.8, 25; ADD 0.1, 55, 3.8, 25; ADD 0.1, 59, 3.8, 25;",0,0 // Triade
// --- VARIANTI ---
SEQUENCER "PROB 25; ADD 0.3, 54, 3.2, 15;",0,0 // 9
SEQUENCER "PROB 35; ADD 0.4, 50, 3.1, 15;",0,0 // 7
SEQUENCER "PROB 25; ADD 0.5, 57, 2.5, 15;",0,0 // 11
// --- UMANIZZAZIONE (MOD globale per l'accordo) ---
// Parametri: minbars=0, maxbars=1 (copre tutti i trigger), 
// dtrig(0, 0.2), ddur(-.2, 0), dpitch(0), dvel(-8, 2)
SEQUENCER "MOD 0, 1, 0, 0.2, -.2, 0, 0, 0, -8, 2;"
// Jump to end
SEQUENCER "GOTO 9999;" // Slot 71.


// We are in the IV. 45% to go in I
SEQUENCER "PROB 45;GOTO 22;" // Slot 72
// We are in the IV. 20% to go in V
SEQUENCER "PROB 40;GOTO 98;"
// We are in the IV. 15% to go in ii
SEQUENCER "PROB 30;GOTO 41;"
// We are in the IV. 10% to go in vi
SEQUENCER "PROB 40;GOTO 117;"
// We are in the IV. 10% to remain in IV
SEQUENCER "PROB 5;GOTO 79;"
// We are in the IV. 5% to go in iii
SEQUENCER "GOTO 60;"
// We are in the IV. 5% to go in vii°
SEQUENCER "GOTO 135;"
// We must play chord IV
// --- NOTE BASE ---
SEQUENCER "ADDMCC 0,727,3;" // Slot 79
SEQUENCER "ADD 0, 41, 4, 70;",0,0 // Basso Tonica
SEQUENCER "ADDMCC 3.9,727,3;"
SEQUENCER "ADD 0, 53, 4, 70;",0,0 // Ottava
SEQUENCER "ADD 0.1, 65, 3.8, 25; ADD 0.1, 57, 3.8, 25; ADD 0.1, 60, 3.8, 25;",0,0 // Triade
// --- VARIANTI ---
SEQUENCER "PROB 15; ADD 0.3, 50, 3.2, 10;",0,0   // 6
SEQUENCER "PROB 20; ADD 0.4, 55, 3.1, 10;",0,0   // 9
SEQUENCER "PROB 35; ADD 0.5, 52, 2.5, 15;",0,0   // 7+
// --- UMANIZZAZIONE (MOD globale per l'accordo) ---
// Parametri: minbars=0, maxbars=1 (copre tutti i trigger), 
// dtrig(0, 0.2), ddur(-.2, 0), dpitch(0), dvel(-8, 2)
SEQUENCER "MOD 0, 1, 0, 0.2, -.2, 0, 0, 0, -8, 2;"
// Jump to end
SEQUENCER "GOTO 9999;" // Slot 90.


// We are in the V. 65% to go to I
SEQUENCER "PROB 65;GOTO 22;" // Slot 91
// We are in the V. 15% to go in vi
SEQUENCER "PROB 45;GOTO 117;"
// We are in the V. 10% to go in IV
SEQUENCER "PROB 50;GOTO 79;"
// We are in the V. 5% to remain in V
SEQUENCER "PROB 5;GOTO 98;"
// We are in the V. 5% to go in ii
SEQUENCER "PROB 20;GOTO 41;"
// We are in the V. 3% to go in iii
SEQUENCER "GOTO 60;"
// We are in the V. 2% to go in vii°
SEQUENCER "GOTO 135;"
// We must play chord V
// --- NOTE BASE ---
SEQUENCER "ADDMCC 0,727,4;" // Slot 98
SEQUENCER "ADD 0, 43, 4, 85;",0,0 // Basso Tonica
SEQUENCER "ADDMCC 3.9,727,4;"
SEQUENCER "ADD 0, 55, 4, 65;",0,0 // Ottava
SEQUENCER "ADD 0.1, 67, 3.8, 25; ADD 0.1, 59, 3.8, 25; ADD 0.1, 62, 3.8, 30;",0,0 // Triade
// --- VARIANTI (Estensioni su Sol Maj) ---
SEQUENCER "PROB 30; ADD 0.3, 48, 3.2, 10;",0,0   // 4
SEQUENCER "PROB 35; ADD 0.4, 53, 3.1, 15;",0,0   // 7
SEQUENCER "PROB 20; ADD 0.5, 57, 2.5, 10;",0,0   // 9
// --- UMANIZZAZIONE (MOD globale per l'accordo) ---
// Parametri: minbars=0, maxbars=1 (copre tutti i trigger), 
// dtrig(0, 0.2), ddur(-.2, 0), dpitch(0), dvel(-8, 2)
SEQUENCER "MOD 0, 1, 0, 0.2, -.2, 0, 0, 0, -8, 2;"
// Jump to end
SEQUENCER "GOTO 9999;" // Slot 109.

// We are in the vi. 40% to go in ii
SEQUENCER "PROB 40;GOTO 41;" // Slot 110
// We are in the vi. 25% to go in IV
SEQUENCER "PROB 40;GOTO 79;"
// We are in the vi. 15% to go to I
SEQUENCER "PROB 40;GOTO 22;"
// We are in the vi. 10% to remain in vi
SEQUENCER "PROB 5;GOTO 117;"
// We are in the vi. 10% to go in V
SEQUENCER "PROB 60;GOTO 98;"
// We are in the vi. 5% to go in iii
SEQUENCER "GOTO 60;"
// We are in the vi. 5% to go in vii°
SEQUENCER "GOTO 135;"
// We must play chord vi
// --- NOTE BASE ---
SEQUENCER "ADDMCC 0,727,5;" // Slot 117
SEQUENCER "ADD 0, 45, 4, 110;",0,0 // Basso Tonica
SEQUENCER "ADDMCC 3.9,727,5;"
SEQUENCER "ADD 0, 57, 4, 40;",0,0 // Ottava
SEQUENCER "ADD 0.1, 69, 3.8, 25; ADD 0.1, 60, 3.8, 20; ADD 0.1, 64, 3.8, 25;",0,0 // Triade
// --- VARIANTI (Estensioni su La min) ---
SEQUENCER "PROB 40; ADD 0.3, 55, 3.2, 10;",0,0 // 7
SEQUENCER "PROB 30; ADD 0.4, 59, 3.1, 10;",0,0 // 9
SEQUENCER "PROB 15; ADD 0.5, 62, 2.5, 10;",0,0 // 11
// --- UMANIZZAZIONE (MOD globale per l'accordo) ---
// Parametri: minbars=0, maxbars=1 (copre tutti i trigger), 
// dtrig(0, 0.2), ddur(-.2, 0), dpitch(0), dvel(-8, 2)
SEQUENCER "MOD 0, 1, 0, 0.2, -.2, 0, 0, 0, -8, 2;"
// Jump to end
SEQUENCER "GOTO 9999;" // Slot 128.


// We are in the vii°. 65% to go to I
SEQUENCER "PROB 65;GOTO 22;" // Slot 129
// We are in the vii°. 35% to go in iii
SEQUENCER "PROB 70;GOTO 60;"
// We are in the vii°. 10% to go in vi
SEQUENCER "PROB 60;GOTO 117;"
// We are in the vii°. 5% to go in V
SEQUENCER "PROB 60;GOTO 98;"
// We are in the vii°. 3% to go in ii
SEQUENCER "PROB 70;GOTO 41;"
// We are in the vii°. 2% to go in IV
SEQUENCER "GOTO 79;"
// We must play chord vii°
// --- NOTE BASE ---
SEQUENCER "ADDMCC 0,727,6;" // Slot 135
SEQUENCER "ADD 0, 47, 4, 110;",0,0 // Basso Tonica
SEQUENCER "ADDMCC 3.9,727,6;"
SEQUENCER "ADD 0, 59, 4, 40;",0,0 // Ottava
SEQUENCER "ADD 0.1, 62, 3.8, 30; ADD 0.1, 53, 3.8, 55; ADD 0.1, 56, 3.8, 60;",0,0 // Triade
// --- VARIANTI (Il tocco Ambient) ---
// Settima diminuita (70 - Bb4): Rende l'accordo più "denso".
SEQUENCER "PROB 30; ADD 0.3, 58, 3.2, 15;",0,0
// NONA (73 - Db5): Questa è la chiave! La nona (Do#) su un Si dim crea un colore incredibile.
SEQUENCER "PROB 60; ADD 0.5, 61, 2.5, 15;",0,0
// --- UMANIZZAZIONE (MOD globale per l'accordo) ---
// Parametri: minbars=0, maxbars=1 (copre tutti i trigger), 
// dtrig(0, 0.2), ddur(-.2, 0), dpitch(0), dvel(-8, 2)
SEQUENCER "MOD 0, 1, 0, 0.2, -.2, 0, 0, 0, -8, 2;"
// Jump to end
SEQUENCER "GOTO 9999;" // Slot 146.
QUALITY 4096, 7, 0, 1, 1, 1, 1, 0
//SAMPLE 1, 0, 0, .3, 2.0035, .25, 0, .1, 2.9948, .5, 0, .35, 4.0070, .75, 0, .25, 4.9914, .125
//SAMPLE 2, 0, 0, .3, 1.9965, .25, 0, .1, 3.0052, .5, 0, .35, 3.9930, .75, 0, .25, 5.0086, .125
//SAMPLE 1, 0, 0, .3, 2.0035, .25, 0, .1, 2.9948, .5, 0, .35, 4.0070, .75
//SAMPLE 2, 0, 0, .3, 1.9965, .25, 0, .1, 3.0052, .5, 0, .35, 3.9930, .75
SAMPLE 1, 0, 5, .3, 2.0035, .25, 5, .1, 2.9948, .5
SAMPLE 2, 0, 5, .3, 1.9965, .25, 5, .1, 3.0052, .5
//SAMPLE 1, 0, 5, .3, 2.0035, .25
//SAMPLE 2, 0, 5, .3, 1.9965, .25

POST
MCC605=MCC727
OUT=.01*((100-MCC603)*OUT+MCC603*WIDE(REVERB3(OUT,MCC600,MCC601,MCC602,1,120,12,40,4,.618),2))

LAYER
// Brilliance
B=((.02*KEYF)^5)-1
// Release
REL=5-.04*ONVEL
// Attack
ATK=REL*2
// Filter frequency envelope
E=2*ENV0(2*ATK,0,1,1000)
F=FREQ*(1+E)
// Filter resonance envelope
R=E*.4

// (1+Brilliance)*volume*LP(pan(osc1)+pan(osc2),Fc,Reso)
OUT=(1+MCC607*B)*MCC606*FILT(0,PAN(OSCG("MgfA00L",1, ATK, REL),-70)+PAN(OSCG("MgfA00L",2, ATK, REL),70),F,R)


