Old 07-29-2018, 05:54 AM   #1
solarfall
Human being with feelings
 
Join Date: Sep 2013
Posts: 74
Default New Jsfx: AnalogSum

Hi folks.
Here's my first attempt at emulating an analog summing device. Give it a try: put it on every track (not busses or masters) and let me know if you like it. Suggestions are welcome. Thanks

Giovanni
Attached Files
File Type: txt AnalogSum.txt (1.4 KB, 338 views)
solarfall is offline   Reply With Quote
Old 07-29-2018, 07:16 AM   #2
bezusheist
Human being with feelings
 
bezusheist's Avatar
 
Join Date: Nov 2010
Location: Mullet
Posts: 829
Default

have you plotted this ?
i wouldn't double the input gain...as is, you need to limit to -6 dBFS +/- or it starts to fold over / fall apart.
didn't check it out too much yet but that caught my eye right away...
__________________
I like turtles
bezusheist is offline   Reply With Quote
Old 07-29-2018, 07:28 AM   #3
solarfall
Human being with feelings
 
Join Date: Sep 2013
Posts: 74
Default

Yes, i plotted it. It's a classic sigmoid function. The pre and post gain is there to increase saturation. I just chose the number by ear. I guess soft clipping would be better than limiting, just to stay in the realm of analog. Does this makes sense?
solarfall is offline   Reply With Quote
Old 07-29-2018, 07:54 AM   #4
bezusheist
Human being with feelings
 
bezusheist's Avatar
 
Join Date: Nov 2010
Location: Mullet
Posts: 829
Default

the sin/cos functions have a limit (pi/2), so you need to hard clip <= that or else use another function that doesn't have a limit. (tanh(x) is very popular these days)
you could get rid of the default *2 for the gain and put an input gain slider there in place... let the user decide. (people love their input/output gain.)

i attached a screnshot of what happens with 0 dBFS sine input...that's not good...
Attached Images
File Type: png Screen Shot 2018-07-29 at 10.45.35 AM.png (31.4 KB, 610 views)
__________________
I like turtles
bezusheist is offline   Reply With Quote
Old 07-29-2018, 08:24 AM   #5
solarfall
Human being with feelings
 
Join Date: Sep 2013
Posts: 74
Default

Quote:
Originally Posted by bezusheist View Post
the sin/cos functions have a limit (pi/2), so you need to hard clip <= that or else use another function that doesn't have a limit. (tanh(x) is very popular these days)
you could get rid of the default *2 for the gain and put an input gain slider there in place... let the user decide. (people love their input/output gain.)

i attached a screnshot of what happens with 0 dBFS sine input...that's not good...
Cool! So i made some changes and removed that multiplication. Actually i've changed the entire waveshaping. For now i want something without controls for simplicity.

Code:
desc:AnalogSum
desc:AnalogSum


@init

a = rand(1);
t = 0;

mX1l=mX2l=mY1l=mY2l=mX1r=mX2r=mY1r=mY2r=0;

sx = 16+95.95*1.20103;
cx = floor(exp(sx*log(1.059))*8.17742);
res = 0;
//coeffcients
cutoff = 2 * cx / srate;
res = pow(10, 0.05 * -res);
k = 0.5 * res * sin($pi * cutoff);
c1 = 0.5 * (1 - k) / (1 + k);
c2 = (0.5 + c1) * cos($pi * cutoff);
c3 = (0.5 + c1 - c2) * 0.25;
    
mA0 = 2 * c3;
mA1 = 2 * 2 * c3;
mA2 = 2 * c3;
mB1 = 2 * -c2;
mB2 = 2 * c1;


function add_noise()
(
  spl0 += 0.00005*((rand(1)*2)-1);
  spl1 += 0.00005*((rand(1)*2)-1);
  spl0 += 0.00001*sin(2*$pi*51*t);
  spl1 += 0.00001*sin(2*$pi*51*t);
  t+=1/srate;
);


function add_harmonics()
(
    b = 2; c = 1; amp = 0.8;
    spl0 = ((sin(b*spl0)*cos(spl0/b))/b) + (spl0/(2.6*b));
    spl1 = ((sin(b*spl1)*cos(spl1/b))/b) + (spl1/(2.4*b));
    spl0 = ((c*spl0)/(1+abs(c*spl0)) + (spl0/(1.5*c)));
    spl1 = ((c*spl1)/(1+abs(c*spl1)) + (spl1/(1.7*c)));
    spl0 *= amp;
    spl1 *= amp;
);

function analog_stereo()
(
  m = 0.5*(spl0+spl1);
  s = 0.6*(spl1-spl0);
  spl1 = m + s;
  spl0 = m - s;
);

function filter()
(

  inputl = spl0;
  inputr = spl1;
  
  outputl = mA0*inputl + mA1*mX1l + mA2*mX2l - mB1*mY1l - mB2*mY2l;
  mX2l = mX1l;
  mX1l = inputl;
  mY2l = mY1l;
  mY1l = outputl;
   
  outputr = mA0*inputr + mA1*mX1r + mA2*mX2r - mB1*mY1r - mB2*mY2r;
  mX2r = mX1r;
  mX1r = inputr;
  mY2r = mY1r;
  mY1r = outputr;
  
  spl0 = outputl;
  spl1 = outputr;
);


@sample
  add_noise();
  filter();
  add_harmonics();
  analog_stereo();
solarfall is offline   Reply With Quote
Old 07-30-2018, 09:59 AM   #6
ashcat_lt
Human being with feelings
 
Join Date: Dec 2012
Posts: 7,296
Default

Why do you not just use a signoid function? All those sin and cos and tan and htan in order to approximate a function with a single exponential? In my experience, one sigmoid is slightly less efficient than one one (clamped) sin, and slightly more efficient than a real tanh, but it's definitely faster than even two sins in a row. It requires no external clamping and will never explode at any input value.

Maybe I'm missing something?

What's going on in that analog stereo function? I kind of only glanced at it.

Edit to add -

I've been doing everything with sigmoids for a while. Even rebuilding things I did with tanh just to save that tick or two. See my Logistic Sidechain Distortion in the stash.

I've also been thinking about making some "black box" type character plugs. No sliders or maybe just input and output level. Drop it on there, it does...something...and if you like it you keep it and if not, you try a different one.


Edit again - But also I think it was about 2003 when analog summing devices were really the talk of the town and I predicted that before long we'd have virtual analog summing devices.

Last edited by ashcat_lt; 07-30-2018 at 10:13 AM.
ashcat_lt is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 05:15 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.