INTERFACE 1200,100
HIDEUI 4
VSTVARS 7
// VSTVAR <number>;<initial value>;"Name";"Unit";<min>;<max>;<scale type>
VSTVAR 0,0.5,"VOLUME","",0,1,1
VSTVAR 1,.1,"ATTACK","s",.001,10,0
VSTVAR 2,.1,"DECAY","s",.001,10,0
VSTVAR 3,1,"SUSTAIN","",0,1,1
VSTVAR 4,10,"RELEASE","s",.01,100,0
VSTVAR 5,0,"DJ_KNOB","",-1,1,1
VSTVAR 6,2,"DRIVE","",.5,5,0

//SAMPLE <slot_number>; <numeric_code>; <2nd_harmonic_numeric_code>; <2nd_harmonic_amplitude>; <2nd_harmonic_frequency>; <2nd_harmonic_phase>; <3rd...
sample 1,2

GAINENV &600,0,&601,0,&602,&603,&604

LAYER
sig=OSCG("Sgfa000",1)
//DJ_KNOB=VAR5
//DRIVE=VAR6

// 1. BIPOLAR PARAMETER MAPPING
// DJ_KNOB: -1.0 (Full LP) -> 0.0 (Bypass) -> +1.0 (Full HP)
Intensity = ABS(VAR5)

// 2. GLOBAL PRE-SATURATION (Calculated once)
// This "thickens" the sound before it hits the filters
SaturatedIn = TANH(sig * (1 + Intensity * VAR6))

// Logarithmic Frequency Scaling (Range: 0.1 to 20.0)
// Ensures the sweep feels "musical" and follows octaves
FcBase = 0.1 * (200 ^ Intensity)

// 3. PARALLEL LINEAR PROCESSING
// We use simple 6dB Linear Filters (FILT6) to keep CPU low.
// Both filters MUST run every sample to maintain phase continuity.
LP_Branch = FILT(-1,SaturatedIn, (20.1 - FcBase)*FREQ,0) // Closes as Intensity increases
HP_Branch = FILT(-2,SaturatedIn, FcBase*FREQ,0)        // Opens as Intensity increases

// 4. THE CROSS-SWITCH (Output Selection)
// Using a small dead-zone (0.02) for a clean center bypass
// Step 4: Logic Switch
IF VAR5 < -0.002 GOTO LOW_PASS
IF VAR5 > 0.002 GOTO HIGH_PASS

// Case: Bypass (Center)
Filtered = sig
IF 1 = 1 GOTO END

LABEL LOW_PASS
Filtered = LP_Branch
IF 1 = 1 GOTO END

LABEL HIGH_PASS
Filtered = HP_Branch

LABEL END
// 5. THE "GREY" ATMOSPHERE
// Reverb3 adds the characteristic "washed-out" club feel
OUT = (1-Intensity*.4)*filtered + Intensity*.4*REVERB(Filtered, 0.98,0.95,5000,1)

