Processing中如何获取当前播放的音频作为音频输入?

How to get the currently playing audio as audio input in Processing?

我正在创建一个简单的音频可视化工具。这是代码

import ddf.minim.analysis.*;
import ddf.minim.*;

Minim minim;
AudioInput in;
FFT fft;

int w;

PImage fade;

void setup() {
  size(640,480); // draw screen
  minim = new Minim(this); // new minim object

  in = minim.getLineIn(Minim.STEREO,512); // audio input from microphone (have to change this to get currently playing audio)

  fft = new FFT(in.bufferSize(),in.sampleRate()); // new fft object

  fft.logAverages(60,7);

  stroke(255); 
  w=width/fft.avgSize();
  strokeWeight(w); // display lines as bars

  background(0);

}

void draw() {
  background(0);
  fft.forward(in.mix); //generate fourier series

  for(int i = 0; i < fft.avgSize(); i++) {
    line((i*w)+(w/2),height, (i*w)+(w/2), height - fft.getAvg(i)*4); // draw bars
  }
}

此处in = minim.getLineIn(Minim.STEREO,512);给出了来自麦克风的音频输入。但我需要获取计算机当前正在播放的音频 (您从扬声器或耳机中听到的内容) 并将其可视化。

如果有任何方法或任何其他方法可以将当前正在播放的音频作为输入,请提及。提前致谢:)

像这样的问题最好通过阅读 the reference:

来回答

An AudioInput is a connection to the current record source of the computer. How the record source for a computer is set will depend on the soundcard and OS, but typically a user can open a control panel and set the source from there. Unfortunately, there is no way to set the record source from Java.

换句话说,这是用户必须在其控制面板中更改的设置。这似乎得到了证实here and here