Skip to content

Commit ff82151

Browse files
authored
Merge pull request #194 from 44100hertz/master
2 parents 5619e28 + 22f41ea commit ff82151

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
desc: Harmonic Bass Enhancer
2+
author: @aliasing
3+
4+
bassFreq:150<50,300>Bass Frequency
5+
bassQ:2.0<0.5,4.0>Bass Q
6+
bassLevel:0.0<0.0,2.0>Source bass passthrough
7+
harmonicFreq:400<100,800>Harmonics Frequency
8+
harmonicQ:1.0<0.25,2.0>Harmonic Q
9+
harmonicDrive:6.0<0.0,20.0>Harmonics Drive Level
10+
harmonicBias:0.1<0.0,0.5>Saturation Bias Level (Odd to Even)
11+
harmonicLevel:0.8<0.0,2.0>Harmonics Level
12+
13+
@init
14+
bassFreq = 250;
15+
bassQ = 2.0;
16+
bassLevel = 0.0;
17+
harmonicFreq = 500;
18+
harmonicQ = 1.0;
19+
harmonicDrive = 10.0;
20+
harmonicLevel = 1.0;
21+
harmonicBias = 0.5;
22+
23+
function LP_set(frequency qFactor)(
24+
x = (frequency * 2.f * $PI) / srate;
25+
sinX = sin(x);
26+
y = sinX / (qFactor * 2.f);
27+
cosX = cos(x);
28+
z = (1.f - cosX) / 2.f;
29+
30+
_a0 = y + 1.f;
31+
_a1 = cosX * -2.f;
32+
_a2 = 1.f - y;
33+
_b0 = z;
34+
_b1 = 1.f - cosX;
35+
_b2 = z;
36+
37+
this.y_2 = 0; this.y_1 = 0; this.x_2 = 0; this.x_1 = 0;
38+
this.b0 = _b0 / _a0;
39+
this.b1 = _b1 / _a0;
40+
this.b2 = _b2 / _a0;
41+
this.a1 = -_a1 / _a0;
42+
this.a2 = -_a2 / _a0;
43+
);
44+
45+
function LP_process(sample)(
46+
out = sample * this.b0 + this.x_1 * this.b1 + this.x_2 * this.b2 + this.y_1 * this.a1 + this.y_2 * this.a2;
47+
this.y_2 = this.y_1;
48+
this.y_1 = out;
49+
this.x_2 = this.x_1;
50+
this.x_1 = sample;
51+
52+
out;
53+
);
54+
55+
function Channel_set(bassFreq, harmonicFreq, qFactor) (
56+
this.lp_low.LP_set(bassFreq, qFactor);
57+
this.lp_high.LP_set(harmonicFreq, qFactor);
58+
);
59+
60+
function saturate(sample, bias) (
61+
satOdd = sample / (abs(sample) + 1.0);
62+
satEven = satOdd * satOdd * 2.0;
63+
satOdd + bias * (satEven - satOdd);
64+
);
65+
66+
function Channel_process(sample, harmonicDrive, harmonicBias, harmonicLevel, bassLevel) (
67+
bass = this.lp_low.LP_process(sample);
68+
topend = sample - bass;
69+
bass = saturate(bass * harmonicDrive, harmonicBias);
70+
harmonics = this.lp_high.LP_process(bass);
71+
topend + harmonics * harmonicLevel + bass * bassLevel;
72+
);
73+
74+
bass_l.Channel_set(bassFreq, harmonicFreq, bassQ);
75+
bass_r.Channel_set(bassFreq, harmonicFreq, harmonicQ);
76+
77+
@sample
78+
spl0 = bass_l.Channel_process(spl0, harmonicDrive, harmonicBias, harmonicLevel, bassLevel);
79+
spl1 = bass_r.Channel_process(spl1, harmonicDrive, harmonicBias, harmonicLevel, bassLevel);
80+

0 commit comments

Comments
 (0)