-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfullbacano.c
40 lines (27 loc) · 884 Bytes
/
fullbacano.c
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
#include <lv2plugin.hpp>
using namespace LV2;
class StereoPanner : public Plugin<StereoPanner> {
public:
StereoPanner(double rate)
: Plugin<StereoPanner>(6) {
}
void run(uint32_t nframes) {
float width = *p(0);
float balance = *p(1);
width = width < 0 ? 0 : width;
width = width > 1 ? 1 : width;
balance = balance < -1 ? -1 : balance;
balance = balance > 1 ? 1 : balance;
for (uint32_t i = 0; i < nframes; ++i) {
float mid = (p(2)[i] + p(3)[i]) / 2;
float side = (p(2)[i] - p(3)[i]) / 2;
p(4)[i] = (mid + width * side) * 2 / (1 + width);
p(5)[i] = (mid - width * side) * 2 / (1 + width);
if (balance < 0)
p(5)[i] *= 1 + balance;
else
p(4)[i] *= 1 - balance;
}
}
};
static int _ = StereoPanner::register_class("http://ll-plugins.nongnu.org/lv2/lv2pftci/stereopanner");