Moved to Core Library Questions! Why? Read this.
A simple solution would be to use transparency. For example by using no background and making your audioreactive elements transparent.
Another solution might be to work with PGraphics where you draw audio-reactive elements. Not only could you use this for the above transparent solution in more complex setups, but you'd also be able to use the different blend effects on the whole PGraphics (which is also an image).
Adapted Code
A simple solution would be to use transparency. For example by using no background and making your audioreactive elements transparent.
Another solution might be to work with PGraphics where you draw audio-reactive elements. Not only could you use this for the above transparent solution in more complex setups, but you'd also be able to use the different blend effects on the whole PGraphics (which is also an image).
Adapted Code
- import ddf.minim.analysis.*;
- import ddf.minim.*;
- Minim minim;
- AudioInput in;
- FFT fftLin;
- void setup() {
- size(600, 600);
- minim = new Minim(this);
- in = minim.getLineIn();
- fftLin = new FFT(in.bufferSize(), in.sampleRate());
- fftLin.linAverages(30);
- background(0);
- rectMode(CENTER);
- colorMode(HSB);
- noStroke();
- smooth();
- }
- void draw() {
- fftLin.forward(in.mix);
- float winner = 0;
- int whichBand = 0;
- for (int i=0; i<fftLin.avgSize(); i++) {
- if (fftLin.getBand(i) > winner) {
- winner = fftLin.getBand(i);
- whichBand = i;
- }
- }
- float hue = map(whichBand, 0, 32, 0, 255);
- fill(hue, 255, 255, 5);
- ellipse(width/2, height/2, winner*1.2, winner*1.2);
- }
- void stop() {
- in.close();
- minim.stop();
- super.stop();
- }