Processing: Getting the volume of a playing sound file in Processing

最后都变了- 提交于 2019-12-25 02:58:23

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!