audioreactivity now applicable to all parameters, major change in how parameters are being read by the shader

This commit is contained in:
2024-08-24 14:52:50 +02:00
parent 821092116f
commit e94d5c54d2
4 changed files with 291 additions and 251 deletions

View File

@@ -45,27 +45,27 @@ class WEBCAM extends Shader {
params.add(new Param("saturation", FLOATVAL, 0.0, 1.0, new int[]{TRIANG, SINE, RAMPUPDOWN }));
params.add(new Param("blend mode", INTVAL, 0, this.blends.length-1, new int[]{RANDOM }));
params.add(new Param("webcam", INTVAL, 0, Capture.list().length-1, new int[]{TRIANG, SINE, RAMPUPDOWN, }));
camSelected = (int)params.get(13).value;
camSelectedPrev = (int)params.get(13).value;
camSelected = (int)params.get(13).getValue();
camSelectedPrev = (int)params.get(13).getValue();
}
void apply() {
rw = canvas.width;
rh = canvas.height;
x = int(params.get(0).value*rw);
y = int(params.get(1).value*rh);
w = int(params.get(2).value*(rw*2));
h = int(params.get(3).value*(rh*2));
x = int(params.get(0).getValue()*rw);
y = int(params.get(1).getValue()*rh);
w = int(params.get(2).getValue()*(rw*2));
h = int(params.get(3).getValue()*(rh*2));
camSelected = (int)params.get(13).value;
camSelected = (int)params.get(13).getValue();
/*
if (camSelected != camSelectedPrev) {
currentCam = camSelected;
camSelectedPrev = camSelected;
stopWebcam();
startWebcam();
//new Capture(this, 1920,1080, Capture.list()[camSelected]);
}*/
currentCam = camSelected;
camSelectedPrev = camSelected;
stopWebcam();
startWebcam();
//new Capture(this, 1920,1080, Capture.list()[camSelected]);
}*/
@@ -100,12 +100,12 @@ class ASDFPIXELSORT extends Shader {
}
int previousMode;
void apply() {
if (previousMode != int(params.get(1).value)) {
if (params.get(1).value == 0) changeParam(0, new Param("black", INTVAL, -17000000, -2000000, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANG}));
if (params.get(1).value == 1) changeParam(0, new Param("brightness", INTVAL, 0, 200, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANG}));
if (params.get(1).value == 2) changeParam(0, new Param("white", INTVAL, -15000000, -700000, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANG}));
if (previousMode != int(params.get(1).getValue())) {
if (params.get(1).getValue() == 0) changeParam(0, new Param("black", INTVAL, -17000000, -2000000, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANG}));
if (params.get(1).getValue() == 1) changeParam(0, new Param("brightness", INTVAL, 0, 200, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANG}));
if (params.get(1).getValue() == 2) changeParam(0, new Param("white", INTVAL, -15000000, -700000, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANG}));
}
previousMode = (int)params.get(1).value;
previousMode = (int)params.get(1).getValue();
row = 0;
column = 0;
@@ -134,7 +134,7 @@ class ASDFPIXELSORT extends Shader {
int y = row;
int xend = 0;
while (xend < canvas.width-1) {
switch((int)params.get(1).value) {
switch((int)params.get(1).getValue()) {
case 0:
x = getFirstNotBlackX(x, y);
xend = getNextBlackX(x, y);
@@ -179,7 +179,7 @@ class ASDFPIXELSORT extends Shader {
int yend = 0;
while (yend < canvas.height-1) {
switch((int)params.get(1).value) {
switch((int)params.get(1).getValue()) {
case 0:
y = getFirstNotBlackY(x, y);
yend = getNextBlackY(x, y);
@@ -222,7 +222,7 @@ class ASDFPIXELSORT extends Shader {
int x = _x;
int y = _y;
color c;
while ( (c = canvas.pixels[x + y * canvas.width]) < params.get(0).value) {
while ( (c = canvas.pixels[x + y * canvas.width]) < params.get(0).getValue()) {
x++;
if (x >= canvas.width) return -1;
}
@@ -233,7 +233,7 @@ class ASDFPIXELSORT extends Shader {
int x = _x+1;
int y = _y;
color c;
while ( (c = canvas.pixels[x + y * canvas.width]) > params.get(0).value) {
while ( (c = canvas.pixels[x + y * canvas.width]) > params.get(0).getValue()) {
x++;
if (x >= canvas.width) return canvas.width-1;
}
@@ -245,7 +245,7 @@ class ASDFPIXELSORT extends Shader {
int x = _x;
int y = _y;
color c;
while (brightness (c = canvas.pixels[x + y * canvas.width]) < params.get(0).value) {
while (brightness (c = canvas.pixels[x + y * canvas.width]) < params.get(0).getValue()) {
x++;
if (x >= canvas.width) return -1;
}
@@ -256,7 +256,7 @@ class ASDFPIXELSORT extends Shader {
int x = _x+1;
int y = _y;
color c;
while (brightness (c = canvas.pixels[x + y * canvas.width]) > params.get(0).value) {
while (brightness (c = canvas.pixels[x + y * canvas.width]) > params.get(0).getValue()) {
x++;
if (x >= canvas.width) return canvas.width-1;
}
@@ -268,7 +268,7 @@ class ASDFPIXELSORT extends Shader {
int x = _x;
int y = _y;
color c;
while ( (c = canvas.pixels[x + y * canvas.width]) > params.get(0).value) {
while ( (c = canvas.pixels[x + y * canvas.width]) > params.get(0).getValue()) {
x++;
if (x >= canvas.width) return -1;
}
@@ -279,7 +279,7 @@ class ASDFPIXELSORT extends Shader {
int x = _x+1;
int y = _y;
color c;
while ( (c = canvas.pixels[x + y * canvas.width]) < params.get(0).value) {
while ( (c = canvas.pixels[x + y * canvas.width]) < params.get(0).getValue()) {
x++;
if (x >= canvas.width) return canvas.width-1;
}
@@ -293,7 +293,7 @@ class ASDFPIXELSORT extends Shader {
int y = _y;
color c;
if (y < canvas.height) {
while ( (c = canvas.pixels[x + y * canvas.width]) < params.get(0).value) {
while ( (c = canvas.pixels[x + y * canvas.width]) < params.get(0).getValue()) {
y++;
if (y >= canvas.height) return -1;
}
@@ -306,7 +306,7 @@ class ASDFPIXELSORT extends Shader {
int y = _y+1;
color c;
if (y < canvas.height) {
while ( (c = canvas.pixels[x + y * canvas.width]) > params.get(0).value) {
while ( (c = canvas.pixels[x + y * canvas.width]) > params.get(0).getValue()) {
y++;
if (y >= canvas.height) return canvas.height-1;
}
@@ -320,7 +320,7 @@ class ASDFPIXELSORT extends Shader {
int y = _y;
color c;
if (y < canvas.height) {
while (brightness (c = canvas.pixels[x + y * canvas.width]) < params.get(0).value) {
while (brightness (c = canvas.pixels[x + y * canvas.width]) < params.get(0).getValue()) {
y++;
if (y >= canvas.height) return -1;
}
@@ -333,7 +333,7 @@ class ASDFPIXELSORT extends Shader {
int y = _y+1;
color c;
if (y < canvas.height) {
while (brightness (c = canvas.pixels[x + y * canvas.width]) > params.get(0).value) {
while (brightness (c = canvas.pixels[x + y * canvas.width]) > params.get(0).getValue()) {
y++;
if (y >= canvas.height) return canvas.height-1;
}
@@ -347,7 +347,7 @@ class ASDFPIXELSORT extends Shader {
int y = _y;
color c;
if (y < canvas.height) {
while ( (c = canvas.pixels[x + y * canvas.width]) > params.get(0).value) {
while ( (c = canvas.pixels[x + y * canvas.width]) > params.get(0).getValue()) {
y++;
if (y >= canvas.height) return -1;
}
@@ -360,7 +360,7 @@ class ASDFPIXELSORT extends Shader {
int y = _y+1;
color c;
if (y < canvas.height) {
while ( (c = canvas.pixels[x + y * canvas.width]) < params.get(0).value) {
while ( (c = canvas.pixels[x + y * canvas.width]) < params.get(0).getValue()) {
y++;
if (y >= canvas.height) return canvas.height-1;
}
@@ -451,18 +451,24 @@ class DISTORTER extends Shader {
buffer = canvas.get();
buffer.resize(canvas.width, canvas.height);
float neww = map(params.get(0).value, 2, initBufferW-2, 2, buffer.width/4-2);
float newh = map(params.get(1).value, 2, initBufferH-2, 2, buffer.height/4-2);
float neww = map(params.get(0).getValue(), 2, initBufferW-2, 2, buffer.width/4-2);
float newh = map(params.get(1).getValue(), 2, initBufferH-2, 2, buffer.height/4-2);
do_blend = boolean(int(params.get(2).value));
shift_amt = params.get(3).value;
scalex = params.get(4).value;
scaley = params.get(5).value;
blend_mode = blends[(int)params.get(6).value];
channel = (int)params.get(7).value;
/*
do_blend = boolean(int(params.get(2).getValue()));
shift_amt = params.get(3).getValue();
scalex = params.get(4).getValue();
scaley = params.get(5).getValue();
blend_mode = blends[(int)params.get(6).getValue()];
channel = (int)params.get(7).getValue();
*/
do_blend = boolean(int(params.get(2).getValue()));
shift_amt = params.get(3).getValue();
scalex = params.get(4).getValue();
scaley = params.get(5).getValue();
blend_mode = blends[(int)params.get(6).getValue()];
channel = (int)params.get(7).getValue();
float totalnum = neww+newh;
float times = (totalnum/floor(totalnum/neww));
@@ -636,12 +642,12 @@ class FM extends Shader {
rw = canvas.width;
do_blend = boolean(int(params.get(0).value));
blend_mode = blends[(int)params.get(1).value];
omega = map(sqrt(params.get(2).value), 0, 1, min_omega, max_omega);
float phase = map(sq(params.get(3).value), 0, 1, min_phase_mult, max_phase_mult);
colorspace = (int)params.get(4).value;
quantval = (int) params.get(5).value;
do_blend = boolean(int(params.get(0).getValue()));
blend_mode = blends[(int)params.get(1).getValue()];
omega = map(sqrt(params.get(2).getValue()), 0, 1, min_omega, max_omega);
float phase = map(sq(params.get(3).getValue()), 0, 1, min_phase_mult, max_phase_mult);
colorspace = (int)params.get(4).getValue();
quantval = (int) params.get(5).getValue();
if (rw != canvas.width || rh != canvas.height) {
@@ -830,7 +836,7 @@ class WZIP extends Shader {
canvas.noStroke();
if (boolean((int)params.get(3).value)) { /////////////////////
if (boolean((int)params.get(3).getValue())) { /////////////////////
canvas.colorMode(HSB, 255);
colorMode(HSB, 255);
} else {
@@ -838,8 +844,8 @@ class WZIP extends Shader {
colorMode(RGB, 255);
}
scalingfactorin = map(params.get(1).value, 0, 1, 0, params.get(0).value); /////////////////////
scalingfactorout = map(params.get(2).value, 0, 1, 0, params.get(0).value); /////////////////////
scalingfactorin = map(params.get(1).getValue(), 0, 1, 0, params.get(0).getValue()); /////////////////////
scalingfactorout = map(params.get(2).getValue(), 0, 1, 0, params.get(0).getValue()); /////////////////////
@@ -849,7 +855,7 @@ class WZIP extends Shader {
for (int x=0; x<img.width; x++) {
color c = img.get(x, y);
float r, g, b;
if (boolean((int)params.get(3).value)) { /////////////////////
if (boolean((int)params.get(3).getValue())) { /////////////////////
r = hue(c)>127?hue(c)-256:hue(c);
g = saturation(c)>127?saturation(c)-256:saturation(c);
b = brightness(c)>127?brightness(c)-256:brightness(c);
@@ -895,7 +901,7 @@ class WZIP extends Shader {
}
if (boolean((int)params.get(4).value)) option1(); /////////////////////
if (boolean((int)params.get(4).getValue())) option1(); /////////////////////
else option2();
@@ -1035,7 +1041,7 @@ class AUECHO extends Shader {
}
void apply() {
canvas.beginDraw();
if (boolean((int)params.get(0).value)) {
if (boolean((int)params.get(0).getValue())) {
canvas.colorMode(HSB);
colorMode(HSB);
} else {
@@ -1044,12 +1050,12 @@ class AUECHO extends Shader {
}
canvas.loadPixels();
float _delay = params.get(1).value;
float decay = params.get(2).value;
float _delay = params.get(1).getValue();
float decay = params.get(2).getValue();
int delay = (int)(canvas.pixels.length * _delay);
color[] history = new color[canvas.pixels.length];
int blendMode =this.blends[(int)params.get(3).value];
int blendMode =this.blends[(int)params.get(3).getValue()];
for ( int i = 0, l = canvas.pixels.length; i<l; i++) {
history[i] = canvas.pixels[i];
}
@@ -1069,7 +1075,7 @@ class AUECHO extends Shader {
canvas.pixels[i] = history[i] = blendColor(origColor, toColor, blendMode);
}
canvas.updatePixels();
if (boolean((int)params.get(0).value)) {
if (boolean((int)params.get(0).getValue())) {
canvas.colorMode(RGB);
colorMode(RGB);
}
@@ -1137,10 +1143,10 @@ class SLITSCAN extends Shader {
changeParam(2, new Param("y num", INTVAL, 1, s, new int[]{RANDOM}));
}
//depth = (int)params.get(1).value;
//depth = (int)params.get(1).getValue();
//println(depth);
fxnum = (int)random(params.get(1).value);
fynum = (int)random(params.get(2).value);
fxnum = (int)random(params.get(1).getValue());
fynum = (int)random(params.get(2).getValue());
fx = new int[fxnum+1];
fy = new int[fynum+1];
@@ -1276,9 +1282,9 @@ class WAHWAH extends Shader {
// params.add(new Param ("blend mode", INTVAL, 0, this.blends.length-1, new int[]{RANDOM }));
}
void apply() {
res = params.get(0).value;
depth = params.get(1).value;
freqofs = params.get(2).value;
res = params.get(0).getValue();
depth = params.get(1).getValue();
freqofs = params.get(2).getValue();
//res = 12.5
//depth = 0.8;
//freqofs = 0.9;
@@ -1365,15 +1371,15 @@ class PHASER extends Shader {
*/
void apply() {
mode = (int)params.get(0).value;
float mFreq = params.get(1).value;
mode = (int)params.get(0).getValue();
float mFreq = params.get(1).getValue();
int mDryWet = 255;
int mDepth = (int)params.get(2).value;
int mFeedback = (int)params.get(3).value;
float mPhase = params.get(4).value;
int mDepth = (int)params.get(2).getValue();
int mFeedback = (int)params.get(3).getValue();
float mPhase = params.get(4).getValue();
//these two are only changed if mode = 1
int mStages = 2;
@@ -1402,8 +1408,8 @@ class PHASER extends Shader {
*/
// enable these for some more fun :)
if (mode == 1) {
mStages = (int)params.get(5).value;
mSampleRate = params.get(6).value;
mStages = (int)params.get(5).getValue();
mSampleRate = params.get(6).getValue();
}
//init
float gain = 0, fbout = 0;
@@ -1473,10 +1479,10 @@ class ECHO extends Shader {
result = createImage(canvas.width, canvas.height, RGB);
}
void apply() {
mode = (int)params.get(0).value;
mode = (int)params.get(0).getValue();
int xp = (int)params.get(1).value;
int yp = (int)params.get(2).value;
int xp = (int)params.get(1).getValue();
int yp = (int)params.get(2).getValue();
canvas.beginDraw();
canvas.colorMode(RGB);
@@ -1587,10 +1593,10 @@ class DARKER extends Shader {
void apply() {
// bright = knobZero;
int count = int(params.get(0).value);
darken = int(params.get(1).value);
thresh = int(params.get(2).value);
mode = int(params.get(3).value);
int count = int(params.get(0).getValue());
darken = int(params.get(1).getValue());
thresh = int(params.get(2).getValue());
mode = int(params.get(3).getValue());
canvas.beginDraw();
canvas.colorMode(HSB);
@@ -1654,9 +1660,9 @@ class BRIGHTER extends Shader {
}
void apply() {
brighten = int(params.get(2).value);
thresh2 = int(params.get(1).value);
thresh = int(params.get(0).value);
brighten = int(params.get(2).getValue());
thresh2 = int(params.get(1).getValue());
thresh = int(params.get(0).getValue());
canvas.beginDraw();
canvas.colorMode(HSB);
@@ -1700,7 +1706,7 @@ class AMPLIFY extends Shader {
}
void apply() {
canvas.beginDraw();
if (params.get(3).value > 0) colorMode(HSB);
if (params.get(3).getValue() > 0) colorMode(HSB);
else {
colorMode(RGB);
}
@@ -1709,7 +1715,7 @@ class AMPLIFY extends Shader {
float h = hue(canvas.pixels[i]);
float s = saturation(canvas.pixels[i]);
float b = brightness(canvas.pixels[i]);
canvas.pixels[i] = color(h+params.get(0).value, s+params.get(1).value, b+params.get(2).value);
canvas.pixels[i] = color(h+params.get(0).getValue(), s+params.get(1).getValue(), b+params.get(2).getValue());
}
canvas.updatePixels();
canvas.endDraw();
@@ -1741,14 +1747,14 @@ class BROKENCOLORROT extends Shader {
}
void apply() {
canvas.beginDraw();
if (params.get(3).value > 0) colorMode(HSB);
if (params.get(3).getValue() > 0) colorMode(HSB);
else {
colorMode(RGB);
}
canvas.loadPixels();
float h = params.get(0).value;
float s = params.get(1).value;
float b = params.get(2).value;
float h = params.get(0).getValue();
float s = params.get(1).getValue();
float b = params.get(2).getValue();
for (int i = 0; i < canvas.width*canvas.height; i++) {
h = hue(canvas.pixels[i])+h;
if (h > 255) h -= 255;
@@ -1779,7 +1785,7 @@ class POSTER extends Shader {
params.add(new Param("levels", INTVAL, 2, 10, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE}));
}
void apply() {
levels = (int)params.get(0).value;
levels = (int)params.get(0).getValue();
canvas.beginDraw();
canvas.filter(POSTERIZE, levels);
canvas.endDraw();
@@ -1809,7 +1815,7 @@ class DUAL extends Shader {
buffer = createImage(canvas.width, canvas.height, ARGB);
}
void apply() {
switch((int)params.get(1).value) {
switch((int)params.get(1).getValue()) {
case(0):
dirx = 1;
diry = 1;
@@ -1827,13 +1833,13 @@ class DUAL extends Shader {
diry = -1;
break;
}
dualColor = (int)params.get(0).value;
dualColor = (int)params.get(0).getValue();
buffer.resize(canvas.width, canvas.height);
canvas.beginDraw();
canvas.imageMode(CORNER);
canvas.loadPixels();
buffer.loadPixels();
if ((int)params.get(2).value > 0) {
if ((int)params.get(2).getValue() > 0) {
for (int i = 0; i < canvas.width*canvas.height; i++) {
buffer.pixels[i] = canvas.pixels[i]+dualColor;
}
@@ -1867,17 +1873,17 @@ class GRAUZONE extends Shader {
GRAUZONE() {
name = "fxGrauzone";
params.add(new Param("delay (in frames)", INTVAL, 3, 100, new int[]{RANDOM}));
nFrames = (int)params.get(0).value;
nFrames = (int)params.get(0).getValue();
buffer = new PImage[nFrames];
}
int nFramesPrev;
void apply() {
nFramesPrev = nFrames;
if (nFramesPrev != (int)params.get(0).value) {
if (nFramesPrev != (int)params.get(0).getValue()) {
iWrite = 0;
iRead = 1;
int nFramesOld = nFrames;
nFrames = (int)params.get(0).value;
nFrames = (int)params.get(0).getValue();
if (nFrames > nFramesOld) {
buffer = new PImage[nFrames];
}
@@ -1933,10 +1939,10 @@ class COPYZOOM extends Shader {
canvas.imageMode(CORNER);
if (buffer.width != canvas.width || buffer.height != canvas.height) buffer.resize(canvas.width, canvas.height);
buffer = canvas.get();
coprw = int(map(params.get(0).value, 0, 1, 1, canvas.width));
coprh = int(map(params.get(1).value, 0, 1, 1, canvas.height));
coprx = int(map(params.get(2).value, 0, 1, 0, canvas.width-coprw));
copry = int(map(params.get(3).value, 0, 1, 0, canvas.height-coprh));
coprw = int(map(params.get(0).getValue(), 0, 1, 1, canvas.width));
coprh = int(map(params.get(1).getValue(), 0, 1, 1, canvas.height));
coprx = int(map(params.get(2).getValue(), 0, 1, 0, canvas.width-coprw));
copry = int(map(params.get(3).getValue(), 0, 1, 0, canvas.height-coprh));
canvas.beginDraw();
buffer.copy(coprx, copry, coprw, coprh, 0, 0, canvas.width, canvas.height);
canvas.image(buffer, 0, 0, canvas.width, canvas.height);
@@ -1987,10 +1993,10 @@ class SUBTLESORT extends Shader {
}
void apply() {
channel_weight = map(renderSize, 4, 15000, 0, 1.5)*params.get(0).value;
channel = (int)params.get(1).value;
direction = (int)params.get(2).value;
mode = (int)params.get(3).value;
channel_weight = map(renderSize, 4, 15000, 0, 1.5)*params.get(0).getValue();
channel = (int)params.get(1).getValue();
direction = (int)params.get(2).getValue();
mode = (int)params.get(3).getValue();
canvas.beginDraw();
canvas.noStroke();
@@ -2089,10 +2095,10 @@ class SCANKER extends Shader {
directionParamIndex = 4;
}
void apply() {
mode = (int)params.get(3).value;
mode = (int)params.get(3).getValue();
canvas.beginDraw();
canvas.loadPixels();
float factor = params.get(0).value + params.get(1).value + params.get(2).value;
float factor = params.get(0).getValue() + params.get(1).getValue() + params.get(2).getValue();
if (mode == 0) {
for (int i = 0; i < canvas.width*canvas.height; i++) {
// canvas.pixels[i] = canvas.pixels[i]+((i/1000)*scankMulti);
@@ -2150,14 +2156,14 @@ class MASK extends Shader {
if (foreground.width != canvas.width || foreground.height != canvas.height) foreground.resize(canvas.width, canvas.height);
backgroundLayer = (int)params.get(0).value;
maskLayer = (int)params.get(1).value;
invert = (int)params.get(2).value;
bandwidth = (int)params.get(3).value;
val = (int)params.get(4).value;
chan = (int)params.get(5).value;
do_blend = boolean((int)params.get(6).value);
blend_mode = blends[(int)params.get(7).value];
backgroundLayer = (int)params.get(0).getValue();
maskLayer = (int)params.get(1).getValue();
invert = (int)params.get(2).getValue();
bandwidth = (int)params.get(3).getValue();
val = (int)params.get(4).getValue();
chan = (int)params.get(5).getValue();
do_blend = boolean((int)params.get(6).getValue());
blend_mode = blends[(int)params.get(7).getValue()];
if (backgroundLayer <= 0) {
background.resize(source.width, source.height);
@@ -2296,13 +2302,13 @@ class DRAWSTROKES extends Shader {
int rw, rh;
void apply() {
stat_type = (int)params.get(0).value;
stroke_len = (int)params.get(1).value;
angles_no = (int)params.get(2).value;
segments = (int)params.get(3).value;
stroke_width = params.get(4).value;
stroke_alpha = (int)params.get(5).value;
iterations = (int)params.get(6).value;
stat_type = (int)params.get(0).getValue();
stroke_len = (int)params.get(1).getValue();
angles_no = (int)params.get(2).getValue();
segments = (int)params.get(3).getValue();
stroke_width = params.get(4).getValue();
stroke_alpha = (int)params.get(5).getValue();
iterations = (int)params.get(6).getValue();
if (rw != canvas.width || rh != canvas.height) { //doesnt account image swap
len = (canvas.width<canvas.height?canvas.width:canvas.height)/3;
@@ -2506,7 +2512,7 @@ class DRAWGENERATIVE extends Shader {
buffer.endDraw();
}
buffer.beginDraw();
buffer.strokeWeight(params.get(0).value);
buffer.strokeWeight(params.get(0).getValue());
for (int i=1; i<n; i++) {
color c = canvas.get((int)cx[i], (int)cy[i]);
buffer.stroke(c);
@@ -2624,15 +2630,15 @@ class PIXELDRIFTER extends Shader {
img.resize(rw, rh);
buffer = createGraphics(rw, rh);
}
channel_off = map(params.get(0).value, 0, 1, 10, max(rw, rh));
iteration_no = (int)params.get(1).value;
scale = params.get(2).value;
feedback = params.get(3).value;
direction = (int)params.get(4).value;
do_blend = boolean((int)params.get(5).value);
blend_mode = blends[(int)params.get(6).value];
channel = (int)params.get(7).value == 1 ? HUE : RGB;
automate_channel_offset = boolean((int)params.get(8).value);
channel_off = map(params.get(0).getValue(), 0, 1, 10, max(rw, rh));
iteration_no = (int)params.get(1).getValue();
scale = params.get(2).getValue();
feedback = params.get(3).getValue();
direction = (int)params.get(4).getValue();
do_blend = boolean((int)params.get(5).getValue());
blend_mode = blends[(int)params.get(6).getValue()];
channel = (int)params.get(7).getValue() == 1 ? HUE : RGB;
automate_channel_offset = boolean((int)params.get(8).getValue());
acho_step = 256.0 / iteration_no;
img = canvas.get();
@@ -2755,11 +2761,11 @@ class DRIPDRIP extends Shader {
}
void apply() {
minsteps = (int)map(params.get(1).value, 0, 1, 1, max(canvas.width, canvas.height)/10);
maxsteps = (int)map(params.get(0).value, 0, 1, minsteps, max(canvas.width, canvas.height)/10);
autoPivot = params.get(2).value;
//brightmode = boolean((int)params.get(3).value);
//autotoggle = boolean((int)params.get(4).value);
minsteps = (int)map(params.get(1).getValue(), 0, 1, 1, max(canvas.width, canvas.height)/10);
maxsteps = (int)map(params.get(0).getValue(), 0, 1, minsteps, max(canvas.width, canvas.height)/10);
autoPivot = params.get(2).getValue();
//brightmode = boolean((int)params.get(3).getValue());
//autotoggle = boolean((int)params.get(4).getValue());
if (rw != canvas.width || rh != canvas.height) {
rw = canvas.width;
rh = canvas.height;
@@ -2868,10 +2874,10 @@ class WRONGQSORT extends Shader {
}
void apply() {
random_point = params.get(1).value;
mode = boolean((int)params.get(2).value);
do_blend = boolean((int)params.get(3).value);
blend_mode = blends[(int)params.get(4).value];
random_point = params.get(1).getValue();
mode = boolean((int)params.get(2).getValue());
do_blend = boolean((int)params.get(3).getValue());
blend_mode = blends[(int)params.get(4).getValue()];
if (rw != canvas.width || rh != canvas.height) {
rw = canvas.width;
@@ -2882,7 +2888,7 @@ class WRONGQSORT extends Shader {
img = canvas.get();
len = rw * rh;
int v = (int)map(params.get(0).value, 0, 1, 1, len-1);
int v = (int)map(params.get(0).getValue(), 0, 1, 1, len-1);
buffer.beginDraw();
buffer.image(img, 0, 0);
@@ -2970,10 +2976,10 @@ class VHS extends Shader {
}
void apply() {
sxl = (int)params.get(0).value;
syl = (int)params.get(1).value;
bass = (int)params.get(2).value;
treble = (int)params.get(3).value;
sxl = (int)params.get(0).getValue();
syl = (int)params.get(1).getValue();
bass = (int)params.get(2).getValue();
treble = (int)params.get(3).getValue();
int virtw = canvas.width;
@@ -3185,26 +3191,26 @@ class LZ7 extends Shader {
}
img = canvas.get();
colorspace = (int)params.get(12).value == 0 ?RGB:HSB;
do_blend = boolean((int)params.get(13).value);
blend_mode = blends[(int)params.get(14).value];
colorspace = (int)params.get(12).getValue() == 0 ?RGB:HSB;
do_blend = boolean((int)params.get(13).getValue());
blend_mode = blends[(int)params.get(14).getValue()];
//red
compressor_attributes[0][0] = (int)params.get(0).value;
compressor_attributes[0][1] = (int)(params.get(1).value*compressor_attributes[0][0]);
number_of_glitches[0][0] = (int)params.get(2).value;
number_of_glitches[0][1] = params.get(3).value;
compressor_attributes[0][0] = (int)params.get(0).getValue();
compressor_attributes[0][1] = (int)(params.get(1).getValue()*compressor_attributes[0][0]);
number_of_glitches[0][0] = (int)params.get(2).getValue();
number_of_glitches[0][1] = params.get(3).getValue();
//green
compressor_attributes[1][0] = (int)params.get(4).value;
compressor_attributes[1][1] = (int)(params.get(5).value*compressor_attributes[1][0]);
number_of_glitches[1][0] = (int)params.get(6).value;
number_of_glitches[1][1] = params.get(7).value;
compressor_attributes[1][0] = (int)params.get(4).getValue();
compressor_attributes[1][1] = (int)(params.get(5).getValue()*compressor_attributes[1][0]);
number_of_glitches[1][0] = (int)params.get(6).getValue();
number_of_glitches[1][1] = params.get(7).getValue();
//blue
compressor_attributes[2][0] = (int)params.get(8).value;
compressor_attributes[2][1] = (int)(params.get(9).value*compressor_attributes[2][0]);
number_of_glitches[2][0] = (int)params.get(10).value;
number_of_glitches[2][1] = params.get(11).value;
compressor_attributes[2][0] = (int)params.get(8).getValue();
compressor_attributes[2][1] = (int)(params.get(9).getValue()*compressor_attributes[2][0]);
number_of_glitches[2][0] = (int)params.get(10).getValue();
number_of_glitches[2][1] = params.get(11).getValue();
comp1 = new LZ77( compressor_attributes[0][0], compressor_attributes[0][1] );
comp2 = new LZ77( compressor_attributes[1][0], compressor_attributes[1][1] );
@@ -3450,20 +3456,20 @@ class LENS extends Shader {
changeParam(0, new Param("lens image layer", INTVAL, 0, shaderListLength-1, new int[]{RANDOM}));
}
img = canvas.get();
if ((int)params.get(0).value == pos) {
if ((int)params.get(0).getValue() == pos) {
limg = canvas.get();
} else {
limg = gui.shaderList.get((int)params.get(0).value).result.get();
limg = gui.shaderList.get((int)params.get(0).getValue()).result.get();
}
power_vals[0] = params.get(1).value;
power_vals[1] = params.get(2).value;
types[0] = (int)params.get(3).value;
types[1] = (int)params.get(4).value;
channels[0] = (int)params.get(5).value;
channels[1] = (int)params.get(6).value;
bendx = params.get(7).value;
bendy = params.get(8).value;
power_vals[0] = params.get(1).getValue();
power_vals[1] = params.get(2).getValue();
types[0] = (int)params.get(3).getValue();
types[1] = (int)params.get(4).getValue();
channels[0] = (int)params.get(5).getValue();
channels[1] = (int)params.get(6).getValue();
bendx = params.get(7).getValue();
bendy = params.get(8).getValue();
facts[0] = bendx * img.width;
facts[1] = bendy * img.height;
@@ -3660,25 +3666,25 @@ class SLICER extends Shader {
changeParam(0, new Param("mask layer", INTVAL, 0, shaderListLength-1, new int[]{RANDOM}));
}
img = canvas.get();
if ((int)params.get(0).value == pos) {
if ((int)params.get(0).getValue() == pos) {
mimg = canvas.get();
} else {
mimg = gui.shaderList.get((int)params.get(0).value).result.get();
mimg = gui.shaderList.get((int)params.get(0).getValue()).result.get();
}
max_rotation = params.get(1).value;
thr_min = (int)params.get(2).value;
thr_max = (int)params.get(3).value;
max_shift = params.get(4).value;
type = (int)params.get(5).value;
do_blend = boolean((int)params.get(6).value);
blend_type = blends[(int)params.get(7).value];
threshold = params.get(8).value;
min_comp_size = (int)params.get(9).value;
blur = (int)params.get(10).value;
stat_type = (int)params.get(11).value;
fixed_rotation = boolean((int)params.get(12).value);
max_rotation = params.get(1).getValue();
thr_min = (int)params.get(2).getValue();
thr_max = (int)params.get(3).getValue();
max_shift = params.get(4).getValue();
type = (int)params.get(5).getValue();
do_blend = boolean((int)params.get(6).getValue());
blend_type = blends[(int)params.get(7).getValue()];
threshold = params.get(8).getValue();
min_comp_size = (int)params.get(9).getValue();
blur = (int)params.get(10).getValue();
stat_type = (int)params.get(11).getValue();
fixed_rotation = boolean((int)params.get(12).getValue());
//println("");
//println("Processing...");
@@ -4025,17 +4031,17 @@ class STREAKER extends Shader {
img.resize(W, H);
}
img = canvas.get();
int p0 = (int)params.get(0).value;
int p0 = (int)params.get(0).getValue();
v = (p0 == 0 || p0 == 2) ? true : false;
h = (p0 == 1 || p0 == 2) ? true : false;
Vrev = boolean((int)params.get(1).value);
Hrev = boolean((int)params.get(2).value);
tol = params.get(3).value;
rand = params.get(4).value;
mode = (int)params.get(5).value;
sum = (int)params.get(6).value;
lim = (int)params.get(7).value;
iterations = (int)params.get(8).value;
Vrev = boolean((int)params.get(1).getValue());
Hrev = boolean((int)params.get(2).getValue());
tol = params.get(3).getValue();
rand = params.get(4).getValue();
mode = (int)params.get(5).getValue();
sum = (int)params.get(6).getValue();
lim = (int)params.get(7).getValue();
iterations = (int)params.get(8).getValue();
PGraphics temp = createGraphics(img.width, img.height);
@@ -4215,13 +4221,13 @@ class SEGMENTER extends Shader {
bounds[3]= rh;
}
img = canvas.get();
thres = (int)params.get(0).value;
mode = (int)params.get(1).value;
diag = boolean((int)params.get(2).value);
v = boolean((int)params.get(3).value);
h = boolean((int)params.get(4).value);
choice = boolean((int)params.get(5).value);
iterations = (int)params.get(6).value;
thres = (int)params.get(0).getValue();
mode = (int)params.get(1).getValue();
diag = boolean((int)params.get(2).getValue());
v = boolean((int)params.get(3).getValue());
h = boolean((int)params.get(4).getValue());
choice = boolean((int)params.get(5).getValue());
iterations = (int)params.get(6).getValue();
canvas.beginDraw();
canvas.image(img, canvas.width/2, canvas.height/2);
canvas.endDraw();
@@ -4341,7 +4347,7 @@ class COLORCRUSHER extends Shader {
params.add(new Param("multiplier", INTVAL, 2, 10, new int[]{SINE, TAN, SAWTOOTH, TRIANG}));
}
void apply() {
m = (int)params.get(0).value;
m = (int)params.get(0).getValue();
canvas.beginDraw();
canvas.loadPixels();
for (int i = 0; i < canvas.pixels.length; i++) {
@@ -4388,8 +4394,8 @@ class JPGCORRUPTION extends Shader {
rh = canvas.height;
img.resize(rw, rh);
}
int probparam = (int)params.get(0).value;
int iterations = (int)params.get(1).value;
int probparam = (int)params.get(0).getValue();
int iterations = (int)params.get(1).getValue();
img = canvas.get();
canvas.beginDraw();
for (int k = 0; k < iterations; k++) {
@@ -4465,7 +4471,7 @@ class WEBPCORRUPTION extends Shader {
rh = canvas.height;
img.resize(rw, rh);
}
int probparam = (int)params.get(0).value;
int probparam = (int)params.get(0).getValue();
img = canvas.get();
canvas.beginDraw();
canvas.image(img, canvas.width/2, canvas.height/2);
@@ -4595,12 +4601,12 @@ class SOX extends Shader {
}
void apply() {
iterations = (int)params.get(1).value;
do_blend = boolean((int)params.get(2).value);
blend_type = blends[(int)params.get(3).value];
depth = (int)params.get(4).value * 8;
samplerate = (int)params.get(5).value;
encoding = (int)params.get(6).value;
iterations = (int)params.get(1).getValue();
do_blend = boolean((int)params.get(2).getValue());
blend_type = blends[(int)params.get(3).getValue()];
depth = (int)params.get(4).getValue() * 8;
samplerate = (int)params.get(5).getValue();
encoding = (int)params.get(6).getValue();
switch(encoding) {
case(0):
type = "s8";
@@ -4639,8 +4645,8 @@ class SOX extends Shader {
coding = "float";
break;
}
rgbyuv = boolean((int)params.get(7).value);
channels = (int)params.get(8).value;
rgbyuv = boolean((int)params.get(7).getValue());
channels = (int)params.get(8).getValue();
getParams();
if (rw != canvas.width || rh != canvas.height) {
@@ -4720,10 +4726,10 @@ class SOXECHO extends SOX {
}
void getParams() {
gainin = params.get(9).value;
gainout = params.get(10).value;
delay = params.get(11).value;
decay = params.get(12).value;
gainin = params.get(9).getValue();
gainout = params.get(10).getValue();
delay = params.get(11).getValue();
decay = params.get(12).getValue();
effectParams = new String[]{"echo", str(gainin), str(gainout), str(delay), str(decay)};
}
}
@@ -4747,9 +4753,9 @@ class SOXALLPASS extends SOX {
params.add(new Param("h/k/q/o", INTVAL, 0, 3, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE}));
}
void getParams() {
frequency = (int)params.get(9).value;
widt = (int)params.get(10).value;
switch((int)params.get(11).value) {
frequency = (int)params.get(9).getValue();
widt = (int)params.get(10).getValue();
switch((int)params.get(11).getValue()) {
case(0):
hkqo = "h";
break;
@@ -4789,9 +4795,9 @@ class SOXBAND extends SOX {
}
void getParams() {
center = (int)params.get(9).value;
widt = (int)params.get(10).value;
switch((int)params.get(11).value) {
center = (int)params.get(9).getValue();
widt = (int)params.get(10).getValue();
switch((int)params.get(11).getValue()) {
case(0):
hkqo = "h";
break;
@@ -4805,7 +4811,7 @@ class SOXBAND extends SOX {
hkqo = "o";
break;
}
n = boolean((int)params.get(12).value);
n = boolean((int)params.get(12).getValue());
effectParams = new String[]{ "band", (n ? "-n " : "") + str(center), str(widt) + hkqo};
}
}
@@ -4830,9 +4836,9 @@ class SOXBANDPASS extends SOX {
params.add(new Param("-c", INTVAL, 0, 1, new int[]{RANDOM, SQUAR}));
}
void getParams() {
frequency = (int)params.get(9).value;
widt = (int)params.get(10).value;
switch((int)params.get(11).value) {
frequency = (int)params.get(9).getValue();
widt = (int)params.get(10).getValue();
switch((int)params.get(11).getValue()) {
case(0):
hkqo = "h";
break;
@@ -4846,7 +4852,7 @@ class SOXBANDPASS extends SOX {
hkqo = "o";
break;
}
c = boolean((int)params.get(12).value);
c = boolean((int)params.get(12).getValue());
effectParams = new String[]{"bandpass", (c ? "-c " : "") + str(frequency), str(widt) + hkqo};
}
@@ -4870,9 +4876,9 @@ class SOXBANDREJECT extends SOX {
params.add(new Param("h/k/q/o", INTVAL, 0, 3, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE}));
}
void getParams() {
frequency = (int)params.get(9).value;
widt = (int)params.get(10).value;
switch((int)params.get(11).value) {
frequency = (int)params.get(9).getValue();
widt = (int)params.get(10).getValue();
switch((int)params.get(11).getValue()) {
case(0):
hkqo = "h";
break;
@@ -4913,10 +4919,10 @@ class SOXBASS extends SOX {
params.add(new Param("seconds", FLOATVAL, 0.001, 10, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE}));
}
void getParams() {
gain = (int)params.get(9).value;
frequency = (int)params.get(10).value;
widt = (int)params.get(11).value;
switch((int)params.get(12).value) {
gain = (int)params.get(9).getValue();
frequency = (int)params.get(10).getValue();
widt = (int)params.get(11).getValue();
switch((int)params.get(12).getValue()) {
case(0):
hkqo = "h";
break;
@@ -4930,7 +4936,7 @@ class SOXBASS extends SOX {
hkqo = "o";
break;
}
seconds = params.get(13).value;
seconds = params.get(13).getValue();
effectParams = new String[]{"bass", str(gain), str(frequency), str(widt) + hkqo};
}
@@ -4952,8 +4958,8 @@ class SOXBEND extends SOX {
//params.add(new Param("h/k/q/o", INTVAL, 0, 3, new int[]{SAWTOOTH, TRIANG, SINE, TAN, TANINVERSE, RAMPUPDOWN, RAMP, RAMPINVERSE}));
}
void getParams() {
//frequency = (int)params.get(9).value;
//widt = (int)params.get(10).value;
//frequency = (int)params.get(9).getValue();
//widt = (int)params.get(10).getValue();
//effectParams = new String[]{"bend", str(frequency), str(widt) + hkqo};
}

View File

@@ -23,6 +23,11 @@ import java.util.Arrays;
Class<?> sketchClass;
VideoExport videoExport;
AudioIn audioIn;
Amplitude loudness;
float volume;
float volumeRoof = 1.0;
int maxFx = 15; //possible amount of effect layers
SDrop drop;
PImage source;

View File

@@ -185,8 +185,7 @@ public class SecondApplet extends PApplet {
//audioindicator
fill(map(volume,0,0.5,0,255));
noStroke();
ellipse(260,15,15,15);
ellipse(260,height-105,15,15);
}
boolean heightOverLimit;
@@ -389,7 +388,11 @@ public class SecondApplet extends PApplet {
for (int i = 0; i < slider.size(); i++) {
if (slider.get(i).hovering || slider.get(i).hovering_anim_btn) sliderHover = true;
if (paused && slider.get(i).animated) paused = false;
params.get(i).audioMulti = slider.get(i).audioVal * volume * 2;
}
if (mouseX > 10 && mouseX < 22 && mouseY > 4+totalBrickHeight+scrollAmount && mouseY < 4+totalBrickHeight+13+scrollAmount) {
hoverActiveButton = true;
@@ -421,8 +424,12 @@ public class SecondApplet extends PApplet {
}
for (int i = 0; i < slider.size(); i++) {
slider.get(i).update();
//params.get(i).value = slider.get(i).value;
//* map(volume,0,1,0.8,1.2);
//slider.get(i).value = map(volume,0,1,0.8,1.2) * slider.get(i).value;
params.get(i).value = slider.get(i).value;
slider.get(i).update();
}
brickBGcol = color(85, 85, 85);
}
@@ -484,8 +491,8 @@ public class SecondApplet extends PApplet {
class Slider {
int x, y, w, h, mode;
int[] osciModes;
float minVal, maxVal, value; //should be private but doesnt work lol
boolean hovering, hovering_anim_btn, animated;
float minVal, maxVal, value, audioVal; //should be private but doesnt work lol
boolean hovering, hovering_anim_btn,hovering_audio_slider, animated;
String label;
Oscillator osci;
@@ -503,7 +510,8 @@ public class SecondApplet extends PApplet {
osci = new Oscillator(int(random(2, 5)), osciModes);
osci.amplitude(minVal, maxVal);
osci.update();
setValue(osci.value);
//setValue(osci.value);
setValue((minVal+maxVal)/2);
animated = true;
@@ -546,14 +554,17 @@ public class SecondApplet extends PApplet {
void update() {
//float audioImpact = (audioVal * volume) + 1;
//setValue(value*(1+audioVal));
osci.update();
// osci.update();
if (animated) {
osci.update();
setValue(osci.value);
}
if (mouseX >= x && mouseX <= x+w && mouseY >= y+scrollAmount && mouseY <= y+h+scrollAmount) {
hovering = true;
@@ -566,6 +577,12 @@ public class SecondApplet extends PApplet {
} else {
hovering_anim_btn = false;
}
if (mouseX >= x+w+20 && mouseX <= x+w+35 && mouseY >= y+scrollAmount && mouseY <= y+h+scrollAmount) {
hovering_audio_slider = true;
} else {
hovering_audio_slider = false;
}
}
void display() {
@@ -585,6 +602,11 @@ public class SecondApplet extends PApplet {
fill(100+(40*int(hovering_anim_btn)));
}
rect(x+w+5, y, h, h);
stroke(255);
line(x+w+5+h+10,y, x+w+5+h+10, y+h);
line(x+w+5+h+5, y+h-(audioVal*h), x+w+5+h+15, y+h-(audioVal*h));
}
}
@@ -650,6 +672,9 @@ public class SecondApplet extends PApplet {
Slider s = slider.get(i);
if (s.hovering) s.press(i);
if (s.hovering_anim_btn) s.animated = !s.animated;
if (s.hovering_audio_slider){
s.audioVal = map(mouseY-(s.y+scrollAmount),0,12,1,0);
}
}
for (int i = bricks.size()-1; i >= 0; i--) {
if (bricks.get(i).hovering) {
@@ -729,12 +754,10 @@ public class SecondApplet extends PApplet {
}
textSize(10);
if (mouseX > 245 && mouseY < 30) {
volumeRoof -= float(event.getCount())/1000;
if(volumeRoof > 1.0) volumeRoof = 1;
if(volumeRoof < 0.0) volumeRoof = 0;
println(volume);
println(volumeRoof);
if (mouseX > 245 && mouseY < height-90 && mouseY > height-120) {
volumeRoof -= float(event.getCount())/100;
if(volumeRoof > 100) volumeRoof = 100;
if(volumeRoof <= 0.01) volumeRoof = 0.01;
}
}
int numberTypedFrame;

View File

@@ -3,6 +3,7 @@ class Param {
int type;
float minValue, maxValue;
float value;
float audioMulti;
int[] osciModes;
Param(String name_, int type_, float minValue_, float maxValue_, int[] osciModes_) {
name = name_;
@@ -11,6 +12,9 @@ class Param {
maxValue = maxValue_;
osciModes = osciModes_;
}
float getValue(){
return(value + ((maxValue-minValue) * audioMulti)); //wenn man so auch die automation-values handhabt, kann man mit automatisierten slidern besser spielen .. mayb
}
}
class Shader {
@@ -59,6 +63,8 @@ class Shader {
paramChanged = true;
}
previousPos = pos;
if(volume > 0) paramChanged = true;
try{
if (previousActive != gui.bricks.get(pos).active) { //fails if brick has not yet been loaded but shader has
@@ -86,7 +92,7 @@ class Shader {
gui.bricks.get(pos).exchangeSlider(paramNo, newParam);
paramChanged = true;
}
void shade() {
if (renderSizeChanged || paramChanged) {
this.setupCanvas();