I noticed you weren't actually using a lot of variables (mouse, time). Perhaps once you do actually use them, you can include them again. For now here is an example of your adapted code that sends the minim audiobuffers to the shader and utilizes them to change the color accordingly.
Adapted Fragment Shader
Adaped Code
Adapted Fragment Shader
- #define PROCESSING_COLOR_SHADER
- uniform vec2 resolution;
- uniform float bufferSize;
- uniform float audioLeft[1024];
- uniform float audioRight[1024];
- varying vec4 vertColor;
- void main(void) {
- vec2 c = vec2 (-1.0 + 2.0 * gl_FragCoord.x / resolution.x, 1.0 - 2.0 * gl_FragCoord.y / resolution.y);
- int bufX = int(bufferSize * gl_FragCoord.x / resolution.x);
- float d1 = c.y - audioLeft[bufX];
- float d2 = c.y - audioRight[bufX];
- float y = c.y + d1 + d2;
- float g = abs(0.3 / y);
- float h = abs(c.x);
- vec3 col = vec3(g * (1.0 - h), g * h, g * 1.5);
- gl_FragColor = vec4(col, 1.0);
- }
Adaped Code
- import ddf.minim.*;
- Minim minim;
- AudioInput in;
- PShader myShader;
- void setup() {
- size(1024, 1080, P2D);
- minim = new Minim(this);
- in = minim.getLineIn();
- myShader = loadShader("shader.glsl");
- myShader.set("resolution", float(width), float(height));
- myShader.set("bufferSize", 1024.0);
- noStroke();
- shader(myShader);
- }
- void draw() {
- background(0);
- float[] left = new float[in.bufferSize()];
- float[] right = new float[in.bufferSize()];
- for (int i=0; i<in.bufferSize(); i++) {
- left[i] = in.left.get(i);
- right[i] = in.right.get(i);
- }
- myShader.set("audioLeft", left);
- myShader.set("audioRight", right);
- rect(0, 0, width, height);
- }