Old 11-28-2019, 03:16 PM   #1
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 59
Default Tales Upsampling to Stereo

Hi

Im meaning to use Tales library and upsample some experiments. His example is mono only and I cant figure out how to change code to get an Left + Right version?

Any ideas? Thanks

Regards /danerius

---------------------------------------------------------------------------

desc:Oversampled distortion

import Tale/oversample.jsfx-inc

@init

function tanh(x)
(
x = exp(2*x);
(x - 1) / (x + 1);
);

pdc_bot_ch = 0; pdc_top_ch = 2;
pdc_delay = 3;

@slider

drive = exp(log(10)/20 * slider1);
gain = sqrt(1/drive);

@sample

os.os_up2(0.5*(spl0 + spl1));

os.y1 = tanh(drive * os.y1);
os.y0 = tanh(drive * os.y0);

spl0 = spl1 = gain * os.os_down2();
danerius is offline   Reply With Quote
Old 11-28-2019, 05:56 PM   #2
ashcat_lt
Human being with feelings
 
Join Date: Dec 2012
Posts: 4,363
Default

Something like this, I think:
Code:
@sample

os0.os_up2(spl0);
os1.os_up2(spl1);

os0.y1 = tanh(drive * os0.y1);
os0.y0 = tanh(drive * os0.y0);


os1.y1 = tanh(drive * os1.y1);
os1.y0 = tanh(drive * os1.y0);


spl0 = gain * os0.os_down2();
spl1 = gain * os1.os_down2();
Pretty much just do it twice, really.
ashcat_lt is online now   Reply With Quote
Old 11-29-2019, 02:09 AM   #3
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 59
Default

Hi

Excellent. Many, many thanks

It was the "os0..." that does it

Regards /danerius

Quote:
Originally Posted by ashcat_lt View Post
Something like this, I think:
danerius is offline   Reply With Quote
Old 11-30-2019, 01:03 PM   #4
ErBird
Human being with feelings
 
Join Date: Jan 2017
Posts: 100
Default

Hi Danerius,

If you aren't aware, Sai'ke has implemented, in JS form, a novel technique to anti-alias TANH without oversampling. Oversampling would further improve the result, but this technique offers properties that you can't get through oversampling alone. Aliasing foldback into the lower frequencies is substantially reduced.

https://raw.githubusercontent.com/Jo...urator_AA.jsfx

And here is some discussion in this unrelated thread:

https://forum.cockos.com/showpost.ph...7&postcount=34

Based on this paper:

http://dafx16.vutbr.cz/dafxpapers/20...aper_41-PN.pdf

P.S. You can pretty much ignore the beta linear version and stick with the rect/constant one.
ErBird is online now   Reply With Quote
Old 11-30-2019, 03:58 PM   #5
ashcat_lt
Human being with feelings
 
Join Date: Dec 2012
Posts: 4,363
Default

OTOH, I find that most of the time when I’m distorting anything heavily enough for aliasing to be noticeable, I either literally don’t care because it’s supposed to be horrible or I want to filter off a bunch of high end before and after the non-linearity anyway. A low pass at 10K is just as good as 2x OS. I call it “undersampling”.
ashcat_lt is online now   Reply With Quote
Old 12-01-2019, 09:50 AM   #6
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 59
Default

Hi ErBird

Cool. Thanks I read the paper but only could take in that they apply a sort of mirror image of the tanh to cancel the aliasing. Much like a humbucker or XLR-Cable?

I do this to learn enough to be able to experiment with my own plugin ideas. Learning to use a bit of upsampling code is really helpful. Now Im looking of a way to upsample more and/or up the the bit level. Maybe I'll eventually find a way to implement the idea in the paper

Best regards /danerius

Quote:
Originally Posted by ErBird View Post
Hi Danerius,

If you aren't aware, Sai'ke has implemented, in JS form, a novel technique to anti-alias TANH without oversampling. Oversampling would further improve the result, but this technique offers properties that you can't get through oversampling alone. Aliasing foldback into the lower frequencies is substantially reduced.

https://raw.githubusercontent.com/Jo...urator_AA.jsfx

And here is some discussion in this unrelated thread:

https://forum.cockos.com/showpost.ph...7&postcount=34

Based on this paper:

http://dafx16.vutbr.cz/dafxpapers/20...aper_41-PN.pdf

P.S. You can pretty much ignore the beta linear version and stick with the rect/constant one.
danerius is offline   Reply With Quote
Old 12-01-2019, 09:52 AM   #7
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 59
Default

Quote:
Originally Posted by ashcat_lt View Post
OTOH, I find that most of the time when I’m distorting anything heavily enough for aliasing to be noticeable, I either literally don’t care because it’s supposed to be horrible or I want to filter off a bunch of high end before and after the non-linearity anyway. A low pass at 10K is just as good as 2x OS. I call it “undersampling”.
Hi ashcat and thanks

Just like it says in my reply to ErBird. I do this to learn code. THe disrtion plugin is a nice effect

Best regards /danerius
danerius is offline   Reply With Quote
Old 12-01-2019, 12:08 PM   #8
ErBird
Human being with feelings
 
Join Date: Jan 2017
Posts: 100
Default

Quote:
Originally Posted by danerius View Post
I do this to learn code.
Me too and JS is a lot of fun.

I'll drop this here if you want to revisit this idea later. It's the minimum code needed to implement this anti-aliasing technique.

Code:
desc:Tanh AA

in_pin:left input
in_pin:right input
out_pin:left output
out_pin:right output

@sample

  function F0(x)
  (
    abs(x) - log(2/(1 + exp(-2*abs(x))));
  );

  function tanh(x)
  (
    2/(1 + exp(-2*x)) - 1;
  );
  
  function antialiased_tanh_rect(x)
  local(eps, F0_xn)
  instance(xnm1, F0_xnm1, out)
  (
    F0_xn   = F0(x);
    eps     = 0.0000000001;
    out     = eps < abs(x - xnm1) ? (F0_xn - F0_xnm1)/(x - xnm1) : tanh(0.5*(x+xnm1));
    F0_xnm1 = F0_xn;
    xnm1    = x;
    out;
  );

  spl0 = ch0.antialiased_tanh_rect(spl0);
  spl1 = ch1.antialiased_tanh_rect(spl1);
ErBird is online now   Reply With Quote
Old 12-02-2019, 01:07 AM   #9
danerius
Human being with feelings
 
Join Date: Oct 2018
Posts: 59
Default

Hi and big thanks

I'll try out the code and see what I can derive from it

Best regards /danerius

Quote:
Originally Posted by ErBird View Post
Me too and JS is a lot of fun.

I'll drop this here if you want to revisit this idea later. It's the minimum code needed to implement this anti-aliasing technique.
danerius is offline   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 02:54 PM.


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