处理:在处理中获取正在播放的声音文件的音量 [英] Processing: Getting the volume of a playing sound file in Processing

查看:40
本文介绍了处理:在处理中获取正在播放的声音文件的音量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个根据正在播放的音乐音量而变化的动画.如何获取正在处理中播放的音乐音量.

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.

推荐答案

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);
}

这应该会给你一个想法.您需要在操作系统声音设置中设置正确的默认音频源.在 Windows 上,您很可能希望将立体声混音设置为默认值,这样可以让您听到计算机发出的声音.如果它不存在,要么您必须检查显示禁用/断开连接的设备",要么您的音频驱动程序有误,要么您的声卡不支持它.在这种情况下,您将需要使用麦克风或直接从 Processing 播放声音.

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.

这篇关于处理:在处理中获取正在播放的声音文件的音量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆