问题
I'm trying to write an animation which changes according to the volume of music being played. How do I get the volume of music that is playing in Processing.
回答1:
import ddf.minim.spi.*;
import ddf.minim.signals.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.ugens.*;
import ddf.minim.effects.*;
Minim minim;
AudioInput in;
void setup() {
minim = new Minim(this);
in = minim.getLineIn();
}
void draw() {
float level = in.mix.level(); // value from 0 to 1
background(255 * level);
}
This should give you an idea. You will need to set right default audio source in your operating system sound settings. On Windows, you will most likely want to set Stereo Mix as default, that will give you the sound which goes out of your computer. If it is not there, either you have to check "show disabled/disconnected devices", you have wrong audio drivers or your soundcard doesn't support it. In that case you will need to use Microphone or play sound directly from Processing.

来源:https://stackoverflow.com/questions/24588279/processing-getting-the-volume-of-a-playing-sound-file-in-processing