File: simplelp6db.jsfx

package info (click to toggle)
jsusfx 0.4.0-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,912 kB
  • sloc: ansic: 19,352; cpp: 9,314; php: 403; yacc: 338; python: 163; makefile: 124; lex: 113; sh: 6
file content (98 lines) | stat: -rw-r--r-- 2,505 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// (C) 2008-2009, Lubomir I. Ivanov

// NO WARRANTY IS GRANTED. THIS PLUG-IN IS PROVIDED ON AN "AS IS" BASIS, WITHOUT
// WARRANTY OF ANY KIND. NO LIABILITY IS GRANTED, INCLUDING, BUT NOT LIMITED TO,
// ANY DIRECT OR INDIRECT,  SPECIAL,  INCIDENTAL OR CONSEQUENTIAL DAMAGE ARISING
// OUT OF  THE  USE  OR INABILITY  TO  USE  THIS PLUG-IN,  COMPUTER FAILTURE  OF
// MALFUNCTION INCLUDED.  THE USE OF THE SOURCE CODE,  EITHER  PARTIALLY  OR  IN
// TOTAL, IS ONLY GRANTED,  IF USED IN THE SENSE OF THE AUTHOR'S INTENTION,  AND
// USED WITH ACKNOWLEDGEMENT OF THE AUTHOR. FURTHERMORE IS THIS PLUG-IN A  THIRD
// PARTY CONTRIBUTION,  EVEN IF INCLUDED IN REAPER(TM),  COCKOS INCORPORATED  OR
// ITS AFFILIATES HAVE NOTHING TO DO WITH IT.  LAST BUT NOT LEAST, BY USING THIS
// PLUG-IN YOU RELINQUISH YOUR CLAIM TO SUE IT'S AUTHOR, AS WELL AS THE CLAIM TO
// ENTRUST SOMEBODY ELSE WITH DOING SO.
// 
// Released under GPL:
// <http://www.gnu.org/licenses/>.

//=================================================
desc: Simple LP, HP Filter 6db

slider1:0<0,1,1{Stereo,Mono}>Processing
slider2:0<0,1,1{LP,HP}>Filter Type
slider3:100<0,100,0.05>Cutoff (Scale)
slider4:0<-25,25,0.05>Output (dB)

//=================================================
@slider
//mono
mono = slider1;

//type
hp = slider2;

//exp scale
sx = 16+slider3*1.20103;
cutoff = floor(exp(sx*log(1.059))*8.17742);

//coeff
cutoff = min(cutoff,20000);
lp_cut = 2*$pi*cutoff;
lp_n = 1/(lp_cut+ 3*srate);
lp_b1 = (3*srate - lp_cut)*lp_n;
lp_a0 = lp_cut*lp_n;

//outgain
outgain = 10^(slider4/20);

//=================================================
@sample
//stereo
mono == 0 ? (

//recursion
inl = spl0;
inr = spl1;
lp_outl = 2*inl*lp_a0 + lp_outl*lp_b1;
lp_outr = 2*inr*lp_a0 + lp_outr*lp_b1;

//type
hp == 0 ? (
  spl0 = lp_outl*outgain;
  spl1 = lp_outr*outgain;
) : (
  spl0 = (inl-lp_outl)*outgain;
  spl1 = (inr-lp_outr)*outgain;
);

) : (
//mono

//recursion
inl = (spl0+spl1)/2;
lp_outl = 2*inl*lp_a0 + lp_outl*lp_b1;

//type
hp == 0 ? (
  spl0=spl1=lp_outl*outgain;
) : (
  spl0=spl1=(inl-lp_outl)*outgain;
);

);

//=================================================
@gfx 100 10
//draw freq scale numbers
gfx_x=gfx_y=5;
gfx_lineto(gfx_x, gfx_y,0);
gfx_r=gfx_b=0;
gfx_g=gfx_a=1;
gfx_drawchar($'F');
gfx_drawchar($' ');
gfx_drawchar($'=');
gfx_drawchar($' ');
gfx_drawnumber(cutoff,0);
gfx_drawchar($' ');
gfx_drawchar($'H');
gfx_drawchar($'z');