-
Notifications
You must be signed in to change notification settings - Fork 0
/
PostFXController.pde
78 lines (67 loc) · 1.91 KB
/
PostFXController.pde
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
/*
PostFXController
Feature that adds filter to the resulting image
*/
import ch.bildspur.postfx.builder.*;
import ch.bildspur.postfx.pass.*;
import ch.bildspur.postfx.*;
public class PostFXController extends Feature {
PostFX fx;
public float midiNoiseFactor = 0;
public float midiVigneteSize = 0;
public boolean midiSobelEnabled = false;
public float midiPixealte = height;
public float midiRGBSplit = 0;
public PostFXController(PApplet applet, MidiInterface midi, int midiEnableFaderNumber) {
super(applet, midi, midiEnableFaderNumber);
}
public void setupFeature() {
fx = new PostFX(this.applet);
midi.registerForFaderValue(this, 56);
midi.registerForFaderValue(this, 57);
midi.registerForFaderValue(this, 55);
midi.registerForFaderValue(this, 54);
midi.registerForNoteValue(this, 19);
}
public void newFaderValue(int value, int number) {
if (number == 56) {
midiNoiseFactor = map(value, 0, 127, 0, 0.8);
}
if (number == 57) {
midiVigneteSize = map(value, 0, 127, 0, 1.5);
}
if (number == 55) {
midiRGBSplit = map(value, 0, 127, 0, 200);
}
if (number == 54) {
midiPixealte = map(value, 0, 127, width/2, 1);
}
}
public void newNoteValue(int note) {
super.newNoteValue(note);
if (note == 19) {
midiSobelEnabled = !midiSobelEnabled;
this.midi.setControlLED(note, this.midiSobelEnabled);
}
}
public void featureGotEnabled() {
}
public void drawFeature(int currentTimeState) {
PostFXBuilder builder = fx.render();
if (this.midiNoiseFactor > 0) {
builder = builder.noise(midiNoiseFactor, 0.4);
}
if (this.midiPixealte < width/2) {
builder = builder.pixelate(midiPixealte);
}
if (this.midiRGBSplit > 0) {
builder = builder.rgbSplit(midiRGBSplit);
//builder = builder.bloom(midiRGBSplit, 30, 50);
}
if (this.midiSobelEnabled) {
builder = builder.sobel();
}
builder = builder.vignette(midiVigneteSize, 0.2);
builder.compose();
}
}