Old 05-18-2017, 02:16 PM   #1
Aesis
Human being with feelings
 
Join Date: Jan 2011
Posts: 386
Default [JSFX] Plugin to cancel single delay tap

I need a plug-in to cancel single delay tap, but my JS FX coding skills suck horribly.

Basically all that is needed is a delay with feedback (the first tap is also a function of feedback) and polarity inversion in the loop right at the start. Can someone here show me how to program this? Should be just a few lines, two sliders one for the timing (in samples) and a other for feedback is enough.

In python the for loop for the delay would look like:

for i in range(len(Buffer)):
out(i) = -Feedback*out(i-timing) + input

Thanks!!

Last edited by Aesis; 05-18-2017 at 02:43 PM.
Aesis is offline   Reply With Quote
Old 05-22-2017, 05:23 AM   #2
Aesis
Human being with feelings
 
Join Date: Jan 2011
Posts: 386
Default

No one?

Even simply inverting the feedback loop in readelay would accomplish this (and perhaps turning the delay amount to samples based). Simple add of minus sign. Does anyone know if the code for readelay is included somewhere in the reaper directory?
Aesis is offline   Reply With Quote
Old 05-22-2017, 10:41 AM   #3
ashcat_lt
Human being with feelings
 
Join Date: Dec 2012
Posts: 2,243
Default

I mean it is really as simple as you say. Pick one of the JS delays, hit edit, figure out where to multiply by -1, and save it. Consult the JS Programming Reference as necessary. This wiki page explains the basics pretty well, and has an example of a very simple Echo. Doesn't have feedback, but it might help.
ashcat_lt is offline   Reply With Quote
Old 05-22-2017, 12:30 PM   #4
jrengmusic
Human being with feelings
 
jrengmusic's Avatar
 
Join Date: Jun 2015
Posts: 255
Default

Code:
desc:Single Tap Inverted Delay
//tags: Inverted Delay
//author: JRENG!
/*
JRENG! (C) MMXVII
License: WTFPL - http://www.wtfpl.net
*/

slider1:d=300<0,1000,1>Delay [ms]
slider2:f=0<0,100,1>Feedback [%]
slider3:m=100<0,100,1>Mix [%]
slider4:i=1<0,1,1{NORMAL,INVERTED}>Polarity

@slider
length = d * 0.001 * srate;
feedback = f * 0.01;
mix = m * 0.01;

@sample
in0 = spl0;
in1 = spl1;

bpos[0] = in0 + delay0 * feedback;
bpos[1] = in1 + delay1 * feedback;

bpos += 2 ;
bpos > length ? bpos = 0;

delay0 = bpos[0] * mix; 
delay1 = bpos[1] * mix;

i ? (
  delay0 *= -1;
  delay1 *= -1;
);


spl0 += delay0;
spl1 += delay1;
__________________
JRENG! | EHX | Youtube
jrengmusic is offline   Reply With Quote
Old 05-23-2017, 02:41 AM   #5
Aesis
Human being with feelings
 
Join Date: Jan 2011
Posts: 386
Default

Quote:
Originally Posted by jrengmusic View Post
Code:
desc:Single Tap Inverted Delay
//tags: Inverted Delay
//author: JRENG!
/*
JRENG! (C) MMXVII
License: WTFPL - http://www.wtfpl.net
*/

slider1:d=300<0,1000,1>Delay [ms]
slider2:f=0<0,100,1>Feedback [%]
slider3:m=100<0,100,1>Mix [%]
slider4:i=1<0,1,1{NORMAL,INVERTED}>Polarity

@slider
length = d * 0.001 * srate;
feedback = f * 0.01;
mix = m * 0.01;

@sample
in0 = spl0;
in1 = spl1;

bpos[0] = in0 + delay0 * feedback;
bpos[1] = in1 + delay1 * feedback;

bpos += 2 ;
bpos > length ? bpos = 0;

delay0 = bpos[0] * mix; 
delay1 = bpos[1] * mix;

i ? (
  delay0 *= -1;
  delay1 *= -1;
);


spl0 += delay0;
spl1 += delay1;
Thank you! Great work...

But it doesn't quite work, the feedback loop is too long by one sample. Besides that the timing is half what it claims.
Aesis is offline   Reply With Quote
Old 05-23-2017, 04:46 AM   #6
jrengmusic
Human being with feelings
 
jrengmusic's Avatar
 
Join Date: Jun 2015
Posts: 255
Default

Untested. I'm away from my laptop. But try this

Code:
desc:Single Tap Inverted Delay
//tags: Inverted Delay
//author: JRENG!
/*
JRENG! (C) MMXVII
License: WTFPL - http://www.wtfpl.net
*/

slider1:d=300<0,1000,1>Delay [ms]
slider2:f=0<0,100,1>Feedback [%]
slider3:m=100<0,100,1>Mix [%]
slider4:i=1<0,1,1{NORMAL,INVERTED}>Polarity

@slider
length = d * 0.001 * srate;
feedback = f * 0.01;
mix = m * 0.01;

@sample
in0 = spl0;
in1 = spl1;

bpos0[0] = in0 + delay0 * feedback;
bpos1[0] = in1 + delay1 * feedback;

bpos0 += 1 ;
bpos1 += 1;
bpos0 > length ? bpos0 = 0;
bpos1 > length ? bpos1 = 0;

delay0 = bpos0[0] * mix; 
delay1 = bpos1[0] * mix;

i ? (
  delay0 *= -1;
  delay1 *= -1;
);


spl0 += delay0;
spl1 += delay1;
__________________
JRENG! | EHX | Youtube
jrengmusic is offline   Reply With Quote
Old 05-23-2017, 06:37 AM   #7
Aesis
Human being with feelings
 
Join Date: Jan 2011
Posts: 386
Default

Quote:
Originally Posted by jrengmusic View Post
Untested. I'm away from my laptop. But try this

Code:
desc:Single Tap Inverted Delay
//tags: Inverted Delay
//author: JRENG!
/*
JRENG! (C) MMXVII
License: WTFPL - http://www.wtfpl.net
*/

slider1:d=300<0,1000,1>Delay [ms]
slider2:f=0<0,100,1>Feedback [%]
slider3:m=100<0,100,1>Mix [%]
slider4:i=1<0,1,1{NORMAL,INVERTED}>Polarity

@slider
length = d * 0.001 * srate;
feedback = f * 0.01;
mix = m * 0.01;

@sample
in0 = spl0;
in1 = spl1;

bpos0[0] = in0 + delay0 * feedback;
bpos1[0] = in1 + delay1 * feedback;

bpos0 += 1 ;
bpos1 += 1;
bpos0 > length ? bpos0 = 0;
bpos1 > length ? bpos1 = 0;

delay0 = bpos0[0] * mix; 
delay1 = bpos1[0] * mix;

i ? (
  delay0 *= -1;
  delay1 *= -1;
);


spl0 += delay0;
spl1 += delay1;
The timing is now fixed, but the delay still keeps lengthening itself by 1 sample each repetition.
Aesis is offline   Reply With Quote
Old 05-23-2017, 01:52 PM   #8
ashcat_lt
Human being with feelings
 
Join Date: Dec 2012
Posts: 2,243
Default

Quote:
Originally Posted by Aesis View Post
The timing is now fixed, but the delay still keeps lengthening itself by 1 sample each repetition.
This has become mono because bpos1[0] is the same place in the buffer as bpos0[0] so basically it writes the left sample to the buffer and then immediately overwrites it with the right sample, and when it pulls it back out, both sides get that right side sample.

If, after we set the length, we then set bpos1 = length, this will work. Or we can go back to the original and multiply length by 2.

The reason it's one sample too long is that the conditional checks for >, where it should be =>. The lengthth sample is too far.

I don't love the way the mix level is applied on the way back into the buffer. This means that the actual feedback is dependent both on the feedback and mix parameters, which doesn't seem right to me.
ashcat_lt is offline   Reply With Quote
Old 05-23-2017, 03:14 PM   #9
Aesis
Human being with feelings
 
Join Date: Jan 2011
Posts: 386
Default

Quote:
Originally Posted by ashcat_lt View Post
This has become mono because bpos1[0] is the same place in the buffer as bpos0[0] so basically it writes the left sample to the buffer and then immediately overwrites it with the right sample, and when it pulls it back out, both sides get that right side sample.

If, after we set the length, we then set bpos1 = length, this will work. Or we can go back to the original and multiply length by 2.

The reason it's one sample too long is that the conditional checks for >, where it should be =>. The lengthth sample is too far.

I don't love the way the mix level is applied on the way back into the buffer. This means that the actual feedback is dependent both on the feedback and mix parameters, which doesn't seem right to me.
Thanks, I will try the fix. I already thought that may be the issue, but instead added a minus there, and it didn't work.

The mix works great for me, because I wanted the plug to cancel delay taps/lines. For that the feedback needs to be always at 100%, which is convenient. However, I will still have to change the ms based timing to sample based, because obviously it needs to be exact. The values I check from a cross correlation function.
Aesis is offline   Reply With Quote
Old 05-23-2017, 03:39 PM   #10
bezusheist
Human being with feelings
 
bezusheist's Avatar
 
Join Date: Nov 2010
Location: Dummytown
Posts: 431
Default

Quote:
Originally Posted by ashcat_lt View Post
T
If, after we set the length, we then set bpos1 = length, this will work. Or we can go back to the original and multiply length by 2.
don't mean to distract from this thread, but this has been driving me nuts and thought maybe you or someone else could help...

i'm trying to make a simple delay and i can't get it to work correctly.
i take the basic code from the js tutorial and some of the jsfx and try to make it stereo but i need to "+1" the slider value to get it to be accurate. i have no idea why.
i noticed this code in the js master limiter and also that it is always 1 sample behind.
i tried moving stuff around but nothing made it work besides adding 1 to the delay time.
anyway, here is what i have...(it works)
Code:
desc:delay

slider1:1<1,1000,1>delay (samples)

@slider

delay = slider1+1;

@sample

bufpos[0] = spl0;
bufpos[delay] = spl1;
bufpos +=1;
bufpos >= delay ? bufpos = 0;
spl0 = bufpos[0]; 
spl1 = bufpos[delay];
i thought that was a "proper" bare bones delay, but maybe not. what did i do wrong ?
__________________
the quim reaper
bezusheist is offline   Reply With Quote
Old 05-23-2017, 06:57 PM   #11
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 10,246
Default

Quote:
Originally Posted by bezusheist View Post
don't mean to distract from this thread, but this has been driving me nuts and thought maybe you or someone else could help...

i'm trying to make a simple delay and i can't get it to work correctly.
i take the basic code from the js tutorial and some of the jsfx and try to make it stereo but i need to "+1" the slider value to get it to be accurate. i have no idea why.
i noticed this code in the js master limiter and also that it is always 1 sample behind.
i tried moving stuff around but nothing made it work besides adding 1 to the delay time.
anyway, here is what i have...(it works)

i thought that was a "proper" bare bones delay, but maybe not. what did i do wrong ?
I think yours is correct, but try this mod (reducing the size of the delay line by one sample by reading then writing):
Code:
desc:delay

slider1:1<1,1000,1>delay (samples)

@slider

delay = slider1;

@sample

ns1 = bufpos[0];
ns2 = bufpos[delay];
bufpos[0] = spl0;
bufpos[delay] = spl1;
bufpos +=1;
bufpos >= delay ? bufpos = 0;
spl0 = ns1; 
spl1 = ns2;
Justin is offline   Reply With Quote
Old 05-24-2017, 03:13 AM   #12
Aesis
Human being with feelings
 
Join Date: Jan 2011
Posts: 386
Default

Quote:
Originally Posted by ashcat_lt View Post
This has become mono because bpos1[0] is the same place in the buffer as bpos0[0] so basically it writes the left sample to the buffer and then immediately overwrites it with the right sample, and when it pulls it back out, both sides get that right side sample.

If, after we set the length, we then set bpos1 = length, this will work. Or we can go back to the original and multiply length by 2.

The reason it's one sample too long is that the conditional checks for >, where it should be =>. The lengthth sample is too far.

I don't love the way the mix level is applied on the way back into the buffer. This means that the actual feedback is dependent both on the feedback and mix parameters, which doesn't seem right to me.
Okay, I tried this fix, and it still didn't work. The first delay tap is still shorter by one sample...
Aesis is offline   Reply With Quote
Old 05-24-2017, 03:06 PM   #13
bezusheist
Human being with feelings
 
bezusheist's Avatar
 
Join Date: Nov 2010
Location: Dummytown
Posts: 431
Default

Quote:
Originally Posted by Justin View Post
I think yours is correct, but try this mod (reducing the size of the delay line by one sample by reading then writing):
cool, thanks for that, it seems to work correctly for sample delay.

does JS allow for "actual" ms (sub-sample) delay ? it seems like it does.
this new code/fix seems to have a problem with that, though.
i just tried it quickly but only seems to work for mono render.
so do i need 2 different delays ? a sample delay and a seconds based delay ?

Quote:
Originally Posted by Aesis View Post
Okay, I tried this fix, and it still didn't work. The first delay tap is still shorter by one sample...
maybe this has something to do with the issue i am experiencing ?

i was going to have a go at making this delay, but i couldn't even get a simple delay to work so i guess i can't help out too much ...
__________________
the quim reaper
bezusheist is offline   Reply With Quote
Old 05-24-2017, 03:47 PM   #14
Aesis
Human being with feelings
 
Join Date: Jan 2011
Posts: 386
Default

Quote:
Originally Posted by bezusheist View Post
cool, thanks for that, it seems to work correctly for sample delay.

does JS allow for "actual" ms (sub-sample) delay ? it seems like it does.
this new code/fix seems to have a problem with that, though.
i just tried it quickly but only seems to work for mono render.
so do i need 2 different delays ? a sample delay and a seconds based delay ?



maybe this has something to do with the issue i am experiencing ?

i was going to have a go at making this delay, but i couldn't even get a simple delay to work so i guess i can't help out too much ...
If you have any ideas how to get it to work, by all means let me know. Yes it seems like it may be a related issue, but the JS code is so cryptic to me, it would be a bit of work to get used to it.

As for your question about sub sample delay, you would need sinc interpolation for that, I doubt there is a by default solution. Minimum phase LP filter based interpolation might work better for a real time application, but the phase suffers...

Last edited by Aesis; 05-24-2017 at 04:15 PM.
Aesis is offline   Reply With Quote
Old 05-24-2017, 04:02 PM   #15
bezusheist
Human being with feelings
 
bezusheist's Avatar
 
Join Date: Nov 2010
Location: Dummytown
Posts: 431
Default

ok, i can get what looks like a sub-sample delay, but i think that maybe it's both channels (spl0+spl1) output summed, and there is a 1 sample difference between channels (one before, one after). so an impulse delayed 1ms looks like it was delayed 1ms, but it was really two samples summed...one delayed 44 samples, the other delayed 45 samples.
i think...
__________________
the quim reaper
bezusheist is offline   Reply With Quote
Old 05-27-2017, 06:04 AM   #16
Aesis
Human being with feelings
 
Join Date: Jan 2011
Posts: 386
Default

Still wondering if anyone has any ideas on how to make the code by jrengmusic work. It's literally one sample away from being correct. Merely delaying the whole delay by one sample seems like it should make it work.
Aesis is offline   Reply With Quote
Old 06-02-2017, 01:53 PM   #17
Aesis
Human being with feelings
 
Join Date: Jan 2011
Posts: 386
Default

Bump...
Aesis is offline   Reply With Quote
Old 06-12-2017, 04:41 AM   #18
Aesis
Human being with feelings
 
Join Date: Jan 2011
Posts: 386
Default

Still wondering if someone knows of a fix.

Last edited by Aesis; 06-12-2017 at 04:49 AM.
Aesis 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 03:05 AM.


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