-
-
Save DGriffin91/7f034100fb4fdea260dcd874f2068d11 to your computer and use it in GitHub Desktop.
Varb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc: Varb 0.1 (DG) | |
slider1:0.5<0.0,1.0>Mix | |
slider2:0.2<0.0,1.0>Delay Size | |
slider4:0.9<0.6,1.5>Delay Delta | |
slider6:0.9<0.0,1.5>Decay Init | |
slider7:1.0<0.5,1.5>Decay Delta | |
slider11:16.0<0.0,64.0,1.0>Iterations | |
slider21:20000.0<1.0,20000.0>LPF Cutoff | |
slider22:0.2<0.04,1.0>LPF Slope | |
slider31:0.0<0.0,1.0>Saturation Mix | |
slider32:0.0<1.0,100.0>Saturation | |
slider60:0.0<-24.0,24.0,0.0001>Reverb Master | |
@init | |
n = 0; | |
comp_prev_l = 0.0; | |
comp_prev_r = 0.0; | |
comp_threshold = 2^(-3.0/6); | |
comp_ratio = 1000.0; | |
comp_attack = 1.0; | |
comp_release = 8.0; | |
comp_cteAT = exp(-2.0 * $PI * 1000.0 / comp_attack / srate); | |
comp_cteRL = exp(-2.0 * $PI * 1000.0 / comp_release / srate); | |
@slider | |
ui_mix=slider1; | |
delay=slider2*srate; | |
delay_delta = slider4; | |
ui_decay=slider6; | |
ui_decay_delta=slider7; | |
iterations=floor(slider11); | |
level=2^(slider11/6); | |
ui_saturate_mix = slider31; | |
ui_saturate = slider32; | |
saturate_delta = slider33; | |
master=2^(slider60/6); | |
damp=0.01+slider22*20; | |
c = 1/tan($pi*slider21/srate); | |
fk = 1 / (1 + c*(c+damp)); | |
fa1 = 2 * (1 - c*c) * fk; | |
fa0 = (1 + c*(c-damp)) * fk; | |
oldamp=damp; | |
@sample | |
function mix(x, y, a) ( | |
x * (1.0 - a) + y * a; | |
); | |
function level_match_atan(x, level) ( | |
atan(x*level)/(((level-1.0)*0.95)+1.0); | |
); | |
function lpf(x, ch, i) ( | |
fd0 = i + ch * 512 + 0; | |
fd1 = i + ch * 512 + 64; | |
fd2 = i + ch * 512 + 128; | |
0[fd0] = (fk*x) - (fa1*0[fd1]) - (fa0*0[fd2]); | |
x = 0[fd0] + 0[fd1] + 0[fd1] + 0[fd2]; | |
0[fd2] = 0[fd1]; | |
0[fd1] = 0[fd0]; | |
x; | |
); | |
//y = spl0 + gain*y1L[(n+delay)%delay]; | |
//y1L[n] = y; | |
//spl0 = y; | |
//y = spl1 + gain*y1R[(n+delay)%delay]; | |
//y1R[n] = y; | |
//spl1 = y; | |
//--------------------REVERB----------------- | |
function line(x, array_start, delay, n, gain) ( | |
current_n = n % delay + array_start; | |
prev_n = (n+delay)%delay + array_start; | |
back = gain*1024[prev_n]; | |
1024[current_n] = x + back; | |
-gain*1024[current_n] + back; | |
); | |
orig_l = spl0; | |
orig_r = spl1; | |
i = 0; | |
pos = 0; | |
current_delay = delay; | |
decay = ui_decay; | |
while( | |
//"current_delay - 10" is to make the 2 l/r differ for stereo image | |
spl0 = line(spl0, pos, current_delay - 10, n, decay); | |
spl1 = line(spl1, pos + current_delay, current_delay, n, decay); | |
sl = level_match_atan(spl0, ui_saturate); | |
sr = level_match_atan(spl1, ui_saturate); | |
spl0 = mix(spl0, sl, min(ui_saturate_mix, 1.0)); | |
spl1 = mix(spl1, sr, min(ui_saturate_mix, 1.0)); | |
spl0 = lpf(spl0, 0, i); | |
spl1 = lpf(spl1, 1, i); | |
decay = decay * ui_decay_delta; | |
decay = decay * ui_decay_delta; | |
pos += current_delay * 2; | |
current_delay = floor(current_delay * delay_delta); | |
i += 1; | |
i < iterations; | |
); | |
// Gain compensate | |
spl0 = spl0 / ui_decay_delta^(iterations*(iterations-2)); | |
spl1 = spl1 / ui_decay_delta^(iterations*(iterations-2)); | |
// Gain compensate | |
spl0 = spl0 / ui_decay^(iterations/1.25); | |
spl1 = spl1 / ui_decay^(iterations/1.25); | |
n += 1; | |
spl0 = spl0 * master; | |
spl1 = spl1 * master; | |
//--------------------COMPRESSON----------------- | |
// Detector (peak) | |
side_input_l = abs(spl0); | |
side_input_r = abs(spl1); | |
cte = side_input_l >= comp_prev_l ? comp_cteAT : comp_cteRL; | |
env = side_input_l + cte * (comp_prev_l - side_input_l); | |
comp_prev_l = env; | |
// Compressor transfer function | |
cv_l = env <= comp_threshold ? 1.0 : pow(env / comp_threshold, 1.0 / comp_ratio - 1.0); | |
cte = side_input_r >= comp_prev_r ? comp_cteAT : comp_cteRL; | |
env = side_input_r + cte * (comp_prev_r - side_input_r); | |
comp_prev_r = env; | |
// Compressor transfer function | |
cv_r = env <= comp_threshold ? 1.0 : pow(env / comp_threshold, 1.0 / comp_ratio - 1.0); | |
//Apply Compression | |
spl0 = spl0 * cv_l; | |
spl1 = spl1 * cv_r; | |
//Soft Clip | |
spl0 = atan(spl0); | |
spl1 = atan(spl1); | |
//LPF after clip | |
spl0 = lpf(spl0, 0, iterations); | |
spl1 = lpf(spl1, 1, iterations); | |
//Mix in original signal | |
spl0 = mix(orig_l, spl0, ui_mix); | |
spl1 = mix(orig_r, spl1, ui_mix); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment