Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 03-07-2019, 07:47 AM   #1
ReubenAlfie
Human being with feelings
 
Join Date: Dec 2018
Posts: 16
Default I don't code my own JSFX but I just need an automatic HP for a JS effect

I don't code my own JSFX yet but I'll probably end up doing so in the future as I get into it.

I'm hacking and slicing up some JSFX I like to create some plugs for my workflow.

I have a saturation style plugin that needs a high pass @ 20Hz to remove some DC offset. Can somebody recommend the best type of filter to use and the code for it? Also I don't want the highpass to be selectable, I just want it to add a 20Hz high pass automatically for the reason mentioned.
ReubenAlfie is offline   Reply With Quote
Old 03-07-2019, 08:19 AM   #2
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

A first order high-pass will probably suffice. However, I think I would set the cutoff a bit lower, so 20 Hz passes through more or less unaltered.
Tale is online now   Reply With Quote
Old 03-07-2019, 08:34 AM   #3
ReubenAlfie
Human being with feelings
 
Join Date: Dec 2018
Posts: 16
Default

Quote:
Originally Posted by Tale View Post
A first order high-pass will probably suffice. However, I think I would set the cutoff a bit lower, so 20 Hz passes through more or less unaltered.
can you link me to any code for that? and again I would like to have it automatic in the ReaJS so its always doing its HP thing, I dont want it to be a controllable parameter
ReubenAlfie is offline   Reply With Quote
Old 03-07-2019, 08:52 AM   #4
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

Quote:
Originally Posted by ReubenAlfie View Post
can you link me to any code for that? and again I would like to have it automatic in the ReaJS so its always doing its HP thing, I dont want it to be a controllable parameter
http://www.earlevel.com/main/2012/12...e-pole-filter/

Also, I have a high-pass filter implementation in my JSFX pack.

EDIT: Here is an example:

Code:
desc:DC blocking high-pass filter

@init

cutoff = 7.0; // Hz

b1 = exp(-2*$pi * cutoff / srate);
a0 = (b1 + 1) * 0.5;

@sample

hp0 = (spl0 - old_spl0) * a0 + hp0 * b1;
hp1 = (spl1 - old_spl1) * a0 + hp1 * b1;

old_spl0 = spl0;
old_spl1 = spl1;

spl0 = hp0;
spl1 = hp1;

Last edited by Tale; 03-07-2019 at 09:08 AM. Reason: Added example code
Tale is online now   Reply With Quote
Old 03-07-2019, 02:56 PM   #5
ReubenAlfie
Human being with feelings
 
Join Date: Dec 2018
Posts: 16
Default

Quote:
Originally Posted by Tale View Post
http://www.earlevel.com/main/2012/12...e-pole-filter/

Also, I have a high-pass filter implementation in my JSFX pack.

EDIT: Here is an example:

Code:
desc:DC blocking high-pass filter

@init

cutoff = 7.0; // Hz

b1 = exp(-2*$pi * cutoff / srate);
a0 = (b1 + 1) * 0.5;

@sample

hp0 = (spl0 - old_spl0) * a0 + hp0 * b1;
hp1 = (spl1 - old_spl1) * a0 + hp1 * b1;

old_spl0 = spl0;
old_spl1 = spl1;

spl0 = hp0;
spl1 = hp1;
thankyou so much Tale!
so the high pass is at 7Hz, so how many dB is the slope?
ReubenAlfie is offline   Reply With Quote
Old 03-07-2019, 07:31 PM   #6
ashcat_lt
Human being with feelings
 
Join Date: Dec 2012
Posts: 7,271
Default

Quote:
Originally Posted by ReubenAlfie View Post
thankyou so much Tale!
so the high pass is at 7Hz, so how many dB is the slope?
First order = 6db/octave. If you think you need more than that, you put several in series, but you need to rename some of the variables so that they don't overwrite each other's "history". If you really just want to remove DC, one should be sufficient, and any cutoff greater than 0 will do it, but the lower it is, the longer it takes to settle.
ashcat_lt is offline   Reply With Quote
Old 03-16-2019, 05:07 AM   #7
ReubenAlfie
Human being with feelings
 
Join Date: Dec 2018
Posts: 16
Default

Quote:
Originally Posted by ashcat_lt View Post
First order = 6db/octave. If you think you need more than that, you put several in series, but you need to rename some of the variables so that they don't overwrite each other's "history". If you really just want to remove DC, one should be sufficient, and any cutoff greater than 0 will do it, but the lower it is, the longer it takes to settle.
I experimented with the cut off, and 8Hz seems to do the job. Js Audio statistics is the balls for this kind of stuff haha
ReubenAlfie is offline   Reply With Quote
Old 03-16-2019, 10:01 AM   #8
ashcat_lt
Human being with feelings
 
Join Date: Dec 2012
Posts: 7,271
Default

You know there is a JS DC removal plugin, but it's not significantly different from what Tale posted. What saturation are you playing with? Is it causing a DC offset? If so, you should actually be able to just figure out how much and add or subtract it out. Would be slightly more efficient.
ashcat_lt is offline   Reply With Quote
Old 03-18-2019, 03:21 AM   #9
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

Quote:
Originally Posted by ashcat_lt View Post
You know there is a JS DC removal plugin, but it's not significantly different from what Tale posted.
Well... The stock dc_remove doesn't take the sample rate into account, so at 44.1 kHz it cuts at 7 Hz or so, but at 96 kHz it cuts at 15 Hz, which IMHO it too high.
Tale 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 02:03 AM.


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